score1 <- c(5,2,6,1,3,4,5,1,4,3,6,2,6,2,1,3,4,5,5,1,2,3,6,4,4,3,2,5,1,6,5,6,3,2,4,1)
score2 <- c(4,8,3,10,6,5,6,10,7,8,5,9,2,9,10,7,6,4,4,9,8,5,3,5,8,9,9,7,10,6,6,6,8,9,7,10)
person <- as.factor(c(rep(1,6),rep(2,6),rep(3,6),rep(4,6),rep(5,6), rep(6,6)))
wine <- as.factor(c(rep(1:6),rep(1:6),rep(1:6),rep(1:6),rep(1:6),rep(1:6)))
price <- c("low","high","high","low","low","low",
"low","high","high","low","low","low",
"low","high","high","low","low","low",
"low","high","high","low","low","low",
"low","high","high","low","low","low",
"low","high","high","low","low","low")
table <- data.frame(wine,score2,person,price)
table
## wine score2 person price
## 1 1 4 1 low
## 2 2 8 1 high
## 3 3 3 1 high
## 4 4 10 1 low
## 5 5 6 1 low
## 6 6 5 1 low
## 7 1 6 2 low
## 8 2 10 2 high
## 9 3 7 2 high
## 10 4 8 2 low
## 11 5 5 2 low
## 12 6 9 2 low
## 13 1 2 3 low
## 14 2 9 3 high
## 15 3 10 3 high
## 16 4 7 3 low
## 17 5 6 3 low
## 18 6 4 3 low
## 19 1 4 4 low
## 20 2 9 4 high
## 21 3 8 4 high
## 22 4 5 4 low
## 23 5 3 4 low
## 24 6 5 4 low
## 25 1 8 5 low
## 26 2 9 5 high
## 27 3 9 5 high
## 28 4 7 5 low
## 29 5 10 5 low
## 30 6 6 5 low
## 31 1 6 6 low
## 32 2 6 6 high
## 33 3 8 6 high
## 34 4 9 6 low
## 35 5 7 6 low
## 36 6 10 6 low
#Using the Ranks
aov1 <- aov(score1~price+person+wine, data=table)
summary(aov1)
## Df Sum Sq Mean Sq F value Pr(>F)
## price 1 10.13 10.125 3.177 0.0868 .
## person 5 0.00 0.000 0.000 1.0000
## wine 4 15.21 3.802 1.193 0.3382
## Residuals 25 79.67 3.187
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(aov1)




#Using the Scores out of 10
aov2 <- aov(score2~price+person+wine, data=table)
summary(aov2)
## Df Sum Sq Mean Sq F value Pr(>F)
## price 1 22.22 22.222 5.476 0.0276 *
## person 5 31.22 6.244 1.539 0.2138
## wine 4 24.67 6.167 1.520 0.2268
## Residuals 25 101.44 4.058
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Transformation
library(car)
## Loading required package: carData
scatterplot(table$price, table$score2)

## [1] "3"
library(car)
summary(powerTransform(score2~price+person+wine, data=table))
## bcPower Transformation to Normality
## Est Power Rounded Pwr Wald Lwr Bnd Wald Upr Bnd
## Y1 1.0224 1 0.2137 1.8311
##
## Likelihood ratio test that transformation parameter is equal to 0
## (log transformation)
## LRT df pval
## LR test, lambda = (0) 7.313947 1 0.0068421
##
## Likelihood ratio test that no transformation is needed
## LRT df pval
## LR test, lambda = (1) 0.002955863 1 0.95664
aov2 <- aov(score2**2~price+person+wine, data=table)
summary(aov2)
## Df Sum Sq Mean Sq F value Pr(>F)
## price 1 4080 4080 5.300 0.0299 *
## person 5 4585 917 1.191 0.3418
## wine 4 3748 937 1.217 0.3285
## Residuals 25 19244 770
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(aov2)



