[R-sig-ME] Another question about model specification

Martin Eklund martin.eklund at farmbio.uu.se
Tue Mar 4 18:46:52 CET 2008


Hello again,

Thank you very much for the quick reply on my earlier question!  
Unfortunately, I still have problems to fully understand how to  
specify models in lme4. Specifically, how do you specify interactions  
between factors?

Consider the example data below (also attached for convenience).  
'treatment' and 'family' are factors, 'treatment' is fixed and  
'family' is random. Fitting the models

(i)	lmer(weight ~ treatment + (1|family))
(ii)	lmer(weight ~ treatment * (1|family))
(iii)	lmer(weight ~ (treatment + (1|family))^2)
(iv)	lmer(weight ~ treatment : (1|family))

produce exactly the same results. I assume that this is the expected  
behavior, but to me it is a bit confusing. If we pretend that  
'family' is a fixed factor and use lm to fit the models above we get  
different results (or, to be precise, (ii) = (iii) ≠ (i) ≠ (iv)),  
which is the expected behavior to me. So, my question really boils  
down to: if I want to fit the model

weight ~ treatment + (1|family) + (an interaction term between  
treatment and (1|family))

how would I specify that? And in general, how are interactions  
specified?

Thank you!

Best regards,

Martin.

==========
R commands
==========
data <- read.delim(file="/path/to/test.txt", sep="\t", header=TRUE)
data$treatment <- as.factor(data$treatment)
data$family <- as.factor(data$family)
attach(data)
lmer(weight ~ treatment + (1|family))
lmer(weight ~ treatment * (1|family))
lmer(weight ~ (treatment + (1|family))^2)
lmer(weight ~ treatment : (1|family))

===========
Example data
===========
treatment	family	weight
2	1	0.099
3	1	0.099
1	1	0.105
1	1	0.112
1	1	0.113
1	1	0.114
1	1	0.119
3	1	0.121
1	1	0.123
1	1	0.124
3	1	0.130
3	1	0.130
2	1	0.142
2	1	0.143
2	1	0.144
2	1	0.164
2	2	0.086
1	2	0.097
1	2	0.097
1	2	0.105
1	2	0.106
2	2	0.107
1	2	0.109
2	2	0.113
2	2	0.114
1	2	0.114
3	2	0.115
2	2	0.132
3	2	0.141
2	2	0.131



========================================
Martin Eklund
PhD Student
Department of Pharmaceutical Biosciences
Uppsala University, Sweden
Ph: +46-18-4714281
========================================







More information about the R-sig-mixed-models mailing list