InfluentialPoints.com
Biology, images, analysis, design...
Use/Abuse Principles How To Related
"It has long been an axiom of mine that the little things are infinitely the most important" (Sherlock Holmes)

Search this site

 

 

One-way fixed effects analysis of variance - using R

One-way fixed effects analysis of variance


Gives something like this:

> vetjoh=read.table('vetjoh.txt') > #Now fit the model > joh=lm(log(con)~trt,vetjoh) > #Obtain the ANOVA table > anova.lm(joh)Analysis of Variance Table Response: log(con) Df Sum Sq Mean Sq F value Pr(>F) trt 2 2.3428 1.1714 7.3126 0.001329 ** Residuals 68 10.8929 0.1602 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > #Obtain coefficients > summary(joh) Call: lm(formula = log(con) ~ trt, data = vetjoh) Residuals: Min 1Q Median 3Q Max -1.51066 -0.20532 0.03064 0.25498 0.92298 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.83748 0.08005 47.940 < 2e-16 *** trtB -0.24616 0.12007 -2.050 0.044207 * trtC -0.42770 0.11211 -3.815 0.000296 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.4002 on 68 degrees of freedom Multiple R-Squared: 0.177, Adjusted R-squared: 0.1528 F-statistic: 7.313 on 2 and 68 DF, p-value: 0.001329 > #fit the model without the intercept term > #IMPORTANT! Ignore P-values for this model; > #we are only running it to obtain the full > #set of group means and standard errors > joh1=lm(log(con)~trt-1,vetjoh) > summary(joh1) Call: lm(formula = log(con) ~ trt - 1, data = vetjoh) Residuals: Min 1Q Median 3Q Max -1.51066 -0.20532 0.03064 0.25498 0.92298 Coefficients: Estimate Std. Error t value Pr(>|t|) trtA 3.83748 0.08005 47.94 <2e-16 *** trtB 3.59132 0.08950 40.13 <2e-16 *** trtC 3.40978 0.07849 43.44 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.4002 on 68 degrees of freedom Multiple R-Squared: 0.9884, Adjusted R-squared: 0.9879 F-statistic: 1932 on 3 and 68 DF, p-value: < 2.2e-16