UW-Madison PSYCH 610 - Three-way Between Groups Designs, Balanced-N

Unformatted text preview:

610 – R6 Three-way Between Groups Designs, Balanced-NWritten by Colleen F. Moore, University of Wisconsin-Madison, Psychology DeptFor Psychology 610This uses the example on Table 21.1,p. 466 of Keppel & Wickens.It also uses two packages that you need to install, sciplot, and gplots. gplots requires thatyou install two or three other packages. All these add-ons are small, so don't worry. Seebelow for instructions on installing these.Contents of this handout:Section I: the overall anova and graphs, including how to plot multiple graphs onone pageSection II: simple interactionsSection III: Tukey pair-wise tests for main effect means and cell meansI. Overall anovaI A. Prepare data and bring into R.> your.data=read.table(pipe("pbpaste"),header=T) # paste from the clipboard> your.data Feedback WordType Grade numrecall1 1 1 5 72 1 1 5 73 1 1 5 94 1 1 5 105 1 1 5 96 1 2 5 77 1 2 5 88 1 2 5 99 1 2 5 1010 1 2 5 1011 1 3 5 7...83 3 2 12 684 3 2 12 985 3 2 12 986 3 3 12 687 3 3 12 588 3 3 12 789 3 3 12 890 3 3 12 9> attach(your.data)> F=factor(Feedback) # make factors of the numerical codes> W=factor(WordType)> G=factor(Grade)I B. Do the anovaPsychology 610 R Three-way factorial balanced between-SProf Colleen F. Moore2> threeway.aov=aov(numrecall~F*W*G) # specify full model with all main effects andinteractions by ‘F*W*G’> summary(threeway.aov,intercept=T) Df Sum Sq Mean Sq F value Pr(>F)(Intercept) 1 5198.4 5198.4 2752.0941 < 2.2e-16 ***F 2 26.9 13.4 7.1118 0.001519 **W 2 64.9 32.4 17.1706 7.993e-07 ***G 1 14.4 14.4 7.6235 0.007304 **F:W 4 14.7 3.7 1.9412 0.112829F:G 2 8.6 4.3 2.2765 0.109987W:G 2 16.2 8.1 4.2882 0.017397 *F:W:G 4 10.0 2.5 1.3235 0.269461Residuals 72 136.0 1.9---Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1# We have significant main effects of Feedback, Wordtype and Grade, and an interactionof WordType x Grade.I C. Check that the design is balanced:>newdata=data.frame(numrecall,F,W,G) # I make a new data frame with just the factorsand dv because I have those numerical variables in the original data.> !is.list(replications(numrecall~F*W*G, data=newdata))[1] TRUEI D. Make the qq-normal plot and examine:> qqnorm(numrecall)> qqline(numrecall)Psychology 610 R Three-way factorial balanced between-SProf Colleen F. Moore3The data deviate from the line quite a bit. Some kind of transformation is probablyneeded to make the data closer to normal. I am surprised to see this in Keppel’s example.But we’ll go ahead with the data as they are.E. Find means and se’s> model.tables(threeway.aov,"means",se=T) # tables of means and se’sTables of meansGrand mean7.6 FF 1 2 38.367 7.300 7.133 WW 1 2 38.167 8.233 6.400 GG 5 12Psychology 610 R Three-way factorial balanced between-SProf Colleen F. Moore47.2 8.0 F:W WF 1 2 3 1 8.4 8.8 7.9 2 7.9 8.1 5.9 3 8.2 7.8 5.4 F:G GF 5 12 1 8.400 8.333 2 6.733 7.867 3 6.467 7.800 W:G GW 5 12 1 8.067 8.267 2 8.133 8.333 3 5.400 7.400 F:W:G, , G = 5 WF 1 2 3 1 8.4 8.8 8.0 2 7.8 8.0 4.4 3 8.0 7.6 3.8, , G = 12 WF 1 2 3 1 8.4 8.8 7.8 2 8.0 8.2 7.4 3 8.4 8.0 7.0Standard errors for differences of means F W G F:W F:G W:G F:W:G 0.3549 0.3549 0.2897 0.6146 0.5018 0.5018 0.8692replic. 30 30 45 10 15 15 5I E. Graph main effects:> plot.design(numrecall~F*W*G,data="your.data",main="Keppel Table 21.1 MainEffects Plot") # the numbers on each vertical line indicate the position of the mean forthe different levels of each factor.Psychology 610 R Three-way factorial balanced between-SProf Colleen F. Moore5Another option for graphing main effects:> library(gplots) # first, install gplots and gtools and gdata, then you onlyneed to say ‘library’ for gplots itself. I kept adding packages until ‘gplots’came into the library without a message about another package.> plotmeans(numrecall~F,xlab="Feedback",ylab="numrecall", p=.68,ylim=c(6.0,9.0),main="Keppel Table 21.1",barcol="black") # this plots a linegraph with error bars. After seeing the main effect plot above, I set ‘ylim’ tovalues that I thought would work for all 3 main effect graphs.Psychology 610 R Three-way factorial balanced between-SProf Colleen F. Moore6The error bars are done separately for each level of Feedback so these are likely based onthe overall sd’s rather than using MSerror. I prefer the model-based se’s given by the‘model.tables’ statement above.Or plot box-n-whiskers for all 3 main effects on one page:> par(mfrow=c(2, 2), cex=0.6, mar=c(4, 4, 4, 2), mex=0.8) # ‘mfrow’ partitions the plotwindow into 2 rows and 2 columns. ‘mar’ sets the margins.> plot(numrecall~W*G*F,main="Keppel Table 21.1", xlab=NULL, ylab="numberrecalled") # box’n’whiskers is default for ‘plot’ when factors are specified.Psychology 610 R Three-way factorial balanced between-SProf Colleen F. Moore7Plot all three two-way interactions on one page. You need to repeat the ‘par’ statementafter you close a graph.> library(sciplot) # bring sciplot package into environment> par(mfrow=c(2, 2), cex=0.6, mar=c(4, 4, 4, 2), mex=0.8) # set up to make up to 4graphs on one page, in a 2x2 arrangement> lineplot.CI(F, numrecall, group=G , type="b", legend=TRUE, trace.label="Grade",leg.lab=NULL, fixed=FALSE, x.leg=NULL, y.leg=NULL, cex.leg=1, ncol=1,xlab="Feedback",ylab="mean recall", pch=c(16, 21, 15, 22, 17, 24, c(3:14)),xlim=NULL, ylim=NULL, cex=NULL, lwd=NULL, col="black", cex.axis=1, xaxt="s",data=NULL, subset=NULL,


View Full Document
Download Three-way Between Groups Designs, Balanced-N
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Three-way Between Groups Designs, Balanced-N and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Three-way Between Groups Designs, Balanced-N 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?