Hi There, Suppose two factors, A and B. A has n levels, B has m levels. Why the degree of freedom of interaction effect of A and B ( here I mean A:B not A*B) is (n-1)*(m-1) not n*m-1? I know this is a basic statistical question. Please recommend some good websites or books. Thank you very much. Fan
genomenet at gmail.com
2007-Mar-15 00:13 UTC
[R] how to understand the interaction of two fixed effects
Hi There, I have two questions about how to understand well about the interaction efffect. 1) Suppose two factors, A and B. A has n levels, B has m levels. Why the degree of freedom of interaction effect of A and B ( here I mean A:B not A*B) is (n-1)*(m-1) not n*m-1? 2) can Lard:Gender be understood as LardGender? Value=c(709,679,699,657,594,677,592,538,476,508,505,539) Lard=rep(c("Fresh","Rancid"),each=6) Gender=rep(c("Male","Male","NONE","NONE","Female","Female"),2) LardGender=rep(c("FreshMale","FreshNONE","FreshFemale","RancidMale","RancidNONE","RancidFemale"),each=2) Food=data.frame(Value,Lard, Gender,LardGender) Why is the following two return outputs of lm() function different?> lm(Value~Lard+Gender+Lard:Gender,data=Food)Call: lm(formula = Value ~ Lard + Gender + Lard:Gender, data = Food) Coefficients: (Intercept) LardRancid GenderMale 635.5 -113.5 58.5 GenderNONE LardRancid:GenderMale LardRancid:GenderNONE 42.5 -15.5 -72.5> lm(Value~Lard+Gender+LardGender,data=Food)Call: lm(formula = Value ~ Lard + Gender + LardGender, data = Food) Coefficients: (Intercept) LardRancid GenderMale 635.5 -113.5 43.0 GenderNONE LardGenderFreshMale LardGenderFreshNONE -30.0 15.5 72.5 LardGenderRancidFemale LardGenderRancidMale LardGenderRancidNONE NA NA NA Thank you very much! Fan