代码;
ll<-function(theta){
a <- theta[1]
b <- theta[2]
ll<-N*log(a)+sum(log(exp(-b*x2)-exp(-b*x1)))-a*(1-exp(-b*337))
return(-ll)
}
x1 <- c(9,21,32,36,43,45,50,58,63,70,71,77,78,87,91,92,95,98,104,105,116,149,156,247,249,250,337)
x2 <- c(0,9,21,32,36,43,45,50,58,63,70,71,77,78,87,91,92,95,98,104,105,116,149,156,247,249,250)
y <- 0:26
z <- 1:27
N <- length(x1);
res<-nlminb(c(1,5),ll,lower=c(0,0),upper=c(100,100))
print(res)
遇到的问题:
$par
[1] 1 5
$objective
[1] Inf
$convergence
[1] 0
$iterations
[1] 1
$evaluations
function gradient
2 2
$message
[1] "X-convergence (3)"
Warning message:
In nlminb(c(1, 5), ll, lower = c(0, 0), upper = c(100, 100)) :
NA/NaN function evaluation
> 麻烦帮忙解决一些