我想解决下面给出的等式wrt c
其中n = k = 30,x在下面给出。
我在uniroot
包中使用了rootSolve
命令,并在代码后面给了我一个错误。
model <- function(c){
sx <- apply(x,1, function(x) exp(c*x))
numerator <- sum(sx[2:30])-29*sx[1]
denumerator <- (30*29*(sx[1]-1))
numerator/denumerator-0.2542
}
ss <- uniroot(model, c(0,1))
根是已知的并且是0.0331。
那我的错误在哪里?如何解决?