Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

PSYCH-UA 11 - Statistics and Data Analysis for Research in Psychology

Fall 2023

Data Assignment 4

For the following assignment, you will need to do analyses in R.

What you need to submit:

1.  The code you used to complete your analyses

2.  Your written response to each question

How should you write up the homework so we can grade it?

1.  Some of you may have experience with RMarkdown (or maybeyou want to learn how to use RMarkdown!). If that’s the case, you can use RMarkdown to both run your code (in code chunks) and write your responses (outside of those code chunks). Once you’redone, you can knit (aka export) your RMarkdown file as a PDF and submit that.

2. The option most of you will probably use: If you’ve never heard of RMarkdown (or don’t  want to learn how to use it), it’s probably simpler to create run your analyses in R and then write up the assignment in Microsoft Word, Google Docs, or whatever platform you use.

You can submit your code by either:

a.  Taking screenshots of your code and pasting the images into your text document

b.  Copying the code you used in R and directly pasting it into your text document

c.  Submitting both a R Script file with your code + your text document

You will also need to paste the plots you created in R into your text document.

Whichever option you use, it is easiest for us to grade if you submit your write-up as a PDF.

Please help us save time grading by submitting it as a PDF (it opens directly in Brightspace as a PDF, but Word documents don’t…). (R files are ok for your code!)

Do I need to write in full sentences? We aren’t going to grade you on your grammar, but when asked to give your thoughts on something or to explain something in the data, please use full sentences. You don’t have to write a lot, but full sentences make it clearer what you’rethinking.

How do I access R?

Here’s a guide onhow to download R and RStudio onto your own computer.

You can alsoaccess R using NYU’s Virtual Labor througha free account on RStudio Cloud (now called posit cloud)— both great options, especially if you’re struggling to get R onto your computer!

I’m still confused on how to submit the homework, or I am having trouble with R! Please reach out to your teaching assistant (they are all knowledgeable in how to use R!) or to me.

Question 1. Total points: 15

A psychologist is studying the effect of different types of music on reducing stress levels. They conduct an experiment where participants are exposed to one of three types of music: Classical, Jazz, or Rock. After listening to the music for 30 minutes, participants rate their stress levels on a scale from 1 to 10. The psychologist's hypothesis is that different types of music have different effects on stress levels.

Use the following code to get your data into R:

music_types <- factor(c(rep("Classical", 10), rep("Jazz", 10), rep("Rock",

10)))

stress_levels <- c(4, 3, 2, 5, 3, 2, 3, 4, 2, 3, 5, 6, 7, 6, 5, 5, 6, 7, 5, 6,

8, 9, 7, 8, 10, 9, 7, 8, 9, 8)

data <- data.frame(music_types, stress_levels)

1.  Run a one-way ANOVA to test if there are any statistically significant differences in stress levels between the three types of music. (3 pts)

2.  Report the F-value and the p-value from the ANOVA test. (2 pts)

3.  If the ANOVA test is significant, perform a post-hoc test to determine which pairs of music types differ significantly in stress levels. (3 pts)

4.  Interpret the results of the ANOVA and post-hoc tests. What do these results suggest about the impact of different music types on stress levels? (4 pts)

5.  Discuss any assumptions of the one-way ANOVA and how you can check if these assumptions are met with your dataset. (3 pts)

Question 2.Total points: 15

In a separate study, the same psychologist examines whether gender and type of music interact to affect stress levels. Participants are divided into groups based on gender (Male or Female) and the type of music they listen to (Classical, Jazz, or Rock). After listening to the music, they again rate their stress levels.

Use the following code to get your data into R:

gender <- factor(rep(c("Male", "Female"), each = 15))

music_types <- factor(rep(c("Classical", "Jazz", "Rock"), times = 2, each = 5))

stress_levels <- c(4, 5, 3, 4, 2, 6, 7, 5, 6, 5, 8, 7, 9, 8, 7, 3, 2, 4, 3, 2,

5, 6, 4, 5, 4, 7, 8, 6, 7, 6)

data <- data.frame(gender, music_types, stress_levels)

1.  Conduct a two-way ANOVA to examine the effect of gender, music type, and their interaction on stress levels. (3 pts)

2.  Report the F-values and p-values for each main effect and the interaction effect. (3 pts)

3.  Interpret the results. What do these findings suggest about the role of gender and type of music, individually and in combination, on stress levels? (4 pts)

4.  Discuss any assumptions for conducting a two-way ANOVA and how these can be checked in R. (3 pts)

5.  If there are any significant interaction effects, describe how you would conduct and interpret follow-up analyses. (2 pts)