我收到了这个错误
qr中的错误(.swts * attr(rhs,“gradient”)): dims [product 6]与对象的长度不匹配[81]
我更换了起始值但仍然出错。
这是我的代码:
x=c(30,110)
y=c(0.000760289, 0.000800320, 0.000830345, 0.000840353, 0.000860370,
0.000910414, 0.000990490, 0.001090594, 0.001200721, 0.001350912,
0.001531172, 0.001751533, 0.001961923, 0.002192402, 0.002463031,
0.002793899, 0.003185067, 0.003636604, 0.004148594, 0.004721127,
0.005394524, 0.006168989, 0.007014544, 0.007870894, 0.008758242,
0.009656474, 0.010565620, 0.011485709, 0.012396520, 0.013308162,
0.014271353, 0.015326859, 0.016525802, 0.017889059, 0.019447890,
0.021223636, 0.023145810, 0.025174229, 0.027391752, 0.029645106,
0.032337259, 0.035347424, 0.039375125, 0.043575783, 0.048003973,
0.052926206, 0.058307309, 0.064581189, 0.071947231, 0.080494476,
0.089891885, 0.100671526, 0.111971207, 0.124237571, 0.137975539,
0.153629149, 0.171239194, 0.190712664, 0.212079979, 0.235026373,
0.259457493, 0.282867017, 0.307830359, 0.334773680, 0.364001719,
0.395742526, 0.425596389, 0.458391314, 0.494558651, 0.534657357,
0.579354317, 0.616075034, 0.656680256, 0.701804548, 0.752133146,
0.808558032, 0.872226001, 0.944664487, 1.027837007, 1.124484096,
1.238426232)
a=0.0189
b=0.14328
delta=0.0005
fit = nls(y ~ a*(exp(b*(x+0.5)))*((delta*b)/((delta*b)+(a*(exp(b* (x+0.5))-1))))^(0.5),
start=list(a=a,b=b, delta=delta))
predict(fit)
plot(x,y,col="red", xlab="Usia",ylab=expression(paste(mu)))
lines(x,predict(fit), col="blue")
legend("topleft", c(expression(paste(mu)),"Fit"),col=c("red","blue"),lty=1:1)
如何解决错误?非常感谢帮助。谢谢。