## anova test, bohrnstedt-knoke, pagina 122
J <- 4
sud <- c(7.56, 6.57, 5.71, 5.42, 5.38, 4.96, 4.89, 4.83, 4.32, 4.11, 3.92, 3.78, 3.58, 3.27, 2.95, 2.23)
sum(sud)
ms <- mean(sud)
sd(sud)
ns <- length(sud)
ovest <- c(6.92, 6.90, 6.73, 6.68, 6.54, 6.53, 6.52, 5.82, 5.31, 5.20, 4.33, 4.01, 3.86)
sum(ovest)
mo <- mean(ovest)
sd(ovest)
no <- length(ovest)
nord <- c(5.56, 5.42, 5.1, 4.72, 4.71, 3.87, 3.67, 3.23, 2.99)
sum(nord)
mn <- mean(nord)
sd(nord)
nn <- length(nord)
est <- c(6.36, 5.27, 4.65, 4.35, 4.26, 4.16, 4.13, 3.98, 3.94, 3.78, 2.98, 2.69)
sum(est)
me <- mean(est)
sd(est)
ne <- length(est)
tutto <- c(sud, ovest, nord, est)
ybar <- mean (tutto)
N <- length (tutto)
sy <- sd(tutto)
sqintra <- sum ( c( (sud-ms)^2 , (ovest-mo)^2 , (nord-mn)^2 , (est-me)^2 ) )
sqinter <- (ns*(ms-ybar)^2 + no*(mo-ybar)^2 + nn*(mn-ybar)^2 + ne*(me-ybar)^2 )
sqtotale <- sqintra + sqinter
qminter <- sqinter / ( J - 1 )
qmintra <- sqintra / ( N - J )
consuntF <- qminter/qmintra
quantF <- qf(0.99, J-1, N-J)
consuntF > quantF
riga <- c("SQ","gl", "QM", "F")
colonna <- c("Fra i gruppi", "Nei gruppi", "Totale")
tav <- as.table(matrix( c(sqinter, sqintra, sqtotale, J-1, N-J, N-1,
qminter, qmintra, "_", consuntF,"_","_"), 3,4, dimnames =
list( colonna,riga)))
tav