Skip to content
Prev 139929 / 398502 Next

[PS] Two Way ANOVA

On 20/03/2008, at 12:54 PM, David Mackovjak wrote:

            
(1) Assign to ``yield'' the foregoing 24 values.

(2) Set up a factor ``nitro'' giving the corresponding levels of  
nitrogen
     (e.g. with labels ``n0'' and ``n20'' --- rather than ``1'' and  
``2'' to
     be more evocative and to make it clear that the value of  
``nitro'' are
     ***not*** numeric!).

(3) Likewise set up a factor ``sulfur'' with labels, say ``s0'',  
``s3'', ``s6'', ``s9''.

     Note that yield is a numeric vector of length 24, nitro and  
sulfur are
     factors (with 2 and 4 levels respectively) also (of course!) of  
length 24.

(4) Fit your linear model:

	fit <- lm(yield ~ nitro*sulfur)

(5) Do your analysis of variance:

	anova(fit)

(6) Check that the anova assumptions seem to be OK:

	plot(fitted(fit),resid(fit)) # Looks pretty good to me.

(7) An interaction plot might be illuminating:

	interaction.plot(sulfur,nitro,yield) # The (n20,s3) cell sticks out  
like a sore toe.


Since there *is* interaction you might want to treat the modelling  
exercise as a one-way
anova on an 8-level factor (one level for each cell).  You can create  
the appropriate
factor using ``interaction()''.  You could fit the one-way model (use  
aov() this time;
TukeyHSD demands it!) and then do TukeyHSD() to the result to find  
out what really
differs from what.

		cheers,

			Rolf Turner

######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}