Thank you all for your help. Daniel,
I want to know if I really understand your answer. I calculated each group mean and sub mean as below: > tapply(val,group,mean) group1 group2 group3 4.215670 5.664411 7.210819 > tapply(val,sub,mean) a b c d 4.856927 5.199305 6.183979 6.547655 and intercept (group=1 and sub=a) is: 3.506216 (see original post table) average difference between group2 and group1 is: 5.664411 - 4.215670=1.448741 average difference between sub b and sub a is: 5.199305-4.856972=0.342333 therefore, if I understand this right, the reference level for interaction between sub=b and group=2 should be the sum of the above numbers, which is: 3.506216+1.448741+0.342333=5.29729 Am I right? Thank you vey much. On Fri, Aug 28, 2009 at 7:02 PM, Daniel Malter <dan...@umd.edu> wrote: > The intercept is group=1, sub=a, > > The interaction between sub=b and group=2 implies that both sub=b and > group=2 direct effects are included. That is, with the direct effects only > you are now at: intercept+group2+subb, which means the intercept (group1 > and > sub=a) + the average difference between group=2 and group=1 + the average > difference between sub=b and sub=a. This is the reference level for the > interaction effect between group=2 and sub=b. This is not one-specific > group > in your experiment but rather a generic average group (average group=2, > average sub=b). Your interaction effect now asks the question how much does > group=2 with sub=b stand out from the average in its group and in its sub. > > To clarify your confusion, you may want to write out the model formula. > > Daniel > > ------------------------- > cuncta stricte discussurus > ------------------------- > > -----Ursprüngliche Nachricht----- > Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im > Auftrag von zrl > Gesendet: Friday, August 28, 2009 6:49 PM > An: r-help > Betreff: [R] how to explain the interaction terms regarding > "treatmentcontrast" of lm model > > Dear list, > > I am confused on how to explain the interaction term in the context of > "treatment contrast". > > for example, I have an data frame as below: > sub group val > 1 a group1 3.685625 > 2 a group1 3.407445 > 3 a group1 4.040920 > 4 a group1 2.890875 > 5 b group1 3.853280 > 6 b group1 4.113585 > 7 b group1 3.043250 > 8 b group1 3.800920 > 9 c group1 5.394305 > 10 c group1 5.004290 > 11 c group1 4.651435 > 12 c group1 4.286650 > 13 d group1 4.773440 > 14 d group1 3.982200 > 15 d group1 5.718690 > 16 d group1 4.803815 > ..... > 45 d group3 8.021240 > 46 d group3 7.641685 > 47 d group3 7.519445 > 48 d group3 9.514580 > > then: > > >tapply(val,list(group,sub),mean) > a b c d > group1 3.506216 3.702759 4.834170 4.819536 > group2 4.831503 5.246833 5.930116 6.649191 > group3 6.233062 6.648325 7.787651 8.174238 > > > summary(lm(val~group*sub)) > > Call: > lm(formula = val ~ group * sub) > > Residuals: > Min 1Q Median 3Q Max > -1.24378 -0.50184 -0.03726 0.51748 1.34034 > > Coefficients: > Estimate Std. Error t value Pr(>|t|) > (Intercept) 3.5062 0.3278 10.696 9.98e-13 *** > groupgroup2 1.3253 0.4636 2.859 0.00703 ** > groupgroup3 2.7268 0.4636 5.882 9.98e-07 *** > subb 0.1965 0.4636 0.424 0.67411 > subc 1.3280 0.4636 2.865 0.00693 ** > subd 1.3133 0.4636 2.833 0.00751 ** > groupgroup2:subb 0.2188 0.6556 0.334 0.74052 > groupgroup3:subb 0.2187 0.6556 0.334 0.74060 > groupgroup2:subc -0.2293 0.6556 -0.350 0.72851 > groupgroup3:subc 0.2266 0.6556 0.346 0.73158 > groupgroup2:subd 0.5044 0.6556 0.769 0.44671 > groupgroup3:subd 0.6279 0.6556 0.958 0.34460 > --- > Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 > > Residual standard error: 0.6556 on 36 degrees of freedom > Multiple R-squared: 0.8607, Adjusted R-squared: 0.8182 > F-statistic: 20.22 on 11 and 36 DF, p-value: 3.296e-12 > > > My question is: > with "treatment contrast" in R, Coefficients, groupgroup2,groupgroup3, > subb, > subc,subd are the difference from Intercept 3.5062 (reference level for > intercepts). > But what is the reference level for the interaction terms? such as > groupgroup2:subb,groupgroup3:subb,and etc. > > Thanks. > > [[alternative HTML version deleted]] > > > [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.