DOC PREVIEW
UW-Madison PSYCH 610 - Unbal Factoria lBetw

This preview shows page 1-2-3-4 out of 13 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

610 R12 Prof Colleen F. MooreAnalysis of variance for Unbalanced Between Groups designs in RFor Psychology 610 University of Wisconsin--MadisonR is very touchy about unbalanced designs, partly because it includes several ways ofcalculating the SS. The Type I method is the default in the ‘aov’ module. Type II andType III sums of squares can be tested using ‘Anova’ (note capital A) in the ‘car’package. Install the ‘car’ package in R, then activate it for your session using the‘library(car)’ command.When using R for unbalanced designs, the contrast coding of your factors isabsolutely critical. I illustrate how dramatically this can alter your results below. Otherprograms are more idiot-proof for unbalanced designs.Contents of this tutorial:I. Bring in data and arrange for analysis. This section includes some datatransformation tricks for recoding variables, and constructing centereddummy codes for main effects and interactions.II. Anova with Type I, Type II and Type III SS’s.III. Same analyses but conducted with multiple regression using the codeslaboriously constructed in Part I.IV. Non-orthogonality of the design illustrated by correlating the main effectcontrast codes across all observations. Shows how to construct acorrelation matrix.Summary of R steps:Step 1) set options for contrasts to ‘sum’ or ‘poly’,Step 2) run anova in ‘aov’,Step 3) use ‘Anova’ (capital A) in the ‘car’ package to extract Type II or Type III SS’sfrom the ‘aov’ run.Summary of R code:> options(contrasts=c("contr.sum","contr.poly")) # set the contrast type R will use as adefault> model = aov(dv ~ A*B*C) # make sure A, B and C are ‘factors’> library(car) # activate the ‘car’ package> Anova(model,type=c("III"))Warnings: 1) Type III SS’s are sensitive to the specific contrasts used. 2) make sure youmake your independent variables into factors.610 R12 Unbalanced Between Group Designs Prof Colleen F. MoorePsychology 610, University of Wisconsin--Madison2An Example in detailAn Unbalanced Between Groups anova is illustrated here with data from a 2(sex ofanimal) x 2(prenatal alcohol exposed or not) x 2(prenatal stress exposed or not). Thedependent variable is fallypride uptake in the striatum, a measure of dopamine systemfunction in that area of the brain.I. Bring in data and set up the grouping variable codes. The original data set had sexcoded as 1 and 2, and the animal’s condition was coded 1=alc only, 2=control, 3=stressonly, and 5=alc+stress. These codes needed to be turned into two separate variables foralcohol and stress. I did this in a very plodding manner to make sure I didn’t makemistakes. Notice that I have entered ‘NaN’ for missing data.> pet1.data=read.table(pipe("pbpaste"),header=T) # I pasted the data to the clipboard> pet1.data ID sex condition fal fmt1 AR54 2 1 12.88000 6.320002 AR56 2 1 14.80000 5.380003 AR58 1 1 11.46000 6.640004 AR61 1 2 13.48800 6.257005 AR66 2 3 17.34000 4.730006 AR67 1 3 12.05000 5.780007 AR69 1 2 10.15000 4.936008 AR70 2 5 18.94000 7.220009 AR71 2 3 16.67000 4.7400010 AR72 1 5 14.39000 5.5500011 AR76 2 2 14.85000 7.5500012 AR77 2 2 9.37000 5.5900013 AR78 2 3 11.91330 5.2051214 AR80 1 2 14.61000 8.3400015 AR82 1 1 12.41000 6.7600016 AR87 1 1 13.92000 5.6300017 AR88 2 3 17.10000 7.3900018 AR89 1 2 11.35000 5.9100019 AR95 2 2 10.53000 5.7800021 AS03 1 2 NaN NaN22 AS06 2 5 23.07000 5.9000024 AS47 1 1 14.49000 4.9600025 AS48 1 5 19.26000 5.2600026 AS51 1 2 15.72000 5.8950029 AS59 1 2 18.73730 4.2806430 AS61 1 1 12.85910 4.3829831 AS62 1 2 11.79000 6.0700032 AS64 1 1 13.72260 4.7909134 AS80 2 1 8.98263 5.3345936 AS89 1 2 14.53000 6.8500037 AT35 1 5 14.69000 5.2500040 AT83 1 3 17.04100 3.7692541 AT85 2 3 19.03000 5.3600042 AT86 1 1 12.04270 4.3908743 AT94 2 5 11.70000 6.5100044 AU03 2 5 18.74000 6.7700045 AU08 2 3 14.09000 4.8900046 AU09 2 5 9.67000 5.9100047 AU11 1 5 15.03000 4.63000610 R12 Unbalanced Between Group Designs Prof Colleen F. MoorePsychology 610, University of Wisconsin--Madison3A. Create codes for the prenatal stress variable, –1 and 1 for no stress and stressexposed. I call it ‘tress’ so it won’t have the first letter ‘s’, and I won’t confuse it with sexof animal.> pet2.data=transform(pet1.data, tress=ifelse(condition > 2, 1,-1)) # the ifelse statementsets the value of the named variable for a whole vector according whether the test inparentheses (condition > 2) is true or false.> pet2.data # I want to see the results before I continueID sex condition fal fmt tress1 AR54 2 1 12.88000 6.32000 -12 AR56 2 1 14.80000 5.38000 -13 AR58 1 1 11.46000 6.64000 -14 AR61 1 2 13.48800 6.25700 -15 AR66 2 3 17.34000 4.73000 16 AR67 1 3 12.05000 5.78000 1. . .44 AU03 2 5 18.74000 6.77000 145 AU08 2 3 14.09000 4.89000 146 AU09 2 5 9.67000 5.91000 147 AU11 1 5 15.03000 4.63000 1B. Create codes for the prenatal alcohol variable, -1 and 1 for no alc and alc exposed.This is trickier because the original conditions aren’t in order. I folded the originalcondition in the middle by subtracting a constant and then taking the absolute value. Thisis a good trick to learn for recoding variables.> pet3.data=transform(pet2.data,alc=ifelse(abs(condition - 3) >= 2,1,-1) )> pet3.data ID sex condition fal fmt tress alc1 AR54 2 1 12.88000 6.32000 -1 12 AR56 2 1 14.80000 5.38000 -1 13 AR58 1 1 11.46000 6.64000 -1 14 AR61 1 2 13.48800 6.25700 -1 -15 AR66 2 3 17.34000 4.73000 1 -16 AR67 1 3 12.05000 5.78000 1 -1. . .44 AU03 2 5 18.74000 6.77000 1 145 AU08 2 3 14.09000 4.89000 1 -146 AU09 2 5 9.67000 5.91000 1 147 AU11 1 5 15.03000 4.63000 1 1C. Create codes for sex of animal,


View Full Document
Download Unbal Factoria lBetw
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 Unbal Factoria lBetw 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 Unbal Factoria lBetw 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?