forked from statOmics/PSLS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path08_2_poison2.Rmd
127 lines (84 loc) · 3.74 KB
/
08_2_poison2.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
---
title: "Exercise 8.2: Non-additive linear model on the poison dataset"
author: "Lieven Clement and Jeroen Gilis"
date: "statOmics, Ghent University (https://statomics.github.io)"
---
# The poison dataset
In this experiment, 96 fish (dojofish, goldfish and zebrafish)
were placed separately in a tank with two liters of water and
a certain dose (in mg) of the poison EI-43,064. The resistance
of the fish against the poison was measured as the amount of
minutes the fish survived after being exposed to the poison (`Surv_time`, in
minutes). Additionally, the weight of each fish was measured.
# Goal
Suppose that researchers are ,mainly interested in studying the effect of
poison dose on the survival of fish. They know however that the weight can
also impact the survival and might also change the effect of the poison dose.
In this tutorial session we will focus on Dojofish and we will model the
survival time in function of the dose and the weight of the fish,
**including an interaction between dose and weight.**
Load libraries
```{r, message=FALSE, warning=FALSE}
```
# Import the data
```{r, message=FALSE}
```
# Data tidying
We can see a couple of things in the data that can be improved:
1. Capitalise the fist column name
3. Set the Species column as a factor
4. Change the species factor levels from "0" to Dojofish.
*Hint*: use the `fct_recode` function.
4. In the previous analysis on this dataset
(`Simple linear regression session`), we performed a log-transformation on the
response variable `Surv_time` to meet the normality and homoscedasticity
assumptions of the linear model. Here, we will immediately work with
log-transformed survival times; store these in the new variable `log2Surv_time`
and remove the non-transformed values.
5. Subset the data to only retain **dojofish** (species "0").
```{r}
```
# Data exploration
Prior to the analysis, we should explore our data. To start our data
exploration, we will make use of the `ggpairs` function of the
`GGally` R package. This function will generate a visualization containing
multiple panels, which display (1) univariate plots of the different variables
in our dataset, (2) bivariate plots and (3) correlation coefficients between
the different variables.
```{r}
```
# Analysis with interaction and main effect for weight
## Model specification
$$
y_i=\beta_0+\beta_d x_d + \beta_g x_g +\beta_{d:g} x_d x_g+ \epsilon_i,
$$
Can you interpret the different model parameters?
## Assess model assumptions
## Inference
Use the model to test the parameters of interest.
## Interpretation of model parameters
On the transformed and the original scale.
## Assessing the dose effect
The effect of dose is now parameterized by two model parameters ($\beta_d$
and $\beta_{d:g}$). We first evaluate an *omnibus* hypotheses that there is
no effect of dose, i.e., no main effect nor an interaction effect. We can test
this with an F-test that compares a *full* model (1) containing a main effect
for dose, a main effect for weight and an interaction between dose and weight
with a model (2) that only contains a main effect for weight (i.e. no effect
for dose).
```{r, eval = FALSE}
# we already have made the full model (above)
... # fit model that only contains a main effect for weight (no effect for dose)
... # perform the F-test between the two models
```
## Assessing the interaction between dose and weight
Now, we will test if there is a significant interaction effect between dose
and weight. Since we only have one interaction term in this model, this can
be achieved in several equivalent ways:
1. The `summary` function
2. An F-test comparing models with and without the interaction effect
3. An ANOVA table with type III sum of squares
```{r}
```
## Conclusion
On the transformed and the original scale.