With the group project finally complete, my goals this week are to get started on the verification report:
This has been surprisingly difficult, even when I asked Jenny for help, she had some trouble figuring this out. Most of the challenges with this were outlined in last week’s learning log.
Luckily, we were able to successfully replace SE values by using the solution code Jenny provided for us.
First, we took all the steps to get the values and variables that were needed for the graph (not including the SD).
#load packages
library(readspss) #package to read the original datafile from OFS
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.4 ✓ purrr 0.3.4
## ✓ tibble 3.1.2 ✓ dplyr 1.0.6
## ✓ tidyr 1.1.3 ✓ stringr 1.4.0
## ✓ readr 1.4.0 ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(dplyr)
#read data
data <- read.sav("Humiston & Wamsley 2019 data.sav")
#remove excluded
cleandata <- data %>% #remove excluded participants
filter(exclude=="no")
#selecting variables that show biases
choosing_bias <- cleandata %>%
select(baseIATcued, baseIATuncued, preIATcued, preIATuncued, postIATcued, postIATuncued, weekIATcued, weekIATuncued)
#calculate averages
bias_av <- choosing_bias %>%
summarise(cued_baseline_av = mean(baseIATcued),
cued_pre_av = mean(preIATcued),
cued_post_av = mean(postIATcued),
cued_week_av = mean(weekIATcued),
uncued_baseline_av = mean(baseIATuncued),
uncued_pre_av = mean(preIATuncued),
uncued_post_av = mean(postIATuncued),
uncued_week_av = mean(weekIATuncued))
print(bias_av)
## cued_baseline_av cued_pre_av cued_post_av cued_week_av uncued_baseline_av
## 1 0.5175814 0.2108864 0.3068241 0.3999553 0.5954932
## uncued_pre_av uncued_post_av uncued_week_av
## 1 0.3024484 0.248543 0.3988819
Then, what we would normally do is get SE with this code:
SE_bias <- std.error(choosing_bias) #calculated using the plotrix package, see learning log 6
print(SE_bias)
But the problem with this code, was that it didn’t output a normal tibble, it produced values as a double. So, when we tried to call it with the dataset$variable format, it wouldn’t work. Jenny suggested we try this code:
library(plotrix)
bias_av_se <- choosing_bias %>%
summarise_all(list(mean = mean, se = std.error))
print(bias_av_se)
## baseIATcued_mean baseIATuncued_mean preIATcued_mean preIATuncued_mean
## 1 0.5175814 0.5954932 0.2108864 0.3024484
## postIATcued_mean postIATuncued_mean weekIATcued_mean weekIATuncued_mean
## 1 0.3068241 0.248543 0.3999553 0.3988819
## baseIATcued_se baseIATuncued_se preIATcued_se preIATuncued_se postIATcued_se
## 1 0.06522755 0.08030357 0.09232149 0.07937978 0.07984374
## postIATuncued_se weekIATcued_se weekIATuncued_se
## 1 0.08578681 0.06954221 0.0838876
And when we put the values into the dataframe. It worked!
data4 <- data.frame(
condition = factor(c("cued", "cued", "cued", "cued", "uncued", "uncued", "uncued", "uncued")),
time = factor(c("Baseline", "Prenap", "Postnap", "1-week", "Baseline", "Prenap", "Postnap", "1-week")),
levels = c("Baseline", "Prenap", "Postnap", "1-week"),
bias_av = c(bias_av$cued_baseline_av, bias_av$cued_pre_av, bias_av$cued_post_av, bias_av$cued_week_av, bias_av$uncued_baseline_av, bias_av$uncued_pre_av, bias_av$uncued_post_av, bias_av$uncued_week_av))
se = c(bias_av_se$baseIATcued_se, bias_av_se$preIATcued_se, bias_av_se$postIATcued_se, bias_av_se$weekIATcued_se, bias_av_se$baseIATuncued_se, bias_av_se$preIATuncued_se, bias_av_se$postIATuncued_se,bias_av_se$weekIATuncued_se)
head(data4)
## condition time levels bias_av
## 1 cued Baseline Baseline 0.5175814
## 2 cued Prenap Prenap 0.2108864
## 3 cued Postnap Postnap 0.3068241
## 4 cued 1-week 1-week 0.3999553
## 5 uncued Baseline Baseline 0.5954932
## 6 uncued Prenap Prenap 0.3024484
This means we don’t have to summarise the list of means in such a long and convoluted way which, as a result, reduces all this code down to just a few lines. This led me to try and understand the difference between summarise, which is what we were initially using, and summarise_all which is what Jenny used.
As the names of the functions suggest, summarise will only summarise the select variables from the dataset. summarise_all will summarise all of them. Since we want to summarise all of the ones in the choosing_bias dataset, we may as well use this function.
I’ve also managed to simplify our code in a similar way with figure 4.
Overall, this has been a huge success.
My first success in this domain was the fact that Goal 1 allowed me to understand the summarise_all function which, in turn, led me to clean up a large part of my code by allowing me to call variables instead of values. As a result, all my code that includes SEs looks significantly cleaner.
My next challenge was to reduce the code for figure 3 down even more. This is what it initially looked like:
#selecting variables that show biases
choosing_bias <- cleandata %>%
select(baseIATcued, baseIATuncued, preIATcued, preIATuncued, postIATcued, postIATuncued, weekIATcued, weekIATuncued)
#getting the SE and mean for each
bias_av_se <- choosing_bias %>%
summarise_all(list(mean = mean, se = std.error))
print(bias_av_se)
## baseIATcued_mean baseIATuncued_mean preIATcued_mean preIATuncued_mean
## 1 0.5175814 0.5954932 0.2108864 0.3024484
## postIATcued_mean postIATuncued_mean weekIATcued_mean weekIATuncued_mean
## 1 0.3068241 0.248543 0.3999553 0.3988819
## baseIATcued_se baseIATuncued_se preIATcued_se preIATuncued_se postIATcued_se
## 1 0.06522755 0.08030357 0.09232149 0.07937978 0.07984374
## postIATuncued_se weekIATcued_se weekIATuncued_se
## 1 0.08578681 0.06954221 0.0838876
I thought I could merge the selecting variables and summarising functions into one chunk of code by using the summarise(across()) function. The logic behind this is that the across() does the work that select() does.
bias_av_se1 <- cleandata %>%
summarise(across(contains("IAT"), list(mean = mean, se = std.error)))
However, this did not work because there are other columns that we don’t want to analyse which have “IAT” in their name. So I tried to specify the across() even more by using ends_with as well.
bias_av_se1 <- cleandata %>%
summarise(across(contains("IAT"), ends_with("cued"), list(mean = mean, se = std.error)))
But this didn’t work as the error code stated that ends_with() must be used within a selecting function. For now, I’ve decided to leave this challenge for now since this part of the code is already quite compact.
So, I turned my attention to areas that, with my current knowledge, I knew I could clean up. The most obvious example of this was our descriptive statistics.
The first thing I wanted to simplify was the code we used to calculate our implicit bias levels, since we wrote this code at the very beginning of our journey and it was quite clunky. Initially, it looked like this:
BIB <- cleandata %>% #Calculating baseline implicit bias from "cleandata" data
select( #select two variables baseline IAT scores for race and gender
base_IAT_race,
base_IAT_gen) %>%
summarise( #using summarise() to calculate means and sds
BIBaverage = mean(rbind(base_IAT_race, base_IAT_gen)), #use rbind() function to bind together the race and gender baseline IAT values, and then calculate mean and sds for this binded value
BIBsd = sd(rbind(base_IAT_race, base_IAT_gen))
)
print(BIB)
## BIBaverage BIBsd
## 1 0.5565373 0.4058619
PrenapIB <- cleandata %>% #Calculating prenap implicit bias from "cleandata" data
select( #select two variables prenap IAT scores for race and gender
pre_IAT_race,
pre_IAT_gen) %>%
summarise( #using summarise() to calculate means and sds
PrenapIBaverage = mean(
rbind( #use rbind() function to bind together the race and gender prenap IAT values
pre_IAT_race,
pre_IAT_gen)
),
PrenapIBsd = sd( #now calculate mean and sds for this binded value
rbind(
pre_IAT_race,
pre_IAT_gen))
)
print(PrenapIB)
## PrenapIBaverage PrenapIBsd
## 1 0.2566674 0.4776418
PostnapIB <- cleandata %>% #Calculating postnap implicit bias from "cleandata" data
select( #select two variables postnap IAT scores for race and gender
post_IAT_race,
post_IAT_gen) %>%
summarise( #using summarise() to calculate means and sds
PostnapIBaverage = mean(
rbind( #use rbind() function to bind together the race and gender postnap IAT values
post_IAT_race,
post_IAT_gen
)),
PostnapIBsd = sd( #now calculate mean and sds for this binded value
rbind(
post_IAT_race,
post_IAT_gen
))
)
print(PostnapIB)
## PostnapIBaverage PostnapIBsd
## 1 0.2776836 0.4585372
OWDIB <- cleandata %>% #Calculating one-week delay implicit bias from "cleandata" data
select( #select two variables one-week delay IAT scores for race and gender
week_IAT_race,
week_IAT_gen) %>%
summarise( #using summarise() to calculate means and sds
OWDIBaverage = mean(
rbind( #use rbind() function to bind together the race and gender one-week delay IAT values
week_IAT_race,
week_IAT_gen
)
),
OWDIBsd = sd( #now calculate mean and sds for this binded value
rbind(
week_IAT_race,
week_IAT_gen
)
)
)
print(OWDIB)
## OWDIBaverage OWDIBsd
## 1 0.3994186 0.4254629
As you can see, it is very repetitive and long.
I initially attempted my transformations with just the baseline code since I assumed that one I had worked something out with a smaller piece of code, I could apply it to the entire chunk.
Firstly, I attempted to bind the columns outside the summarise so that we didn’t have to repeat the rbind when calculating both the mean and SD. But for some reason, when I try to do it this way, it says that “object ‘base_IAT_race’ not found”.
BIB <- cleandata %>%
select(base_IAT_race,base_IAT_gen) %>%
rbind(base_IAT_race,base_IAT_gen) %>%
summarise_all(list(mean = mean, sd = sd))
print(BIB)
After attempting to Google for answers and play around with different forms of column concatenation (such as pivot_longer - which showed up with the same error message), nothing seemed to work because it still cannot find base_IAT_race even though this is suggested by RStudio when I begin to type the variable.
Jenny, would you be able to give me a hint as to how to fix this? Alternatively, if you have any tips on how I can bind the columns outside of the mean() or sd() functions, that would also be really helpful, thank you!
Luckily, there were other areas in the descriptive statistics which I was able to successfully clean in the meantime.
For example, we initially calculated mean age and mean Epworth Sleepiness score like this:
#first draft of code
ageaverage <- cleandata %>% #calculating average age including sd using "cleandata" data
select(General_1_Age) %>% #select variable from "cleandata" data
summarise(ageaverage = mean(General_1_Age), #calculate mean and sd
agesd = sd(General_1_Age))
ESS <- cleandata %>% #calculating ESS score using "cleandata" data
select(Epworth_total) %>% #select variable from "cleandata" data
summarise(ESSaverage = mean(Epworth_total), #calculate mean and sd
ESSsd = sd(Epworth_total))
print(ESS)
## ESSaverage ESSsd
## 1 15.29032 2.830707
With the new knowledge of summarise_all from Jenny’s tips (as seen above), I was able to condense all this into just a few lines.
averages <- cleandata %>%
select(General_1_Age, Epworth_total) %>%
summarise_all(list(mean = mean, sd = sd))
print(averages)
## General_1_Age_mean Epworth_total_mean General_1_Age_sd Epworth_total_sd
## 1 19.54839 15.29032 1.233929 2.830707
Once I figure out how to use rbind() properly, I would also like to condense that code and include it in a chunk with this.
For this step, I simply wanted to begin the process.
The first question I wanted to examine was: is TMR more effective at reducing bias in men than women?
The logic behind this question was that women are generally more subject to discrimination and may be more active in challenging their preconceived notions of gender. Therefore, the baseline level of bias is not as high in women as it is for men and it is possible that TMR may reduce bias for men and women to the same level. Therefore, if men’s baseline implicit bias is higher then is reduced by TMR to the same level as women’s this change could be significant.
To look at this question, we can only look at bias as it pertains to gender (IAT_gen) variables, we must separate men’s and women’s IATs.
I wanted to try do a boxplot, since our group didn’t have to replicate one.
First, I tried to create a boxplot with just the baseline implicit bias level. Here, grouped the data by sex to separate male and female implicit bias levels. Then, I measured the x axis by the two groups of gender and then measure baseline bias levels on the y axis. I then colour-coded the genders and put all the data into a box plot.
attempt_explore1<- cleandata %>%
group_by(General_1_Sex) %>%
ggplot(aes(
x = General_1_Sex,
y = base_IAT_gen,
fill = General_1_Sex))+
geom_boxplot()
print(attempt_explore1)
This clearly worked, now the next step was to group the x-axis by time periods (baseline, pre-nap, post-nap, week delay) since sex is already shown by colour coding. This would also allow us to see how bias changes over time and with TMR.
We’ve done a similar thing before in our group’s figure 3, as shown here:
When making this graph, we had to put everything into a new data frame first since the x-axis is categorical. So, I initially based this approach off the data frame we used for that graph.
#graph 1 code (original)
data4 <- data.frame(
condition = factor(c("cued", "cued", "cued", "cued", "uncued", "uncued", "uncued", "uncued")),
time = factor(c("Baseline", "Prenap", "Postnap", "1-week", "Baseline", "Prenap", "Postnap", "1-week")),
bias_av = c(bias_av_se$baseIATcued_mean, bias_av_se$preIATcued_mean, bias_av_se$postIATcued_mean, bias_av_se$weekIATcued_mean, bias_av_se$baseIATuncued_mean, bias_av_se$preIATuncued_mean, bias_av_se$postIATuncued_mean, bias_av_se$weekIATuncued_mean))
se = c(bias_av_se$baseIATcued_se, bias_av_se$preIATcued_se, bias_av_se$postIATcued_se, bias_av_se$weekIATcued_se, bias_av_se$baseIATuncued_se, bias_av_se$preIATuncued_se, bias_av_se$postIATuncued_se,bias_av_se$weekIATuncued_se)
#exploratory analysis code
boxplot <- cleandata %>%
group_by(General_1_Sex) %>%
data.frame(
time = factor(c("Baseline", "Prenap", "Postnap", "1-week")),
IAT_gen = c(cleandata$base_IAT_gen, cleandata$pre_IAT_gen, cleandata$post_IAT_gen, cleandata$week_IAT_gen))
head(boxplot)
## ParticipantID exclude cue_presented heard_cue_report heard_cue_exit
## 1 ub6 no yes no no
## 2 ub7 no yes no unsure
## 3 ub8 no yes no no
## 4 ub9 no yes no no
## 5 ub11 no yes no no
## 6 ub13 no yes no no
## predicted_cue Cue_condition Counterbias_order Sound_assignment
## 1 no race cue played racial training first machR and descG
## 2 no race cue played gender training first machG and descR
## 3 no gender cue played racial training first machR and descG
## 4 suspected gender cue played racial training first machR and descG
## 5 no race cue played gender training first machR and descG
## 6 no gender cue played racial training first machG and descR
## IAT1_order IAT234_order IAT_order compensation General_1_Age General_1_Sex
## 1 EATF-SATF SATS-EATS ES, SESESE cash 21 Female
## 2 SATF-EATF EATS-SATS SE, ESESES cash 21 Female
## 3 EATF-SATF SATS-EATS ES, SESESE cash 20 Female
## 4 SATF-EATF EATS-SATS SE, ESESES cash 21 Male
## 5 EATF-SATF SATS-EATS ES, SESESE course credit 19 Female
## 6 EATF-SATF SATS-EATS ES, SESESE course credit 20 Female
## General_1_Race General_1_English General_1_EnglishYrs General_1_Caffeine
## 1 White Yes NA Yes
## 2 White Yes NA Yes
## 3 White Yes NA No
## 4 White Yes NA No
## 5 White No 12 No
## 6 White Yes NA No
## General_1_CaffCups General_1_CaffHrsAgo General_1_SleepDisor
## 1 1 2 No
## 2 1 3 No
## 3 <NA> NA No
## 4 <NA> NA Yes
## 5 <NA> NA No
## 6 <NA> NA No
## General_1_MentalDiso General_1_Meds
## 1 No No
## 2 No Yes
## 3 No No
## 4 No No
## 5 No Yes
## 6 No Yes
## General_1_MedList
## 1
## 2 20 mg prozac every day
## 3
## 4
## 5 birth control
## 6 Quetiapine daily dosage unsure, Wellbutrin 100mg daily, Spironolactone daily for acne dosage unsure
## General_1_University General_1_UniYears Demo_1_Ethnic Demo_1_Racial
## 1 Furman University 3 Not Hispanic or Latino White
## 2 Furman University 3 Not Hispanic or Latino White
## 3 Furman 2 Not Hispanic or Latino White
## 4 Furman University 3 Not Hispanic or Latino White
## 5 Furman University 0 Not Hispanic or Latino White
## 6 Furman 2 Not Hispanic or Latino White
## Demo_1_Gender Demo_1_NonParticipat Epworth_1_Read
## 1 Female <NA> slight chance of dozing
## 2 Female <NA> slight chance of dozing
## 3 Female <NA> slight chance of dozing
## 4 Male <NA> slight chance of dozing
## 5 Female <NA> moderate chance of dozing
## 6 Female <NA> slight chance of dozing
## Epworth_1_TV Epworth_1_Public Epworth_1_Passenger
## 1 slight chance of dozing slight chance of dozing moderate chance of dozing
## 2 slight chance of dozing no chance of dozing slight chance of dozing
## 3 slight chance of dozing no chance of dozing slight chance of dozing
## 4 slight chance of dozing no chance of dozing no chance of dozing
## 5 slight chance of dozing slight chance of dozing moderate chance of dozing
## 6 no chance of dozing no chance of dozing no chance of dozing
## Epworth_1_LyingDown Epworth_1_Talking Epworth_1_Lunch
## 1 high chance of dozing no chance of dozing no chance of dozing
## 2 slight chance of dozing no chance of dozing no chance of dozing
## 3 slight chance of dozing no chance of dozing slight chance of dozing
## 4 no chance of dozing no chance of dozing no chance of dozing
## 5 moderate chance of dozing no chance of dozing no chance of dozing
## 6 high chance of dozing no chance of dozing no chance of dozing
## Epworth_1_Traffic Epworth_total AlertTest_1_Concentr_1
## 1 no chance of dozing 16 80
## 2 no chance of dozing 12 60
## 3 no chance of dozing 13 60
## 4 no chance of dozing 10 70
## 5 no chance of dozing 16 70
## 6 no chance of dozing 12 40
## AlertTest_1_Refresh_1
## 1 60
## 2 70
## 3 60
## 4 30
## 5 60
## 6 40
## AlertTest_1_Feel
## 1 2 - Functioning at high levels, but not at peak; able to concentrate
## 2 2 - Functioning at high levels, but not at peak; able to concentrate
## 3 3 - Awake, but relaxed; responsive but not fully alert
## 4 3 - Awake, but relaxed; responsive but not fully alert
## 5 2 - Functioning at high levels, but not at peak; able to concentrate
## 6 3 - Awake, but relaxed; responsive but not fully alert
## AlertTest_2_Concentr_1 AlertTest_2_Refresh_1
## 1 70 70
## 2 60 60
## 3 40 30
## 4 60 30
## 5 80 60
## 6 40 40
## AlertTest_2_Feel
## 1 3 - Awake, but relaxed; responsive but not fully alert
## 2 2 - Functioning at high levels, but not at peak; able to concentrate
## 3 4 - Somewhat foggy, let down
## 4 3 - Awake, but relaxed; responsive but not fully alert
## 5 2 - Functioning at high levels, but not at peak; able to concentrate
## 6 3 - Awake, but relaxed; responsive but not fully alert
## AlertTest_3_Concentr_1 AlertTest_3_Refresh_1
## 1 NA NA
## 2 60 70
## 3 40 50
## 4 80 70
## 5 NA NA
## 6 60 80
## AlertTest_3_Feel
## 1 <NA>
## 2 2 - Functioning at high levels, but not at peak; able to concentrate
## 3 3 - Awake, but relaxed; responsive but not fully alert
## 4 2 - Functioning at high levels, but not at peak; able to concentrate
## 5 <NA>
## 6 2 - Functioning at high levels, but not at peak; able to concentrate
## AlertTest_4_Concentr_1 AlertTest_4_Refresh_1
## 1 80 90
## 2 60 50
## 3 40 30
## 4 NA NA
## 5 NA NA
## 6 70 80
## AlertTest_4_Feel
## 1 1 - Feeling active, vital alert, or wide awake
## 2 3 - Awake, but relaxed; responsive but not fully alert
## 3 3 - Awake, but relaxed; responsive but not fully alert
## 4 <NA>
## 5 <NA>
## 6 2 - Functioning at high levels, but not at peak; able to concentrate
## S1_ExitQ_1_sound S1_ExitQ_1_soundaffect S1_ExitQ_2_sound S1_ExitQ_3_sound
## 1 No No No No
## 2 No No No No
## 3 No No No No
## 4 No No No No
## 5 No No No No
## 6 No No No No
## S1_ExitQ_4_sound S1_ExitQ_4_soundaffect S1_ExitQ_5_sound
## 1 No No No
## 2 No No No
## 3 No No No
## 4 No No No
## 5 No No No
## 6 No No No
## S1_ExitQ_5_soundaffect S2_ExitQ_1_sound S2_ExitQ_1_soundaffect
## 1 No No No
## 2 No No No
## 3 No No No
## 4 No No No
## 5 No No No
## 6 No No No
## S2_ExitQ_2_sound S2_ExitQ_3_sound S2_ExitQ_4_sound S2_ExitQ_4_soundaffect
## 1 No No No No
## 2 No No No No
## 3 No No No No
## 4 No No No No
## 5 No No No No
## 6 No No No No
## S2_ExitQ_5_sound S2_ExitQ_5_soundaffect Total_sleep Wake_amount NREM1_amount
## 1 No No 65 25 10
## 2 No No 66 24 9
## 3 No No 80 10 5
## 4 No No 62 28 5
## 5 No No 51 39 11
## 6 No No 81 9 4
## NREM2_amount SWS_amount REM_amount SWSxREM cue_minutes baseIATcued
## 1 20.0 12 23 276 9.5 0.57544182
## 2 52.0 19 0 0 12.0 0.09911241
## 3 15.0 24 17 408 15.5 0.20577365
## 4 15.5 24 17 408 16.0 0.35314196
## 5 22.0 16 2 32 15.0 0.57200207
## 6 23.0 36 18 648 25.0 0.31025514
## baseIATuncued preIATcued preIATuncued postIATcued postIATuncued weekIATcued
## 1 0.60953653 0.55905291 0.2146214 0.681910146 0.46728694 0.20377367
## 2 0.64396538 -0.13380639 0.3398503 0.044634805 -0.05686262 0.45873715
## 3 1.52435622 0.51077026 0.3799023 -0.002583615 0.68243589 0.39859469
## 4 0.13108478 -0.02933191 -0.9420955 -0.245989410 0.94970369 0.92341592
## 5 0.04879409 0.30457405 -0.2405173 0.442004960 -0.29184268 -0.01869151
## 6 0.90121486 0.14792592 0.2470349 0.989472453 0.25815885 0.56073473
## weekIATuncued postnap_change_cued postnap_change_uncued week_change_cued
## 1 0.6827742 0.1228572 0.25266550 0
## 2 -0.0107046 0.1784412 -0.39671291 0
## 3 0.7118729 -0.5133539 0.30253356 0
## 4 0.2021283 -0.2166575 1.89179922 0
## 5 0.1307118 0.1374309 -0.05132536 0
## 6 1.1162984 0.8415465 0.01112392 0
## week_change_uncued diff_biaschange_cued diff_biaschange_uncued
## 1 0 0.3716681 -0.07323769
## 2 0 -0.3596247 0.65466998
## 3 0 -0.1928210 0.81248335
## 4 0 -0.5702740 -0.07104354
## 5 0 0.5906936 -0.08191775
## 6 0 -0.2504796 -0.21508358
## diff_biaschange base_IAT_race base_IAT_gen pre_IAT_race pre_IAT_gen
## 1 0.44490584 0.57544182 0.60953653 0.5590529 0.21462144
## 2 -1.01429471 0.09911241 0.64396538 -0.1338064 0.33985028
## 3 -1.00530440 1.52435622 0.20577365 0.3799023 0.51077026
## 4 -0.49923043 0.13108478 0.35314196 -0.9420955 -0.02933191
## 5 0.67261133 0.57200207 0.04879409 0.3045741 -0.24051733
## 6 -0.03539601 0.90121486 0.31025514 0.2470349 0.14792592
## post_IAT_race week_IAT_race post_IAT_gen week_IAT_gen filter_. cues_total
## 1 0.6819101 0.20377367 0.467286940 0.6827742 Selected 142.5
## 2 0.0446348 0.45873715 -0.056862624 -0.0107046 Selected 180.0
## 3 0.6824359 0.71187286 -0.002583615 0.3985947 Selected 232.5
## 4 0.9497037 0.20212832 -0.245989410 0.9234159 Selected 240.0
## 5 0.4420050 -0.01869151 -0.291842685 0.1307118 Selected 225.0
## 6 0.2581588 1.11629844 0.989472453 0.5607347 Selected 375.0
## time IAT_gen
## 1 Baseline 0.60953653
## 2 Prenap 0.64396538
## 3 Postnap 0.20577365
## 4 1-week 0.35314196
## 5 Baseline 0.04879409
## 6 Prenap 0.31025514
I then put this data frame into ggplot in a similar way we did for the graph 1 plot.
#graph 1 plot code (original)
ggplot(data = data4, aes(
x = factor(time, level = c("Baseline", "Prenap", "Postnap", "1-week")), #googled how to reorder x variables !
y = bias_av,
colour = condition,
group = condition)) +
geom_line() +
geom_errorbar(aes(
x= time,
ymin=bias_av-se,
ymax=bias_av+se),
width=0.1, colour="grey", alpha= 0.9) +
ylim(0.0, 0.7) + #expands y axis
labs(x = "", y = "D600 Bias Score", caption = "Fig 3. Average D600 scores at each IAT timepoint") +
theme_bw()
#exploratory analysis plot code
explore1<- ggplot(data = boxplot, aes(
x = factor(time, level = c("Baseline", "Prenap", "Postnap", "1-week")),
y = IAT_gen,
fill = General_1_Sex))+
geom_boxplot()
print(explore1)
While this was a success because it produced something similar to what I had envisioned, there are a few problems with this graph.
Once I’ve sorted these out, I’ll get started on the statistical analysis for this plot.
The next question I want to explore in my exploratory analysis is: did those who heard the cue perform better or worse on the implicit bias test?
The logic behind this one is that if you heard the cue, you may be aware of what the TMR is attempting to do. Would this then affect how the TMR impacts you?
For this we need to separate participants between those who predicted that the cue would be played, and those who didn’t; then we would view the difference between the immediate change and the change after one week.
I will get started on this one after getting advice on binding as this question also requires knowledge on using rbind()
The next steps in my coding journey are a continuation from this week’s work:
This is a lot to do, and since I have a big assignment for another subject due next week, I’m not too sure how much I’ll get done, but I’mm hoping to at least get the first three goals done by next week. It won’t be too bad if I have to leave the last part of my verification report for the week after, as that is the last assignment I have.
In this section, I’ll just more explicitly restate the questions I have for Jenny.
summarise so that we didn’t have to repeat the rbind when calculating both the mean and SD. But for some reason, when I try to do it this way, it says that “object ‘base_IAT_race’ not found”. After attempting to Google for answers and play around with different forms of column combination (such as pivot_longer - which showed up with the same error message), nothing seemed to work because it still cannot find base_IAT_race even though this is suggested by RStudio when I begin to type the variable. Jenny, would you be able to give me a hint as to how to fix this? Alternatively, if you have any tips on how I can bind the columns outside of the mean() or sd() functions, that would also be really helpful, thank you!