Splus for ANOVA

Setting up the Data

blood <- c(62,60,...)
bringing in the data the known way

blood <- scan("BoxHH.data")
bringing in the data from a file

blood <- scan() 62 60 63
bringing in the data from the keyboard

diet <- factor(rep(LETTERS[1:4],c(4,6,6,8)))
making a factor variable (categorical variable) The names are A B C and D.

summary(blood); summary(diet)
Note the different way summary works

blood.df <- data.frame(blood,diet)
Makes a data frame object:

blood.df
matrix like, but with different type of entries

First Look at Data

X11()
Opening the graphic window
plot.design(blood.df)
Dot plot of means of groups

plot.design(blood.df,fun=median)
Dot plot of medians of groups

par(mfrow=c(1,2)); plot.design(blood.df); plot.design(blood.df,fun=median)
Both plots on one page!

par(mfrow=c(1,1))
Back to normal

plot.factor(blood.df)
Simpler than boxplot(split(blood,diet))

The function aov

aov.blood < - aov(blood ~ diet, blood.df)
Does the calculations and stores in a special aov-results object

summary(aov.blood)
The familiar ANOVA table

model.table(aov.blood)
The estimated effects

model.table(aov.blood, type="means")
The estimated means

Diagnostic Plots

hist(resid(aov.blood))
Histogram of residuals

qqnorm(resid(aov.blood))
Normal QQ plot of residuals

plot(fitted(aov.blood),resid(aov.blood))
Residuals vs predicted: checking homogeniety of variance

More on factors

fac <- factor(sex)
creates a factor object

fac
to print the object we created,
note the words are no longer "strings"

s <- summary(fac)
now,
s
dotchart(summary(fac))