I'm still learning how to use r and I have some trouble making an effect plot based on Tukey posthoc tests. I have a dataset with 3 colonies (A
, B
and C
, see below). Each colony is divided into 2 treatments: control
and DWV
. I have to run a GLM to test wether there is a difference of life expectancy last.scan between the treatment groups for each of the colonies. I have taken 'treatment' as a fixed factor and 'colony' as a random factor.
I used the following code:
fit_life = lmer(last.scan~treatment + (1|colony), data = data)
Anova(fit_life, type = 3)
I also need the 95% confidence limits, but I am not sure if I use the correct command:
confint(lsmeans(fit_life, list(~treatment)), type = "response")
The following command gives me the results of the Tukey posthoc tests for the treatments, but I want a Tukey test that gives me the difference between treatment in each colony. How can I do that?
mcp = glht(fit_life, linfct = mcp(treatment = "Tukey"))
summary(mcp)
# DWV treatment significantly changes life expectancy (z = -9.734, p = < 2e-16)
With the results of the posthoc test, I want to make an effect plot like the one shown here, but I do not know what command to use.
Here is an example of the dataset:
> head(data, 30)
RFID colony treatment last.scan
1 A0 01 03 C0 00 C0 20 01 A Control 24
2 A0 01 03 C0 00 C0 20 0C A Control 21
3 A0 01 03 C0 00 C0 20 1D A Control 19
4 A0 01 03 C0 00 C0 20 1E A Control 18
5 A0 01 03 C0 00 C0 20 1F A Control 31
6 A0 01 03 C0 00 C0 20 21 A Control 19
7 A0 01 03 C0 00 C0 20 2F A Control 18
8 A0 01 03 C0 00 C0 20 37 A Control 16
9 A0 01 03 C0 00 C0 20 5E A Control 23
10 A0 01 03 C0 00 C0 20 79 A Control 19
11 A0 01 03 C0 00 C0 20 7F A Control 17
12 A0 01 03 C0 00 C0 20 8C A Control 24
13 A0 01 03 C0 00 C0 20 92 A Control 26
14 A0 01 03 C0 00 C0 20 95 A Control 19
15 A0 01 03 C0 00 C0 20 98 A Control 21
16 A0 01 03 C0 00 C0 20 B8 A Control 21
17 A0 01 03 C0 00 C0 20 B9 A Control 20
18 A0 01 03 C0 00 C0 20 D5 A Control 17
19 A0 01 03 C0 00 C0 20 D9 A Control 27
20 A0 01 03 C0 00 C0 20 E4 A Control 26
21 A0 01 03 C0 00 C0 20 FE A Control 31
22 A0 01 03 C0 00 C0 3A 02 A DWV 11
23 A0 01 03 C0 00 C0 3A 0C A DWV 22
24 A0 01 03 C0 00 C0 3A 0D A DWV 12
25 A0 01 03 C0 00 C0 3A 11 A DWV 19
26 A0 01 03 C0 00 C0 3A 14 A DWV 21
27 A0 01 03 C0 00 C0 3A 1D A DWV 24
28 A0 01 03 C0 00 C0 3A 24 A DWV 9
29 A0 01 03 C0 00 C0 3A 2A A DWV 16
30 A0 01 03 C0 00 C0 3A 2C A DWV 23