Mark Na
2009-Jul-30 22:41 UTC
[R] Testing year effect in lm() ***failed first time, sending again
Dear R-helpers, I have a linear model with a year effect (year is coded as a factor), i.e. the parameter estimates for each level of my year variable have significant P values (see some output below) and I am interested in testing: a) the overall effect of year; b) the significance of each year vis-a-vis every other year (the model output only tests each year against the baseline year). I'd appreciate any help with how to perform these post-hoc tests in R. Many thanks, Mark Na Call: lm(formula = data$SR.obs ~ log(data$AREA, 10) + data$YEAR, subset = (data$AREA >= 14.5)) Residuals: Min 1Q Median 3Q Max -5.3412 -1.3140 0.1108 1.1972 4.3126 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -9.4606 0.6144 -15.399 < 2e-16 *** log(data$AREA, 10) 3.9261 0.1734 22.644 < 2e-16 *** data$YEAR2008 1.0750 0.2854 3.767 0.000211 *** data$YEAR2009 1.5884 0.3073 5.169 5.18e-07 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 1.822 on 226 degrees of freedom Multiple R-squared: 0.6945, Adjusted R-squared: 0.6905 F-statistic: 171.3 on 3 and 226 DF, p-value: < 2.2e-16 [1] "AIC= 934.557" [[alternative HTML version deleted]]
Emmanuel Charpentier
2009-Aug-05 16:17 UTC
[R] Testing year effect in lm() ***failed first time, sending again
Le jeudi 30 juillet 2009 ? 16:41 -0600, Mark Na a ?crit :> Dear R-helpers, > > I have a linear model with a year effect (year is coded as a factor), i.e. > the parameter estimates for each level of my year variable have significant > P values (see some output below) and I am interested in testing: > > a) the overall effect of year; > b) the significance of each year vis-a-vis every other year (the model > output only tests each year against the baseline year).install.packges("multcomp") help.start() and use the vignettes ! They're good (and are a good complement to somewhat incomplete help pages : what in h*ll are valid arguments to mcp() beyond "Tukey" ??? Curently, you'll have to dig in the source to learn that...). HTH Emmanuel Charpentier