"Alejandro Luis Collantes Chávez-Costa"
2007-Sep-27 17:44 UTC
[R] Post-hoc after Anova() car package using linear.hypothesis() in a Repeated Measure Analysis
R masters: I need your help to figure out how can I perform Post-hoc test after ?Anova()? ?car package? using ?linear.hypothesis()? in a Repeated Measure Analysis. I performed a Repeated Measures Analysis to test the effect of Category, Season and their Interaction on some ecological properties using ?Anova()? from ?car package?. I find some significant effect and now I would like to know where the differences are. In order to perform these Within, Between and within-between post hoc?s Professor John Fox recommend me to use ?linear.hypothesis()? and a Bonferonni adjustment of the p-values. After a couple of weeks of work, I can not figure out how to do that. I am very sorry, I did my best but I am not statistician and I can not find examples to understand how can I use linear.hypothesis() in post hoc test. There are someone who can help me? P.D. (I am very thankful to Professor Richard Heiberger who give me advices about the use of ?glht.mmc()? with the ?calpha? argument). For those who can help me, I am posting some extra information about my case and my attempts: The experiment design was as follow: 1 between subjects (fixed factor with 3 levels) and 1 within subjects (fixed factor with 3 levels). Between subjects are nine plots grouped into 3 age category (tree plot for each age category ?T?, ?I?, ?M?), and Within category are 3 season of the year "llu?, ?nor?, ?sec" (equidistant in the time scale). The data set is: lludiversity nordiversity secdiversity Plot Category Season 1.96601 2.10215 2.17984 07A T llu 1.73697 1.96866 1.99766 10B T llu 1.87122 1.92848 2.2673 10C T llu 2.06851 1.98455 2.43838 15B I llu 2.17905 2.49451 2.25759 15C I llu 2.2572 2.16882 2.58295 17A I llu 1.99913 2.43767 2.29582 60A M llu 2.12738 2.64161 2.5385 60B M llu 2.22421 2.42401 2.5385 60C M llu To test the effect of Category, Season and their Interaction on some ecological properties I use the following code: rm(list=ls(all=TRUE)) library(lattice); library(Matrix); library(car); setwd(?c:/R help/?); diversity.tbl <- read.table("diversity.txt", header=TRUE); Season <- factor(c("Lluvias","Nortes","Secas"), levels=c("Lluvias","Nortes","Secas")); idata.df <- data.frame(Season) # Within ?plot?; Plot <- diversity.tbl[,4]; Category <- factor(diversity.tbl[,5], levels=c("T", "I", "M")) #Between ?plot?; dLluvias <- diversity.tbl[,1]; dNortes <- diversity.tbl[,2]; dSecas <- diversity.tbl[,3]; datalm.df <- data.frame(Plot, Category, dLluvias, dNortes, dSecas); diversitylm.ok <- lm(cbind(dLluvias, dNortes, dSecas) ~ Category, data=datalm.df); diversityav.ok <- Anova(diversitylm.ok, idata=idata.df, type="II", idesign=~Season); summary(diversityav.ok, multivariate=FALSE); diversityav.ok To try perform post hoc test I did: linear.hypothesis(diversitylm.ok, c("(Intercept)=CategoryM"), idata=idata.df, idesign=~Season, iterms="Season"); #To contrast Intercept (Category T) and Category M Alejandro Collantes Ch?vez-Costa Universidad de Quintana Roo, Unidad Cozumel http://www.cozumel.uqroo.mx
John Fox
2007-Sep-27 18:40 UTC
[R] Post-hoc after Anova() car package using linear.hypothesis() in a Repeated Measure Analysis
Dear Alejandro, If I understand correctly what you want (that is, pairwise multivariate tests among the groups), you could do the following tests (some output suppressed):> linear.hypothesis(diversitylm.ok, c("(Intercept)=CategoryM"),+ idata=idata.df, idesign=~Season, iterms="Season") Response transformation matrix: Season1 Season2 dLluvias 1 0 dNortes 0 1 dSecas -1 -1 Sum of squares and products for the hypothesis: Season1 Season2 Season1 0.03447365 0.04897023 Season2 0.04897023 0.06956279 Sum of squares and products for error: Season1 Season2 Season1 0.07481798 0.1463547 Season2 0.14635470 0.3945622 Multivariate Tests: Df test stat approx F num Df den Df Pr(>F) Pillai 1 0.3557184 1.3802911 2 5 0.33319 Wilks 1 0.6442816 1.3802911 2 5 0.33319 Hotelling-Lawley 1 0.5521164 1.3802911 2 5 0.33319 Roy 1 0.5521164 1.3802911 2 5 0.33319> linear.hypothesis(diversitylm.ok, c("(Intercept)=CategoryI"),+ idata=idata.df, idesign=~Season, iterms="Season") . . . Multivariate Tests: Df test stat approx F num Df den Df Pr(>F) Pillai 1 0.712033 6.181560 2 5 0.044500 * . . .> linear.hypothesis(diversitylm.ok, c("CategoryI=CategoryM"),+ idata=idata.df, idesign=~Season, iterms="Season") . . . Multivariate Tests: Df test stat approx F num Df den Df Pr(>F) Pillai 1 0.716616 6.321937 2 5 0.04275 * . . . The Bonferroni adjustment is to multiply each p-value by 3 (the number of tests); it should be conservative in this context, and so there should be better approaches for multivariate pairwise comparisons. Regards, John -------------------------------- John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox --------------------------------> -----Original Message----- > From: r-help-bounces at r-project.org > [mailto:r-help-bounces at r-project.org] On Behalf Of "Alejandro > Luis Collantes Ch?vez-Costa" > Sent: Thursday, September 27, 2007 1:45 PM > To: r-help at r-project.org > Subject: [R] Post-hoc after Anova() car package using > linear.hypothesis() in a Repeated Measure Analysis > > R masters: > > I need your help to figure out how can I perform Post-hoc > test after ?Anova()? ?car package? using > ?linear.hypothesis()? in a Repeated Measure Analysis. > > I performed a Repeated Measures Analysis to test the effect > of Category, Season and their Interaction on some ecological > properties using ?Anova()? from ?car package?. > I find some significant effect and now I would like to know > where the differences are. In order to perform these Within, > Between and within-between post hoc?s Professor John Fox > recommend me to use ?linear.hypothesis()? and a Bonferonni > adjustment of the p-values. > > After a couple of weeks of work, I can not figure out how to > do that. I am very sorry, I did my best but I am not > statistician and I can not find examples to understand how > can I use linear.hypothesis() in post hoc test. > > There are someone who can help me? > > P.D. (I am very thankful to Professor Richard Heiberger who > give me advices about the use of ?glht.mmc()? with the > ?calpha? argument). > > > For those who can help me, I am posting some extra > information about my case and my attempts: > > The experiment design was as follow: 1 between subjects > (fixed factor with 3 levels) and 1 within subjects (fixed > factor with 3 levels). Between subjects are nine plots > grouped into 3 age category (tree plot for each age category > ?T?, ?I?, ?M?), and Within category are 3 season of the year > "llu?, ?nor?, ?sec" (equidistant in the time scale). The data set is: > > lludiversity nordiversity secdiversity Plot > Category Season > 1.96601 2.10215 2.17984 07A T llu > 1.73697 1.96866 1.99766 10B T llu > 1.87122 1.92848 2.2673 10C T llu > 2.06851 1.98455 2.43838 15B I llu > 2.17905 2.49451 2.25759 15C I llu > 2.2572 2.16882 2.58295 17A I llu > 1.99913 2.43767 2.29582 60A M llu > 2.12738 2.64161 2.5385 60B M llu > 2.22421 2.42401 2.5385 60C M llu > > To test the effect of Category, Season and their Interaction > on some ecological properties I use the following code: > > rm(list=ls(all=TRUE)) > library(lattice); > library(Matrix); > library(car); > setwd(?c:/R help/?); > diversity.tbl <- read.table("diversity.txt", header=TRUE); > Season <- factor(c("Lluvias","Nortes","Secas"), > levels=c("Lluvias","Nortes","Secas")); > idata.df <- data.frame(Season) # Within ?plot?; Plot <- > diversity.tbl[,4]; Category <- factor(diversity.tbl[,5], > levels=c("T", "I", "M")) #Between ?plot?; dLluvias <- > diversity.tbl[,1]; dNortes <- diversity.tbl[,2]; dSecas <- > diversity.tbl[,3]; datalm.df <- data.frame(Plot, Category, > dLluvias, dNortes, dSecas); diversitylm.ok <- > lm(cbind(dLluvias, dNortes, dSecas) ~ Category, > data=datalm.df); diversityav.ok <- Anova(diversitylm.ok, > idata=idata.df, type="II", idesign=~Season); > summary(diversityav.ok, multivariate=FALSE); diversityav.ok > > To try perform post hoc test I did: > linear.hypothesis(diversitylm.ok, c("(Intercept)=CategoryM"), > idata=idata.df, idesign=~Season, iterms="Season"); #To > contrast Intercept (Category T) and Category M > > > Alejandro Collantes Ch?vez-Costa > Universidad de Quintana Roo, Unidad Cozumel > > http://www.cozumel.uqroo.mx >