PSYC 480 - Dr. King Simple ANOVA Practice Problems (with Answers) For each of the following, get: a) a three-number summary for each group, i.e., N, mean, sd b) a check for homogeneity of variance, i.e., look at the variances c) the ANOVA table d) a decision regarding the null hypothesis based on the p.value e) an effect size measure, i.e., eta-squared f) post hoc tests if appropriate 1) firemen.txt # Data from Tom Prin (Psyc 497, Spring 2005). # Tom tested firemen from three areas of the country, Horry County, SC, # Charleston, SC, and New York City, recording their score on the Rotter # Internal/External inventory (low scores indicate more internal), and # the firemen's risk rating: A=risk taker, B=gets the job done w/o taking # too many risks, and C=generally unwilling to take risks. The risk rating # can also be expressed in terms of willingness to engage in "meritorious # behavior." Tom's hypothesis was that risk A firemen were most willing to # take risks because of of an external locus of control ("When my time is # up, my time is up."). Question: Why is Tom's hypothesis inappropriate for ANOVA? Because it's a directional hypothesis. To get the data: file = "http://ww2.coastal.edu/kingw/psyc480/data/firemen.txt" firemen = read.table(file = file, header=T, stringsAsFactors = T) summary(firemen) # will give an overall summary so you can see what you've got There are two simple ANOVAs possible here: Rotter ~ Risk Rotter ~ Area > with(firemen, tapply(Rotter,Risk,length)) # N by Risk A B C 26 33 16 > with(firemen, tapply(Rotter,Area,length)) # N by Area Charleston Horry NYC 25 25 25 > with(firemen, tapply(Rotter,Risk,mean)) # mean by Risk A B C 8.961538 10.212121 11.062500 > with(firemen, tapply(Rotter,Area,mean)) # mean by Area Charleston Horry NYC 9.64 10.56 9.68 > with(firemen, tapply(Rotter,Risk,sd)) # sd by Risk A B C 3.155703 2.701360 2.619637 > with(firemen, tapply(Rotter,Area,sd)) # sd by Area Charleston Horry NYC 2.659574 2.887906 3.223869 > # the SDs, and therefore the variances, are reasonably similar, > # so I'm comfortable that homogeneity of variance is satisfied > aov.Risk = aov(Rotter~Risk, data=firemen) > summary(aov.Risk) Df Sum Sq Mean Sq F value Pr(>F) Risk 2 47.5 23.733 2.919 0.0604 . Residuals 72 585.4 8.131 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > aov.Area = aov(Rotter~Area, data=firemen) > summary(aov.Area) Df Sum Sq Mean Sq F value Pr(>F) Area 2 13.5 6.760 0.786 0.46 Residuals 72 619.4 8.602 > # fail to reject the null hypothesis in both cases > 47.5 / (47.5+585.4) # eta-squared for Risk [1] 0.07505135 > 13.5 / (13.5+619.4) # eta-squared for Area [1] 0.02133038 > # post hoc tests are not appropriate because the null was not rjected 2) evaluations.txt # Data from Liz Morris's Psyc 497 project, Fall 2005. # She showed students a picture (of a friend of hers), told them the # picture was of a biology teacher, and presented them with a summary # of a lecture given by this teacher (a female). Students were then # asked to fill out a standard faculty evaluation form. The scores # ("score") are scores from the item asking for an overall evaluation of # the professor. Groups were formed when some students received a # photo of the teacher showing her with short hair, others showing her # with medium length hair, and others showing her with long hair. The # photo was the same in all cases but "photoshopped" to make the hair # length different. Question: The score~group effect is significant, but why? Is it because the appearance of an instructor influences the evaluations given to her by students? Or could it be something else? Note: Students were randomly assigned to these three groups. To get the data: file = "http://ww2.coastal.edu/kingw/psyc480/data/evaluations.txt" evaluations = read.table(file = file, header=T, stringsAsFactors = T) summary(evaluations) The desired analysis is: score ~ group > with(evaluations, tapply(score,group,length)) # N by group long medium short 29 28 27 > with(evaluations, tapply(score,group,mean)) # mean by group long medium short 4.344828 4.821429 3.888889 > with(evaluations, tapply(score,group,sd)) # sd by group long medium short 1.232763 1.123934 1.219500 > # the SDs are very similar, so the variances will be as well; > # homogeneity of variance is satisfied > aov.out = aov(score ~ group, data=evaluations) > summary(aov.out) Df Sum Sq Mean Sq F value Pr(>F) group 2 11.96 5.980 4.2 0.0184 * Residuals 81 115.33 1.424 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > # the null hypothesis is rejected > 11.96 / (11.96+115.33) # eta-squared [1] 0.09395868 > TukeyHSD(aov.out) # post hoc tests Tukey multiple comparisons of means 95% family-wise confidence level Fit: aov(formula = score ~ group, data = evaluations) $group diff lwr upr p adj medium-long 0.4766010 -0.2781985 1.2314005 0.2927600 short-long -0.4559387 -1.2178165 0.3059391 0.3310169 short-medium -0.9325397 -1.7009490 -0.1641303 0.0132762 <-one signif. diff. 3) wolves.txt # Data are from: # Monique A.R.Udell, Nicole R.Dorey, & Clive D.L.Wynne (2008). Wolves # outperform dogs in following human social cues. Animal Behaviour, # Volume 76, Issue 6, 1767-1773. # It has long been believed that dogs have a very special relationship with # humans that very few, if any, other animals have. Dogs and humans have been # together for tens of thousands of years, and the belief is that dogs have # evolved during this time to be able to live socially with humans. Thus, dogs # can follow a human social cue such as a point. If a human simply points to # the location of food, a dog can follow that point to find the food. It is # commonly believed that no other animal, not even most apes, have this # capability. Dogs are evolved from wolves, but previous tests with wolves # have shown them unable to following a human pointing cue. # These authors believe that is because of a confound in the experiments. Dogs # and wolves were tested under different conditions. Dogs were usually tested # indoors by a familiar investigator, whereas the wolves were tested outdoors # by an unfamiliar investigator. These authors set out to correct that experimental # oversight. Five groups of animals were tested for their ability to follow a human # point to find food. Each animal was given ten trials, and since there were only # two things the animal could do, there was a 50:50 chance the animal would get # any given trial correct. Thus, 5 correct responses would be expected by chance # alone. More than 5 correct trials may indicate an animal's ability to follow # the human pointing cue (or the animal may just have gotten lucky). # The following groups were tested. # dou - dogs outdoors unfamiliar investigator # dof - dogs outdoors familiar investigator # diu - dogs indoors unfamiliar investigator # sdiu - shelter dogs indoors unfamiliar investigator # wof - wolves outdoors familiar investigator Question: Which two groups are the most interesting comparison? The most interesting comparison would be wof and dof, wolves and dogs tested under similar circumstances. To get the data: file = "http://ww2.coastal.edu/kingw/psyc480/data/wolves.txt" wolves = read.table(file = file, header=T, stringsAsFactors = T) summary(wolves) The desired analysis is: correct ~ group > with(wolves, tapply(correct,group,length)) # N per group diu dof dou sdiu wof 8 8 8 8 8 > with(wolves, tapply(correct,group,mean)) # means by group diu dof dou sdiu wof 7.125 5.250 4.875 3.125 7.125 > with(wolves, tapply(correct,group,sd)) # sds by group diu dof dou sdiu wof 1.457738 2.604940 2.850439 1.959410 2.232071 > # I'm not too concerned about violations of homogeneity here > aov.out = aov(correct ~ group, data=wolves) > summary(aov.out) Df Sum Sq Mean Sq F value Pr(>F) group 4 91 22.750 4.399 0.0055 ** Residuals 35 181 5.171 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > # the null hypothesis is rejected > 91 / (91+181) # eta-squared [1] 0.3345588 > TukeyHSD(aov.out) Tukey multiple comparisons of means 95% family-wise confidence level Fit: aov(formula = correct ~ group, data = wolves) $group diff lwr upr p adj dof-diu -1.875000e+00 -5.1440551 1.3940551 0.4774783 dou-diu -2.250000e+00 -5.5190551 1.0190551 0.2971178 sdiu-diu -4.000000e+00 -7.2690551 -0.7309449 0.0100993 <-signif. wof-diu -8.881784e-16 -3.2690551 3.2690551 1.0000000 dou-dof -3.750000e-01 -3.6440551 2.8940551 0.9973213 sdiu-dof -2.125000e+00 -5.3940551 1.1440551 0.3523948 wof-dof 1.875000e+00 -1.3940551 5.1440551 0.4774783 sdiu-dou -1.750000e+00 -5.0190551 1.5190551 0.5449712 wof-dou 2.250000e+00 -1.0190551 5.5190551 0.2971178 wof-sdiu 4.000000e+00 0.7309449 7.2690551 0.0100993 <-signif. > # let's see what the Holm-Bonferroni test says > with(wolves, pairwise.t.test(correct,group,p.adjust="holm")) Pairwise comparisons using t tests with pooled SD data: correct and group diu dof dou sdiu dof 0.540 - - - dou 0.446 1.000 - - sdiu 0.012 0.446 0.540 - wof 1.000 0.540 0.446 0.012 P value adjustment method: holm > # the same 4) szeszko.txt # These data were extracted from a graph in Szeszko, P. R., et al. (2007). # Anterior cingulate grey-matter deficits and cannabis use in first-episode # schizophrenia. British Journal of Psychiatry, 190, 230-236. (The data may not # be perfectly accurate in that in was visually extracted from a graph, but it # shows the same effects as those seen by the authors.) There are two variables: # volume - total anterior cingulate gyrus grey matter volume in cubic # centimeters (an area of limbic cortex in the frontal lobes) # group - group to which the subject belonged # controls - healthy control subjects with no history of cannabis use # schizo.no - patients diagnosed with schizophrenia but with no history # of cannabis use # schizo.yes - patients diagnosed with schizophrenia and with a history # of cannabis use # These are the data that appeared in problem 4 (Does Cannabis Shrink Your Brain) # of exercise 1. To get the data: file = "http://ww2.coastal.edu/kingw/psyc480/data/szeszko.txt" szeszko = read.table(file = file, header=T, stringsAsFactors = T) summary(szeszko) The desired analysis is: volume ~ group > with(szeszko, tapply(volume,group,length)) # N per group controls schizo.no schizo.yes 56 31 20 > with(szeszko, tapply(volume,group,mean)) # means by group controls schizo.no schizo.yes 8.287500 8.474194 7.360000 > with(szeszko, tapply(volume,group,sd)) # sds by group controls schizo.no schizo.yes 1.558211 1.556699 1.470911 > # no concerns here over homogeneity of variance > aov.out = aov(volume ~ group, data=szeszko) > summary(aov.out) Df Sum Sq Mean Sq F value Pr(>F) group 2 16.76 8.382 3.524 0.033 * Residuals 104 247.35 2.378 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > # reject the null hypothesis > 16.76 / (16.76+247.35) # eta-squared [1] 0.06345841 > TukeyHSD(aov.out) Tukey multiple comparisons of means 95% family-wise confidence level Fit: aov(formula = volume ~ group, data = szeszko) $group diff lwr upr p adj schizo.no-controls 0.1866935 -0.6341984 1.00758546 0.8514012 schizo.yes-controls -0.9275000 -1.8827103 0.02771030 0.0589828 schizo.yes-schizo.no -1.1141935 -2.1658901 -0.06249698 0.0351862 <-one signif. diff. > # let's go fishing and try the Fisher LSD tests > with(szeszko, pairwise.t.test(volume,group,p.adjust="none")) Pairwise comparisons using t tests with pooled SD data: volume and group controls schizo.no schizo.no 0.590 - schizo.yes 0.023 0.013 P value adjustment method: none > # an additional significant difference with Fisher LSD > # would that difference still be significant if we used the Bonferroni-Dunn test? (no) > # how about the Holm-Bonferroni test? (yes)