1 Initialize R

Initialize R with the following commands.

options(contrasts=c("contr.sum","contr.poly")) # IMPORTANT!!
load(file=url('http://pnb.mcmaster.ca/bennett/psy710/datasets/hw3.rda'))

The options command sets up R to define ANOVA effects using the sum-to-zero constraint. The load command loads the data frames df0, df1, and df3.

Answer the questions in Section 3 and submit your answers as a script file on Avenue 2 Learn. Make sure to begin your script file with the following lines:

# PSYCH 710 Lab 3 Homework
# Script File
# SEP-2023
# Your Name: <<Your name here>>
# Student ID: <<Your ID here>>
# Collaborators: <<Names of your collaborators here>>

Also, make sure that text that is not an R command is preceded by a comment symbol (#). For example, you can insert questions or comments among your commands like this:

# The following command doesn't work... not sure why...
# ttest(x=g1,y=g2) # was trying to do a t test

2 Questions

The data frames df0 and df1 each contain two numeric variables, X and Y. Use df0 and df1 to answer questions 1-4. Unless stated otherwise, you may assume that the data are consistent with the assumptions of the t test, and that alpha is 0.05.

  1. Use a 2-sample (independent groups) t test to evaluate the hypothesis of no difference between X and Y means for both df0 and df1. Compute Cohen’s d for each t test.

  2. Use a paired-sample t test to evaluate the hypothesis of no difference between X and Y means for both df0 and df1. Compute Cohens d for each t test.

  3. Were the effects of going from a 2-sample t test to a paired-sample t test the same for df0 and df1? Why or why not?

  4. Perform an equivalence test to determine if the difference between the paired values X and Y in df0 is equivalent to zero. For this test, define the equivalence bounds as being between ±6. Your answer should include a description of the equivalence test’s null and alternative hypotheses.

The data frame df3 contains the results of a study that measured performance on a cognitive test in children in grades 1 through 5. The data frame contains a factor, grade, and a numeric variable, score. Use df3 to answer questions 5-8. Unless stated otherwise, you may assume that the data are consistent with the assumptions of the F test, and that alpha is 0.05.

  1. Create a figure that plots the mean score as a function of grade.

  2. Conduct an ANOVA to examine the hypothesis that the means do not vary among grades. Your answer should include the ANOVA table, a description of the null and alternative hypotheses, and your conclusion regarding the null hypothesis.

  3. ANOVA assumes that the within-group variance is constant. Is that assumption reasonable for this case?

  4. Regardless of how you answered question 7, evaluate the effect of grade on score using an alternative to ANOVA that does not assume that variance is constant across grades.