Eduard Szöcs

Data in Environmental Science and Eco(toxico-)logy

Quantitative Ecotoxicology, Page 94, Example 3.5

Get the data from here and read it into R:

LEAD <- read.table("p94.csv", header = TRUE, sep = ";")
head(LEAD)
##    DAY LEAD
## 1 0.16 41.0
## 2 0.16 31.0
## 3 0.16 25.3
## 4 1.00 30.5
## 5 1.00 22.7
## 6 1.00 22.0

As always we first take a look at the data:

plot(LEAD ~ DAY, LEAD)

plot of chunk p94_raw

A simple power model may fit the data:

We could fit such model as in example 3.3 via Nonlinear Least Squares or we could try to linearize the relationship by a ln-transform of both DAY and LEAD:

LEAD$LLEAD <- log(LEAD$LEAD)
LEAD$LDAY <- log(LEAD$DAY)
plot(LLEAD ~ LDAY, LEAD)

plot of chunk p94_linear

Now we can us lm() to estimate the coefficients and check our model:

# fit model
mod <- lm(LLEAD ~ LDAY, data = LEAD)

The residuals show no pattern:

plot(mod, which = 1)

plot of chunk p94_residuals

From the model-output:

mod_sum <- summary(mod)
mod_sum
## 
## Call:
## lm(formula = LLEAD ~ LDAY, data = LEAD)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.4568 -0.1789  0.0372  0.1689  0.4169 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   3.0008     0.0641   46.80  < 2e-16 ***
## LDAY         -0.2715     0.0313   -8.67  1.5e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
## 
## Residual standard error: 0.238 on 22 degrees of freedom
## Multiple R-squared: 0.773,	Adjusted R-squared: 0.763 
## F-statistic: 75.1 on 1 and 22 DF,  p-value: 1.53e-08

We see that out fitted model hast the formula: with an R-squared of 0.77 and is statistically significant. The standard errors for the two parameters are 0.064 and 0.031.

So our backtransformed model would be:

Finally we can also plot our model:

plot(LLEAD ~ LDAY, LEAD)
abline(mod)

plot of chunk p94_model

Code and data are available at my github-repo under filename ‘p94’.

Written on January 23, 2013