Eduard Szöcs

Data in Environmental Science and Eco(toxico-)logy

# Quantitative Ecotoxicology, Page 85, Example 3.2, Nonlinear Regression

Get the data from here and read it into R:

First we fit a nonlinear Regression without weighting.

So we fit the model

to our data.

In the R formula ZINC corresponds to $C_t$,
INITACT to $C_0$,
KE to $k_{e1}$,
0.00283 is the decay rate constant for 65-Zn $k_{e2}$,
and DAY to $t$.

Were are going to estimate KE and INITACT and also supplied some start-values for the algorithm.

We can look a the summary to get the estimates and standard error:

The resulting estimates of $k_{e1}$ and $C_0$ are $0.00268 \pm 0.00067$ and $465 \pm 20$.

We can investigate the residuals, which show a clear pattern:

Secondly, we run a nonlinear regression with day-squared weighting:

We use day^2 as weights and add there a column to our data:

We run again nls, but now we supply this new column as weights:

The estimates $0.00244 \pm 0.00035$ and $455 \pm 38$ are quite similar to the non-weighted regression.

We could plot the two models and the data:

Finally we can also fit a linear model to the transformed Zinc-Concentrations:

First we ln-transform the concentrations:

We see that the data has now linear trend:

And fit a linear regression:

which is fitting the model $ln(Zn) = a \cdot day + intercept$, with a = -0.0053 and intercept = 6.07

Now plot data and model, as well as the residuals:

The mean square error can be calculated from the summary:

From which we can get an unbiased estimate of $C_0$:

where

extracts the intercept from the summary.

The estimated $k$ in the summary output is $-0.00531 \pm 0.00024$, and $k_e = k - decayrate = 0.00531 - 0.00283 = 0.00248$

This result is similar to the weighted and non weighted nonlinear regression. Again we have the same results as with SAS :) [Small deviations may be due to rounding error]

Code and data are available at my github-repo under file name ‘p85’.

Written on December 1, 2012