Skip to content
tombeesley  /   PSYC121_2021-22  /  
Clear Command Palette
Tip: Type # to search pull requests
Type ? for help and tips
Tip: Type # to search issues
Type ? for help and tips
Tip: Type # to search discussions
Type ? for help and tips
Tip: Type ! to search projects
Type ? for help and tips
Tip: Type @ to search teams
Type ? for help and tips
Tip: Type @ to search people and organizations
Type ? for help and tips
Tip: Type > to activate command mode
Type ? for help and tips
Tip: Go to your accessibility settings to change your keyboard shortcuts
Type ? for help and tips
Tip: Type author:@me to search your content
Type ? for help and tips
Tip: Type is:pr to filter to pull requests
Type ? for help and tips
Tip: Type is:issue to filter to issues
Type ? for help and tips
Tip: Type is:project to filter to projects
Type ? for help and tips
Tip: Type is:open to filter to open content
Type ? for help and tips
We’ve encountered an error and some results aren't available at this time. Type a new search or try again later.
No results matched your search
Search for issues and pull requests # Search for issues, pull requests, discussions, and projects # Search for organizations, repositories, and users @ Search for projects ! Search for files / Activate command mode > Search your issues, pull requests, and discussions # author:@me Search your issues, pull requests, and discussions # author:@me Filter to pull requests # is:pr Filter to issues # is:issue Filter to discussions # is:discussion Filter to projects # is:project Filter to open issues, pull requests, and discussions # is:open
  • Unwatch 1

    Notifications

    Get push notifications on iOS or Android.
Open in github.dev Open in a new github.dev tab
Permalink
ff15dfed06
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
88 lines (57 sloc) 2.13 KB
Open in github.dev
.
library(tidyverse)
library(pwr)
library(rstatix)
data_w9 <- read_csv("music_smedia.csv") # read in the data
# TASK 1 - data visualisation and cleaning
data_w9 %>%
ggplot() +
geom_jitter(aes(x = rock_score, y = pop_score, colour = music_pref))
# draw a histogram of the instagram followers data
data_w9 %>%
ggplot() +
geom_histogram(aes(x = instagram_followers))
# draw a histogram of the facebook friends data
data_w9 %>%
ggplot() +
geom_histogram(aes(x = facebook_friends))
data_w9 <-
data_w9 %>%
mutate(z_FF = scale(facebook_friends), # z-transform of facebook friends
z_IF = scale(instagram_followers)) # z-transform of instagram followers
# descriptive stats
mean(data_w9$z_FF) # for example - also sd(), min(), max()
# removing outliers
data_w9_f <-
data_w9 %>%
filter(z_FF < 2.5 & z_IF < 2.5) #
# TASK 2 - Testing differences with a t-test
#optional plot - probably remove
data_w9_f %>%
ggplot() +
geom_point(aes(x = instagram_followers, y = facebook_friends, colour = music_pref))
# summarise the data
data_w9_f %>%
group_by(music_pref) %>%
summarise(meanFF = mean(facebook_friends),
meanIF = mean(instagram_followers),
N = n()) # how many in each group - no need to edit this
# collect the relevant data for t-test
# test for equality of variances
var.test(data = data_w9_f, facebook_friends ~ music_pref)
# perform the t-test
t.test(data = data_w9_f,
facebook_friends ~ music_pref,
paired = FALSE,
var.equal = TRUE) # change this based on the results of your levene test
# TASK 3 - Power calculations
data_stroop <- read_csv("data_stroop.csv")
# this code removes the control condition from the Stroop data
data_stroop <-
data_stroop %>%
filter(condition == "compatible" | condition == "incompatible")
# find the effect size (d) for the Stroop effect
cohens_d(data = data_stroop,
time ~ condition)
pwr.t.test(n = 20, d = .92, type = "paired") # what power would we achieve?
pwr.t.test(power = .8, d = .92, type = "paired") # what N would we need?
pwr.t.test(power = .9, n = 40, type = "paired") # what effect size could we detect?