Sameer Mathur
Analysis of Variance
carSeats.df <- read.csv(paste("CarSeatsDataV5.csv", sep=""))
attach(carSeats.df)
dim(carSeats.df)
[1] 400 13
# group sample size
table(ShelveLoc)
ShelveLoc
0-Bad 1-Medium 2-Good
96 219 85
Group means
# group means
meanProfit <- aggregate(Profit, by=list(ShelveLoc), FUN=mean)
colnames(meanProfit) <- c("Shelve Location","Average Profit")
meanProfit
Shelve Location Average Profit
1 0-Bad 120.0414
2 1-Medium 163.3505
3 2-Good 232.5998
Group standard deviation
# group standard deviation
sdProfit <- aggregate(Profit, by=list(ShelveLoc), FUN=sd)
colnames(sdProfit) <- c("Shelve Location","SD")
sdProfit
Shelve Location SD
1 0-Bad 44.96228
2 1-Medium 46.91608
3 2-Good 49.90406
boxplot(Profit ~ ShelveLoc, data=carSeats.df, main="Sales broken down by ShelfLoc", xlab="Shelf Location", ylab="Sales ('000 units sold)")
Test for group diffrences
fit <- aov(Profit ~ ShelveLoc)
summary(fit)
Df Sum Sq Mean Sq F value Pr(>F)
ShelveLoc 2 580210 290105 130.7 <2e-16 ***
Residuals 397 881091 2219
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Test for group diffrences
fit <- aov(Profit ~ ShelveLoc + Advertising)
summary(fit)
Df Sum Sq Mean Sq F value Pr(>F)
ShelveLoc 2 580210 290105 153.33 < 2e-16 ***
Advertising 1 131834 131834 69.68 1.18e-15 ***
Residuals 396 749257 1892
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1