[R] Posthoc test for 3-way interaction (log-linear model)

Sachi Ito s.ito.tcu at gmail.com
Mon Aug 30 23:16:07 CEST 2010


Hi,

I have analyzed my data using log-linear model  as seen below:


> yes.no <- c("Yes","No")
> tk <- c("On","Off")
> ats <- c("S","V","M")

> L <- gl(2,1,12,yes.no)
> T <- gl(2,2,12,tk)
> A <- gl(3,4,12,ats)
> n <- c(1056,4774,22,283,326,2916,27,360,274,1770,15,226)

> library(MASS)
> l.loglm <- data.frame(A,T,L,n)
> l.loglm

            A        	T   	L    		n
1      S		 On	 Yes 	1056
2      S		 On	  No 	4774
3      S		 Off	 Yes   	22
4      S		 Off	  No  	283
5      V		 On	 Yes 	 326
6      V  		 On   No 		2916
7      V		 Off    Yes   	27
8      V		 Off	  No  	360
9      M    		 On    Yes  	274
10    M  		 On    No 	1770
11    M		 Off    Yes   	15
12 	 M 		 Off    No  	226


Model comparison based on likelihood ratio chi-square statistics revealed that the 3-way interaction (saturated) model was marginally significantly different from the 2-way association model (see below):


> anova(loglm.null,loglm.LA.LT.AT)
LR tests for hierarchical log-linear models

Model 1:
 n ~ T + A + L 
Model 2:
 n ~ L:T + L:A + A:T 

            Deviance df Delta(Dev) Delta(df) P(> Delta(Dev)
Model 1   305.997600  7                                    
Model 2     4.620979  2 301.376622         5        0.00000
Saturated   0.000000  0   4.620979         2        0.09921


Now, I'd like to run a post-hoc test and see which one of the 3 levels of the variable "A" is significantly different from each other (S vs. V vs. M). 

I'd greatly appreciate if anyone can let me know how to run the post-hoc test.

Thank you in advance!



More information about the R-help mailing list