Splus for Two-way Analysis

Setting up the Data

fnames <- list(treatment = LETTERS[1:4], poison = c("I", "II", "III"))
creating names for the levels of the two cacorigal variables

poisons.design <- fac.design(c(4, 3), fnames, rep = 4)
setting up the design matrix in the form of 4x3 table repeated 4 times

poisons.df <- data.frame(poisons.design, surv.time)

First Look at Data

X11()
Opening the graphic window
plot.design(poisons.df)
Dot plots of means of groups, for each factor separately, on the same scale

plot.design(poisons.df,fun=median)
same with medians of groups

par(mfrow=c(1,2))
Both plots on one page!

plot.factor(poisons.df)
boxplots, split by each factor separately

attach(poisons.df)
attaches the data frame so we can use the variables directly by name

interaction.plot(treatment, poison, surv.time)
profile plot, treatment on the X axis.

The function aov

aov.poisons < - aov(surv.time ~ treatment + poison, poisons.df)
fits two-way additive model and stores in a special aov-results object

aov.poisons < - aov(surv.time ~ treatment + poison, poisons.df)
same plus interaction. Works also when formula is simply: surv.time ~ treatment* poison, poisons.df)< /i>

summary(aov.blood)
The familiar ANOVA table

model.table(aov.poisons)
The estimated effects

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

Diagnostic Plots

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

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

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

More on formulas

surv.time ~ (treatment + poison)^2
same as befor
surv.time ~ (treatment + poison + stam)^2
for a three-way analysis with all pairwise interactions

surv.time ~ (treatment + poison +stam)^3
for a three-way analysis with all interactions

surv.time ~ treatment*poison*stam
same as above