为什么我的代码中的向量为零?

时间:2017-06-21 21:54:12

标签: r

data<-c(50,82,115,126,155,161,243,294,340,384,457,680,855,877,974,1193,1340,1884,2558,3476)

A2<-function(y,lambda){

  func<-function(y,lambda){

    f1<-(1-exp(-(y-50)*lambda))}

  F<-func(y,lambda)

  F_n<-ecdf(y)

  Fn<-c(0,F_n(y))

  a<-numeric()

  for(i in 1:(length(y)-1)){

    a[i]<-((1-Fn[order(y[i])])^2)*(log(1-F[order(y[i])])-
    log(1-F[order(y[i+1])]))

  }
  b<-numeric()

  for(j in 2:(length(y))){

    b[j]<-((Fn[order(y[j])])^2)*(log(F[order(y[j+1])])-log(F[order(y[j])]))

  }

  TEST_STATISTICS<-(-length(y)-1)+(length(y)-1)*sum(a)+(length(y)-1)*sum(b)

  print(TEST_STATISTICS)

  a
}

A2(data,lambda)

0 个答案:

没有答案