



Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!




attach(InsectSprays) data(InsectSprays) str(InsectSprays) 'data.frame': 72 obs. of 2 variables: $ count: num 10 7 20 14 14 12 10 23 17 20 ... $ spray: Factor w/ 6 levels "A","B","C","D",..: 1 1 1 1 1 1 1 1 1 1 ...
tapply(count, spray, mean) A B C D E F 14.500000 15.333333 2.083333 4.916667 3.500000 16.
tapply(count, spray, var) A B C D E F 22.272727 18.242424 3.901515 6.265152 3.000000 38.
tapply(count, spray, length) A B C D E F 12 12 12 12 12 12
boxplot(count ~ spray)
is.factor(spray) [1] TRUE
oneway.test(count~spray) One-way analysis of means (not assuming equal variances) data: count and spray F = 36.0654, num df = 5.000, denom df = 30.043, p-value = 7.999e-
aov.out = aov(count ~ spray, data=InsectSprays) summary(aov.out)
bartlett.test(count ~ spray, data=InsectSprays) Bartlett test of homogeneity of variances data: count by spray Bartlett's K-squared = 25.9598, df = 5, p-value = 9.085e-
plot(aov.out) # the aov command prepares the data for these plots
data: weight by group Bartlett's K-squared = 2.8786, df = 2, p-value = 0.
lm.out = with(PlantGrowth, lm(weight ~ group)) summary(lm.out) # the default summary display will be the linear regression
Call: lm(formula = weight ~ group)
Residuals: Min 1Q Median 3Q Max -1.0710 -0.4180 -0.0060 0.2627 1.
Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 5.0320 0.1971 25.527 <2e-16 *** grouptrt1 -0.3710 0.2788 -1.331 0. grouptrt2 0.4940 0.2788 1.772 0..
Signif. codes: 0 ‘’ 0.001 ‘’ 0.01 ‘’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.6234 on 27 degrees of freedom Multiple R-squared: 0.2641, Adjusted R-squared: 0. F-statistic: 4.846 on 2 and 27 DF, p-value: 0.
summary.aov(lm.out) # we can ask for the corresponding ANOVA table
Df Sum Sq Mean Sq F value Pr(>F) group 2 3.766 1.8832 4.846 0. Residuals 27 10.492 0.
TukeyHSD(results) Tukey multiple comparisons of means 95% family-wise confidence level
Fit: aov(formula = weight ~ group)
$group diff lwr upr p adj trt1-ctrl -0.371 -1.0622161 0.3202161 0. trt2-ctrl 0.494 -0.1972161 1.1852161 0. trt2-trt1 0.865 0.1737839 1.5562161 0.