我想要非线性模型的两侧95%置信区间。我使用了以下数据:
xvalues<-c(0.92 , 3.00, 6.00 , 9.00 ,12.00 ,15.00, 18.00, 21.00, 24.00, 27.00)
yvalues<-c(210000000 ,210000000 ,200000000 ,180000000, 180000000, 180000000 ,160000000, 160000000 ,160000000, 150000000)
data<-data.frame(xvalues,yvalues)
我为数据拟合了渐近模型:
fit = nls(yvalues ~ SSasymp(xvalues, Asym, r0, lrc), data=data)
xCurve <- seq(0, 27, 1)
yCurve <- coef(fit)[1]+(coef(fit)[2]-coef(fit)[1])*exp(-exp(coef(fit)[3])*xCurve)
plot(yvalues~xvalues)
lines(xCurve, yCurve, col = 'green', lty = 1)
我希望回归线周围有置信线。不幸的是,当我要预测置信区间时,出现了此错误:
xnew<-seq(0,27,1)
pre<-predictNLS(fit, newdata=data.frame(xvalues=xnew), interval = c("confidence"),alpha = 0.05)
predictNLS: Propagating predictor value #1...
Error in if (df != as.integer(df)) stop("Rejection sampling currenly works only for integer degrees of freedom. Consider using algorithm='gibbs'.") :
missing value where TRUE/FALSE needed
我也使用pre<-predictNLS(fit, newdata=data.frame(xvalues=xnew), interval = c("confidence"),alpha = 0.05,algorithm='gibbs')
进行了尝试,但是遇到了同样的错误。如何解决此问题?