
217Regression
> light.nls <- nls(Light ~ y0*exp(-k*Depth), start=list(k=1.1,
y0=66))
> light.nls
Nonlinear regression model
model: Light ~ y0 * exp(-k * Depth)
data: parent.frame()
k y0
1.082 67.800
residual sum-of-squares: 21.31
Number of iterations to convergence: 3
Achieved convergence tolerance: 5.265e-06
>
We now have a residual sum of squares of 21.31. This is less than 104 obtained by transformation.
The standard error and correlation coefcient of tted values are calculated using
> yn.est <- fitted(light.nls)
> SSEn <- sum( (Light - yn.est)ˆ2)
> Se.n <- sqrt(SSEn/(length(yn.est)-2) ); Se.n
[1] 0.9842852
> r.n <- cor(Light, yn.est); r.n