---
output: html_document
---

# Exam exercise: Vital capacity

You may use the combined lecture notes for this module available at
<https://asta.math.aau.dk> to guide you to the relevant methods and R commands
for this exam.

In this exercise you will study a dataset concerning vital capacity,
which is the maximal amount of air that can be exhaled after a maximal inhalation.

Read in the data:
```{r}
vitcap <- read.delim("http://asta.math.aau.dk/dan/static/datasets?file=vitcap.txt")
head(vitcap)
```

In the dataset, the variable `vital.capacity` has been measured
on 84 workers in the cadmium industry.

The next variable is the factor `exposure` with 3
levels, indicating the level of cadmium exposure:

 -  A: None
 -  B: Less than 10 years
 -  C: More than 10 years

The data set also contains dummy variables for the factor
`exposure`:

 -  `z1=1` if `exposure=B` and 0 otherwise.
 -  `z2=1` if `exposure=C` and 0 otherwise.

You will use these two variables later on.

Make a model and carry out an analysis investigating the effect of the
factor `exposure` on the response `vital.capacity`. In
that connection you should calculate/interpret the F-test for no effect of `exposure`.

We expand the analysis to include the workers age -
the variable `age` - as a predictor.

Make a model and carry out an analysis investigating the effect of the
predictors `exposure` and `age` on the response
`vital.capacity`. In that connection you should:

- display the summary of each model you fit and be able to  interpret parameter
  estimates, test statistics, p-values etc. in this output.
- investigate whether there is interaction between the effects of
  `exposure` and `age`
- give a graphical interpretation of such an interaction


Consider the following two models, where we introduce the dummy variables.
```{r}
model1 <- lm(vital.capacity ~ age*z2, data = vitcap)
model2 <- lm(vital.capacity ~ age*z1 + age*z2, data = vitcap)
```

- Use an F-test to show that there is no significant difference
  between `model1` and `model2`.
- Give an interpretation of the theoretical difference between the two models.
