Examp3.1 from Duchateau, L. and Janssen, P. and Rowlands, G. J. (1998).Linear Mixed Models. An Introduction with applications in Veterinary Research. International Livestock Research Institute.

Description

Examp3.1 is.

Author(s)

  1. Muhammad Yaseen (myaseen208@gmail.com)

References

  1. Duchateau, L. and Janssen, P. and Rowlands, G. J. (1998).Linear Mixed Models. An Introduction with applications in Veterinary Research. International Livestock Research Institute.

See Also

ex124

Examples

 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
#-------------------------------------------------------------
## Example 3.1 Model 1 p-80
#-------------------------------------------------------------
# PROC MIXED DATA=ex31;
# CLASS drug dose herd;
# MODEL PCV2=drug dose(drug)/solution ddfm=satterth;
# RANDOM herd(drug);
# ESTIMATE 'Mean Samorin' intercept 1 drug 0 1 dose(drug) 0 0 1;
# ESTIMATE 'Berenil 2 doses' dose(drug) 1 -1 0;
# ESTIMATE 'Ber vs Sam at dose 1' drug 1 -1 dose(drug) 1 0 -1;
# CONTRAST 'Mean Samorin' intercept 1 drug 0 1 dose(drug) 0 0 1;
# CONTRAST 'Berenil dif 2 doses' dose(drug) 1 -1 0;
# CONTRAST 'Ber vs Sam at dose 1' drug 1 -1 dose(drug) 1 0 -l;
# CONTRAST 'some difference' drug 1 -1 dose(drug) 0.5 0.5 -1,
#           drug 0 0 dose(drug) 1 -1 0; 
# LSMEANS dose(drug);
# RUN;
 
 library(lmerTest)
 str(ex31)
 ex31$drug1 <- factor(ex31$drug)
 ex31$dose1 <- factor(ex31$dose)
 ex31$herd1 <- factor(ex31$herd)
 
 fm3.1 <- 
          lmerTest::lmer(
                          formula   = PCV2 ~ drug1 + dose1:drug1 + (1|herd1:drug1)
                        , data      = ex31
                        , REML      = TRUE
                        , contrasts = list(dose1 = "contr.SAS", drug1 = "contr.SAS")
                     )
 summary(fm3.1)
 lmerTest::anova(object = fm3.1, ddf = "Satterthwaite")
 lmerTest::lsmeans(model = fm3.1, test.effs = "dose1:drug1")
 
#-------------------------------------------------------------
## Example 3.1 Model 2 p-84
#-------------------------------------------------------------
# PROC MIXED DATA=ex31;
# CLASS drug dose herd;
# MODEL PCV2=PCV1 drug dose(drug)/solution ddfm=satterth;
# RANDOM herd(drug);
# RUN;
 
 library(lmerTest)
 str(ex31)
 ex31$drug1 <- factor(ex31$drug)
 ex31$dose1 <- factor(ex31$dose)
 ex31$herd1 <- factor(ex31$herd)
 
 fm3.2 <- 
          lmerTest::lmer(
                          formula   = PCV2 ~ PCV1 + drug1 + dose1:drug1 + (1|herd1:drug1)
                        , data      = ex31
                        , REML      = TRUE
                        , contrasts = list(dose1 = "contr.SAS", drug1 = "contr.SAS")
                     )
 summary(fm3.2)
 lmerTest::anova(object = fm3.2, ddf = "Satterthwaite")
 lmerTest::lsmeans(model = fm3.2, test.effs = "herd1:drug1")
 
#-------------------------------------------------------------
## Example 3.1 Model 3 p-86
#-------------------------------------------------------------
# PROC MIXED DATA=ex31;
# CLASS drug dose herd;
# MODEL PCV2=drug dose(drug) PCV1*dose(drug)/solution ddfm=satterth;
# RANDOM herd(drug);
# RUN;
 
 library(lmerTest)
 str(ex31)
 ex31$drug1 <- factor(ex31$drug)
 ex31$dose1 <- factor(ex31$dose)
 ex31$herd1 <- factor(ex31$herd)
 
 fm3.3 <- 
          lmerTest::lmer(
                          formula   = PCV2 ~ drug1 + PCV1*dose1:drug1 + (1|herd1:drug1)
                        , data      = ex31
                        , REML      = TRUE
                        , contrasts = list(dose1 = "contr.SAS", drug1 = "contr.SAS")
                     )
 summary(fm3.3)
 lmerTest::anova(object = fm3.3, ddf = "Satterthwaite")
 lmerTest::lsmeans(model = fm3.3, test.effs = "dose1:drug1")

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.