0

I am running a NLS model in R. The residuals are normally distributed, but the mean of the residuals are not zero. How is this possible?

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)

1 Answers1

2

Its the intercept .... i think u need an intercept to get the algebra to work properly...

  • Why are you using `nls`? Your model is currently the same as `lm(height ~ weight + age + 0, data = x)`, and if you remove the `0` this will include the intercept. – Allan Cameron Sep 03 '20 at 10:27
  • Its an example.. in my model i need control some of the estimators...(lm gives completly meaningless results) – Soren Christensen Sep 03 '20 at 10:30