问题描述
我正在R中运行NLS模型。残差是正态分布的,但残差的平均值不为零。这怎么可能?
x <- data.frame( height= c(185,194,166,187,181,177),weight=c(77,67,79,87,65,64),age=c(76,89,76,43,56,54))
model <- nls(height ~ a*weight + age*c,data=x,start= list(a=0,c=0))
residuals <- x$height - predict(model,x)
sum(residuals)
解决方法
它是截距...。我想你需要一个截距才能使代数正常工作...