The exact order of these steps may vary, depending on your data and what you need to do with it.
Good/helpful practices (an incomplete and somewhat subjective list):
pswq_10 –> pswq_10r.A codebook should contain:
bgq_1) as it will appear in the final dataset (not what it’s named in Qualtrics).example of the codebook section for a measure
For steps (2) and (3), I found it easiest to create an initial draft of the codebook for my own reference, where I recorded the variable names and values exactly as they were in Qualtrics for use while writing the portions of the data cleaning script where variables were renamed and recoded. Then I made a final copy of the codebook with the names and values as reflected in the cleaned dataset.
This section of the script deals with the baseline trait measures that participants completed before their experimental sessions.
This assumes that you have just exported the data directly from Qualtrics, and have not manipulated it in any way (i.e., in Excel, etc.) beforehand.
Task: Import data from CSV file except for columns 2:18 (2:17 is just Qualtrics junk, 18 is the participant’s name and needs to be deleted). We’ll keep the first column ‘StartDate’.
We also want to remove any rows where ID (‘Q52’ for now) doesn’t begin with D1, in order to filter out any pilot or test responses.
# run install.packages("tidyverse") if this is the first time using dplyr on your local machine
library(tidyverse)
filter <- dplyr::filter
select <- dplyr::select
baseline <- read.csv("~/Dropbox/GLASS Lab/OT Study/data/raw-data/OT+fMRI+Baseline_January+18%2C+2019_14.22.csv", stringsAsFactors = FALSE, na.strings="")[ ,-c(2:18)] %>%
filter(grepl("^D1", Q52, ignore.case = TRUE)) # one person input their id as "d130", so should NOT be case sensitive
# na.strings = "" replaces all instances where missing data is represented by blank cells with NA, which is how R handles missing values.
# view IDs
baseline$Q52
# filter out participants who did not complete study
baseline <- filter(baseline, !grepl("D108|D109|D111|D112|D116|D124|D150",Q52))
# view IDs
baseline$Q52
Check that your second column is “Q52” (if you’ve deleted the correct number of columns, it will be). You should have 40 observations of 171 variables.
The name to the left of the equal sign is the new name, the one on the right is what the variable was named in Qualtrics.
baseline_1 <- rename(baseline, startdate = StartDate,
ID = Q52,
dob = Q2,
sex_m = Q1,
dateofdeath = Q36,
knowbefore_y = Q37,
caretaker_y = Q38,
education = Q5,
highestdegree = Q6,
education_other = Q6_6_TEXT,
employment = Q7,
householdsize = Q8,
householdsize_adult = Q10,
householdsize_income = Q12,
ethnicity_hisp = Q13,
race = Q14,
race_other = Q14_6_TEXT,
learnaboutstudy = MHQ.1,
meds_y = MHQ.2,
meds_which = MHQ.3,
meds_dx = MHQ.4,
meds_dose = MHQ.5,
majorhealthprobs_y = MHQ.6,
majorhealthprobs_what = MHQ.7,
past2wks_injuryinfect_y = MHQ.8,
past2wks_dentist_y = MHQ.9,
currenttx_y = MHQ.10,
postmenopausal_y = MHQ.11,
lastperiod = MHQ.12,
n_pregnancies = MHQ.13,
n_livebirths = MHQ.14,
n_nursed = MHQ.15,
allergies = MHQ.16,
surgeries_past6mos = MHQ.17,
alcohol = MHQ.18,
smoking_y = MHQ.19,
smoking_howlong = MHQ.20,
smoking_perday = MHQ.21,
caffeine_perday = MHQ.22,
exercise = MHQ.25,
pss_1 = PSS.1.10_1,
pss_2 = PSS.1.10_2,
pss_3 = PSS.1.10_3,
pss_4 = PSS.1.10_4,
pss_5 = PSS.1.10_5,
pss_6 = PSS.1.10_6,
pss_7 = PSS.1.10_7,
pss_8 = PSS.1.10_8,
pss_9 = PSS.1.10_9,
pss_10 = PSS.1.10_10,
ysl_1 = Yrn.1.21_1,
ysl_2 = Yrn.1.21_2,
ysl_3 = Yrn.1.21_3,
ysl_4 = Yrn.1.21_4,
ysl_5 = Yrn.1.21_5,
ysl_6 = Yrn.1.21_6,
ysl_7 = Yrn.1.21_7,
ysl_8 = Yrn.1.21_8,
ysl_9 = Yrn.1.21_9,
ysl_10 = Yrn.1.21_10,
ysl_11 = Yrn.1.21_11,
ysl_12 = Yrn.1.21_12,
ysl_13 = Yrn.1.21_13,
ysl_14 = Yrn.1.21_14,
ysl_15 = Yrn.1.21_15,
ysl_16 = Yrn.1.21_16,
ysl_17 = Yrn.1.21_17,
ysl_18 = Yrn.1.21_18,
ysl_19 = Yrn.1.21_19,
ysl_20 = Yrn.1.21_20,
ysl_21 = Yrn.1.21_21,
icg_1 = ICG.R1.19_1,
icg_2 = ICG.R1.19_2,
icg_3 = ICG.R1.19_3,
icg_4 = ICG.R1.19_4,
icg_5 = ICG.R1.19_5,
icg_6 = ICG.R1.19_6,
icg_7 = ICG.R1.19_7,
icg_8 = ICG.R1.19_8,
icg_9 = ICG.R1.19_9,
icg_10 = ICG.R1.19_10,
icg_11 = ICG.R1.19_11,
icg_12 = ICG.R1.19_12,
icg_13 = ICG.R1.19_13,
icg_14 = ICG.R1.19_14,
icg_15 = ICG.R1.19_15,
icg_16 = ICG.R1.19_16,
icg_17 = ICG.R1.19_17,
icg_18 = ICG.R1.19_18,
icg_19 = ICG.R1.19_19,
bdi_1 = BDI.1,
bdi_2 = BDI.2,
bdi_3 = BDI.3,
bdi_4 = BDI.4,
bdi_5 = BDI.5,
bdi_6 = BDI.6,
bdi_7 = BDI.7,
bdi_8 = BDI.8,
bdi_9 = BDI.9,
bdi_10 = BDI.10,
bdi_11 = BDI.11,
bdi_12 = BDI.12,
bdi_13 = BDI.13,
bdi_14 = BDI.14,
bdi_15 = BDI.15,
bdi_16 = BDI.16,
bdi_17 = BDI.17,
bdi_18 = BDI.18,
bdi_19 = BDI.19,
bdi_20 = BDI.20,
bdi_21 = BDI.21,
hand_1 = Hand.1_1,
hand_2 = Hand.1_2,
hand_3 = Hand.1_3,
hand_4 = Hand.1_4,
hand_5 = Hand.1_5,
hand_6 = Hand.1_6,
hand_7 = Hand.1_7,
hand_8 = Hand.1_8,
hand_9 = Hand.1_9,
hand_10 = Hand.1_10,
hand_11 = Hand.1_11,
hand_12 = Hand.1_12,
hand_bat_1 = Hand.2,
bisbas_1 = BISBAS_1,
bisbas_2 = BISBAS_2,
bisbas_3 = BISBAS_3,
bisbas_4 = BISBAS_4,
bisbas_5 = BISBAS_5,
bisbas_6 = BISBAS_6,
bisbas_7 = BISBAS_7,
bisbas_8 = BISBAS_8,
bisbas_9 = BISBAS_9,
bisbas_10 = BISBAS_10,
bisbas_11 = BISBAS_11,
bisbas_12 = BISBAS_12,
bisbas_13 = BISBAS_13,
bisbas_14 = BISBAS_14,
bisbas_15 = BISBAS_15,
bisbas_16 = BISBAS_16,
bisbas_17 = BISBAS_17,
bisbas_18 = BISBAS_18,
bisbas_19 = BISBAS_19,
bisbas_20 = BISBAS_20,
bisbas_21 = BISBAS_21,
bisbas_22 = BISBAS_22,
bisbas_23 = BISBAS_23,
bisbas_24 = BISBAS_24,
bgq_1 = BGQ.1,
bgq_2 = BGQ.2,
bgq_3 = BGQ.3,
bgq_4 = BGQ.4,
bgq_5 = BGQ.5,
ecrrs_global_1 = Q185_1,
ecrrs_global_2 = Q185_2,
ecrrs_global_3 = Q185_3,
ecrrs_global_4 = Q185_4,
ecrrs_global_5 = Q185_5,
ecrrs_global_6 = Q185_6,
ecrrs_global_7 = Q185_7,
ecrrs_global_8 = Q185_8,
ecrrs_global_9 = Q185_9,
ecrrs_spouse_1 = Q186_1,
ecrrs_spouse_2 = Q186_2,
ecrrs_spouse_3 = Q186_3,
ecrrs_spouse_4 = Q186_4,
ecrrs_spouse_5 = Q186_5,
ecrrs_spouse_6 = Q186_6,
ecrrs_spouse_7 = Q186_7,
ecrrs_spouse_8 = Q186_8,
ecrrs_spouse_9 = Q186_9)
# Check it out:
print(colnames(baseline_1))
# Save it as a csv file
write.csv(baseline_1, file = "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/baseline_1.csv")
First, let’s change all our scale items from chr to numeric:
baseline_2 <- baseline_1 %>% mutate_at(vars(pss_1:ecrrs_spouse_9), funs(as.numeric))
Note: One way to get this all into the same expression might be to use base R’s sapply, e.g. dat[, c(3,6:15,37)] <- sapply(dat[, c(3,6:15,37)], as.numeric) - but I’m not a fan. Column order may change, and it’s much easier to mix up columns when referring to their order in the dataframe (e.g., 88 vs. 89) than it is to mix up two columns when referring to their names.
Let’s leave our nominal, date, and free-text response variables alone for now (ID, dob, dateofdeath, race_other, learnaboutstudy, meds_which, meds_dx, meds_dose, majorhealthprobs_what, lastperiod, n_pregnancies, n_livebirths, allergies, surgeries_past6mos, alcohol, smoking_howlong).
We could also convert variables from chr to factor here – e.g., baseline <- baseline %>% mutate_at(vars(sex_m), funs(factor)) – but that will be taken care of in the next step.
Let’s save the cleaned data so far. R data format (.rds) preserves data structures, such as column data types (numeric, character or factor).
saveRDS(baseline_2, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/baseline_2.rds")
# If you ever want to restore the pre-factoring step data, simply use:
# baseline_2 <- readRDS("~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/baseline_2.rds")
If you have 5 possible levels of a factor (e.g., options for ‘race’ were White, Black, Asian, Native American/Alaskan Native, Other Race Not Listed) but only 2 actual levels in your data (e.g., all of our participants identify as either White or Other), then it will make 1 = the first factor listed for which there is data, and 2 = the second listed for which there is data.
This is different than SPSS, which preserves factor levels regardless of what your data actually contains.
You can check levels and their order like this:
levels(baseline_3$race)
nlevels(baseline_3$race)
For ordered factors, can check their order (and lowest/highest levels) using the min() and max() functions. For example, min(baseline_3$education) returns the following:
[1] high school grad
Levels: high school grad < some college < college grad < 1 year grad school < 2 years grad school < 3 years grad school < 4+ years grad school
For non-ordered factors, view their levels by simply printing the column. baseline$race returns the following below the data:
Levels: White Other (specify)
lfactors (“Provides an extension to factors called ‘lfactor’ that are similar to factors but allows users to refer to ‘lfactor’ levels by either the level or the label”) (link)# householdsize_income was a factor in Qualtrics ("0 people bringing in income" had a value of 1)
## But here, let's convert it to a numeric variable and simply subtract 1 from each value, instead of treating it as a factor:
baseline_3 <- baseline_2 %>% mutate_at(vars(householdsize_income), funs(as.numeric)) %>% mutate(householdsize_income = householdsize_income - 1)
# householdsize and householdsize_adult should also be numeric.
baseline_3 <- baseline_2 %>% mutate_at(vars(householdsize,householdsize_adult), funs(as.numeric))
# Let's clean up the n_pregnancies variable. This was a free-response field, so several people entered "none", "n/a", "male", etc. rather than numeric values.
## We want to change the response "Two" to "2", and make any other non-number response NA.
baseline_3 <- baseline_2 %>% mutate(n_pregnancies = recode(n_pregnancies, "Two" = "2")) # this will give an error message "NAs introduced by coercion" - feel free to ignore it.
baseline_3 <- baseline_2 %>% mutate_at(vars(n_pregnancies), funs(as.numeric))
NAs introduced by coercion
# na_if is also useful function if there's only one value you want to make NA
# See also https://dplyr.tidyverse.org/reference/na_if.html
## Example: baseline <- baseline %>% mutate(n_pregnancies = na_if(n_pregnancies, "None"))
### (We could have done that for all of the text responses other than "Two" in this dataset, but changing the column to numeric from character automatically converts any remaining strings to NA so it would be redundant).
# Making ordered factors: '.ordered = TRUE' orders your levels in order listed, so the first is the reference value.
## Example: for sex_m, we want female to be the reference value, so it is listed first.
## For all of the yes/no variables, they are appended "_y" (for ex., meds_y).
### This indicates that a "no" response is always the reference group, so it should be listed first.
### Note that not all factors are ordered ('.ordered = FALSE' is default).
baseline_3 <- baseline_2 %>%
mutate(sex_m = recode_factor(sex_m, "2" = "female", "1" = "male", .ordered = TRUE),
knowbefore_y = recode_factor(knowbefore_y, "2" = "no", "1" = "yes", .ordered = TRUE),
caretaker_y = recode_factor(caretaker_y, "2" = "no", "1" = "yes", .ordered = TRUE),
education = recode_factor(education, "1" = "less than high school", "2" = "less than high school", "3" = "less than high school", "4" = "less than high school", "5" = "high school grad", "6" = "some college", "7" = "some college", "8" = "some college","9" = "college grad", "10" = "1 year grad school", "11" = "2 years grad school", "12" = "3 years grad school", "13" = "4+ years grad school", .ordered = TRUE), # collapsed the 13 different education categories into 8
highestdegree = recode_factor(highestdegree, "7" = "Less than HS diploma or GED", "1" = "HS diploma or GED", "2" = "Associates's", "3" = "Bachelor's", "4" = "Master's", "5" = "Doctorate", "6" = "Other (specify)"), # did not make this an ordered factor because wasn't sure how the Other category should be ranked
employment = recode_factor(employment, "1" = "working full time", "2" = "working part time", "3" = "unemployed or laid off", "4" = "looking for work", "5" = "keeping house or raising children full time", "6" = "retired", "7" = "student"),
ethnicity_hisp = recode_factor(ethnicity_hisp, "2" = "not Hispanic or Latino", "1" = "Hispanic or Latino", .ordered = TRUE),
race = recode_factor(race, "1" = "White", "2" = "African-American/Black", "3" = "Asian American/Asian", "4" = "Native American or Alaskan Native", "5" = "Pacific Islander or Native Hawaiian", "6" = "Other (specify)"),
meds_y = recode_factor(meds_y, "2" = "no", "1" = "yes", .ordered = TRUE),
majorhealthprobs_y = recode_factor(majorhealthprobs_y, "2" = "no", "1" = "yes", .ordered = TRUE),
past2wks_injuryinfect_y = recode_factor(past2wks_injuryinfect_y, "2" = "no", "1" = "yes", .ordered = TRUE),
past2wks_dentist_y = recode_factor(past2wks_dentist_y, "2" = "no", "1" = "yes", .ordered = TRUE),
currenttx_y = recode_factor(currenttx_y, "2" = "no", "1" = "yes", .ordered = TRUE),
postmenopausal_y = recode_factor(postmenopausal_y, "1" = "no/pre", "2" = "yes/post", .ordered = TRUE),
n_livebirths = recode_factor(n_livebirths, "6" = "0", "1" = "1", "2" = "2", "3" = "3", "4" = "4", "5" = "5 or more", .ordered = TRUE),
n_nursed = recode_factor(n_nursed, "6" = "0", "1" = "1", "2" = "2", "3" = "3", "4" = "4", "5" = "5 or more", .ordered = TRUE),
smoking_y = recode_factor(smoking_y, "2" = "no", "1" = "yes", .ordered = TRUE),
smoking_perday = recode_factor(smoking_perday, "4" = "< 1 cigarette/day", "3" = "1-10 cigarettes/day", "2" = ">10 cigarettes/day", "1" = ">1 pack/day", .ordered = TRUE),
caffeine_perday = recode_factor(caffeine_perday, "4" = "never or <1x", "3" = "1-3x", "2" = "3-5x", "1" = ">5x", .ordered = TRUE),
exercise = recode_factor(exercise, "1" = "not at all", "2" = "1x/week (30+ mins)", "3" = "2-3x/week (30+ mins)", "4" = ">3x/week (30+ mins)", .ordered = TRUE))
# In RStudio, double-check your work by highlighting the name of each variable to show other instances of that variable (helpful with copy/paste errors)
# the lubridate package will be installed along with tidyverse, but if not:
# install.packages("lubridate")
library(lubridate)
Attaching package: ‘lubridate’
The following object is masked from ‘package:base’:
date
# First, we only care about the date they completed the baseline survey, not the time
# so we'll split 'startdate' into two columns, removing the time column.
tidyr::separate(baseline_3, startdate, c("startdate", "time"), sep = " ") -> baseline_3
Expected 2 pieces. Missing pieces filled with `NA` in 40 rows [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ...].
baseline_3$time <- NULL
# 'dob' and 'dateofdeath' both need to be converted from character to date.
# Notice that D138 entered dates using dashes (-) rather than slashes (/), so we need to change that.
# Use the mdy function from lubridate to convert 'dob' and 'dateofdeath' from character to date.
baseline_3 <- baseline_3 %>%
mutate(dateofdeath = recode(dateofdeath, "10-01-2015" = "10/01/2015"),
dob = recode(dob, "03-13-1950" = "03/13/1950"),
dateofdeath = mdy(dateofdeath),
dob = mdy(dob),
startdate = ymd(startdate)
)
unknown timezone 'zone/tz/2018i.1.0/zoneinfo/America/Phoenix'
# Now we need to calculate two new variables: age at enrollment (using when they completed the baseline survey as a proxy for enrollment), and time since death at enrollment.
baseline_3 %>% mutate(timesincedeath = startdate - dateofdeath, age = startdate - dob) %>% mutate_at(vars(timesincedeath, age), funs(as.numeric)) -> baseline_3
# needed to convert the new timesincedeath variable to numeric (vs. difftime) object, because there are a limited number of functions that can operate on difftime objects.
# to get their age in years (instead of days), use
baseline_3 %>% mutate(age_yrs = age/365) -> baseline_3
library(psych)
Attaching package: ‘psych’
The following objects are masked from ‘package:ggplot2’:
%+%, alpha
# time since death
describe(baseline_3$timesincedeath)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 468.5 248.34 429 433.97 220.17 151 1095 944 1.03 0.06 39.27
# age in years
describe(baseline_3$age_yrs)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 69.22 6.49 70.19 69.38 7.33 57.11 79.73 22.62 -0.22 -1.03 1.03
# save your work frequently!
saveRDS(baseline_3, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/baseline_3.rds")
# load if needed:
# baseline_3 <- readRDS("~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/baseline_3.rds")
# 'haven' package should allow you to save as .sav file but won't work for me - file is blank when I open it in spss
# 'foreign' package hasn't worked either - may be compatibility issue with newer versions of SPSS?
Now, let’s tackle our scales.
Qualtrics assigns values starting with 1 as default, but this doesn’t always match what the values should be (i.e., when an item should be scored 0-3, not 1-4).
# For this section, you'll need the 'psych' package
## install.packages("psych") if you don't have it on this machine
library(psych)
baseline_4 <- baseline_3 # make a new iteration of the dataset for scoring and recoding
##################
### Perceived Stress Scale
# Citation: Cohen, S., Kamarck, T., and Mermelstein, R. (1983). A global measure of perceived stress. Journal of Health and Social Behavior, 24, 386-396.
# Answer choices range from 0 (Never) – 4 (Very Often).
# Reverse scored items = 4, 5, 7, 8.
# Sum all items (possible range: 0 – 40) [tot_pss]
# First, reverse score (and/or recode, if applicable) the relevant items:
baseline_4$pss_4r <- 4 - baseline_3$pss_4
baseline_4$pss_5r <- 4 - baseline_3$pss_5
baseline_4$pss_7r <- 4 - baseline_3$pss_7
baseline_4$pss_8r <- 4 - baseline_3$pss_8
# Another way to do this would be:
## cols = c("pss_4", "pss_5", "pss_7", "pss_8")
## baseline[ ,cols] = 5 - baseline[ ,cols]
## BUT the problem with this approach is that you could accidentally re-run those lines, which would undo the reverse scoring because it assigns the new scoring back to the old variable.
# How to create a new 'total' variable:
## First, subset out the columns you want to use in the total score.
## Then use rowSums to get the total, and attach tot_pss back to the dataframe.
tot_pss <- subset(baseline_4, select=c(pss_1,pss_2,pss_3,pss_4r,pss_5r,pss_6,pss_7r,pss_8r,pss_9,pss_10))
baseline_4$tot_pss <- rowSums(tot_pss, na.rm=TRUE) # if na.rm=FALSE, participants with missing responses on any of the items in the subset will not have their total score calculated (i.e., their total will be NA)
# Check out the descriptives if you like (though we'll do this later too)
describe(baseline_4$tot_pss)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 12.93 6.75 11.5 12.53 8.15 4 28 24 0.37 -1.04 1.07
##################
### Yearning in Situations of Loss
# Citation: O'Connor, M. F., & Sussman, T. J. (2014). Developing the yearning in situations of loss scale: Convergent and discriminant validity for bereavement, spouse breakup, and homesickness. Death Studies, 38(7), 450-458.
# Answer choices range from 1 (Never) – 5 (Always).
# NO reverse scored items.
# Sum all items (possible range: 21 – 105) [tot_ysl]
tot_ysl <- subset(baseline_3, select=c(ysl_1:ysl_21))
baseline_4$tot_ysl <- rowSums(tot_ysl, na.rm=TRUE)
describe(baseline_4$tot_ysl)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 67.38 18.79 69.5 67.19 20.02 31 100 69 -0.03 -1.17 2.97
##################
### Inventory of Complicated Grief (NOT the ICG-Revised, although it was labeled as such in Qualtrics)
# Citation: Prigerson, H. G., Maciejewski, P. K., Reynolds, C. F., Bierhals, A. J., Newsom, J. T., Fasiczka, A., ... & Miller, M. (1995). Inventory of Complicated Grief: a scale to measure maladaptive symptoms of loss. Psychiatry Research, 59(1), 65-79.
# Answer choices range from 0 (Never) – 4 (Always).
# NO reverse scored items.
# Sum all items (possible range: 0 – 76; clinical cut-off = 25). [tot_icg]
tot_icg <- subset(baseline_3, select=c(icg_1:icg_19))
baseline_4$tot_icg <- rowSums(tot_icg, na.rm=TRUE)
describe(baseline_4$tot_icg)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 23.35 12.47 22 22.59 10.38 4 51 47 0.37 -0.69 1.97
##################
### Beck Depression Inventory-II
# Citation: Beck, A.T., Steer, R.A., & Brown, G.K. (1996). Manual for the Beck Depression Inventory-II. San Antonio, TX: Psychological Corporation.
# Answer choices range from 0 – 3.
# NO reverse scored items.
# Sum all items (possible range: 0 – 63; <14 = Minimal, 14-20 = Mild, 20-29 = Moderate, 29-51 = Severe). [tot_bdi]
baseline_4 <- baseline_4 %>% mutate(bdi_1c = recode(bdi_1, "1" = "0", "2" = "1", "3" = "2", "4" = "3"))
baseline_4 <- baseline_4 %>% mutate(bdi_2c = recode(bdi_2, "1" = "0", "4" = "1", "6" = "2", "7" = "3")) # note that the Qualtrics coding on item 2 differed from the other items
baseline_4 <- baseline_4 %>% mutate(bdi_3c = recode(bdi_3, "1" = "0", "2" = "1", "3" = "2", "4" = "3"))
baseline_4 <- baseline_4 %>% mutate(bdi_4c = recode(bdi_4, "1" = "0", "2" = "1", "3" = "2", "4" = "3"))
baseline_4 <- baseline_4 %>% mutate(bdi_5c = recode(bdi_5, "1" = "0", "2" = "1", "3" = "2", "4" = "3"))
baseline_4 <- baseline_4 %>% mutate(bdi_6c = recode(bdi_6, "1" = "0", "2" = "1", "3" = "2", "4" = "3"))
baseline_4 <- baseline_4 %>% mutate(bdi_7c = recode(bdi_7, "1" = "0", "2" = "1", "3" = "2", "4" = "3"))
baseline_4 <- baseline_4 %>% mutate(bdi_8c = recode(bdi_8, "1" = "0", "2" = "1", "3" = "2", "4" = "3"))
baseline_4 <- baseline_4 %>% mutate(bdi_9c = recode(bdi_9, "1" = "0", "2" = "1", "3" = "2", "4" = "3"))
baseline_4 <- baseline_4 %>% mutate(bdi_10c = recode(bdi_10, "1" = "0", "2" = "1", "3" = "2", "4" = "3"))
baseline_4 <- baseline_4 %>% mutate(bdi_11c = recode(bdi_11, "1" = "0", "2" = "1", "3" = "2", "4" = "3"))
baseline_4 <- baseline_4 %>% mutate(bdi_12c = recode(bdi_12, "1" = "0", "2" = "1", "3" = "2", "4" = "3"))
baseline_4 <- baseline_4 %>% mutate(bdi_13c = recode(bdi_13, "1" = "0", "2" = "1", "3" = "2", "4" = "3"))
baseline_4 <- baseline_4 %>% mutate(bdi_14c = recode(bdi_14, "1" = "0", "2" = "1", "3" = "2", "4" = "3"))
baseline_4 <- baseline_4 %>% mutate(bdi_15c = recode(bdi_15, "1" = "0", "2" = "1", "3" = "2", "4" = "3"))
baseline_4 <- baseline_4 %>% mutate(bdi_16c = recode(bdi_16, "1" = "0", "2" = "1", "3" = "2", "4" = "3"))
baseline_4 <- baseline_4 %>% mutate(bdi_17c = recode(bdi_17, "1" = "0", "2" = "1", "3" = "2", "4" = "3"))
baseline_4 <- baseline_4 %>% mutate(bdi_18c = recode(bdi_18, "1" = "0", "2" = "1", "3" = "2", "4" = "3"))
baseline_4 <- baseline_4 %>% mutate(bdi_19c = recode(bdi_19, "1" = "0", "2" = "1", "3" = "2", "4" = "3"))
baseline_4 <- baseline_4 %>% mutate(bdi_20c = recode(bdi_20, "1" = "0", "2" = "1", "3" = "2", "4" = "3"))
baseline_4 <- baseline_4 %>% mutate(bdi_21c = recode(bdi_21, "1" = "0", "2" = "1", "3" = "2", "4" = "3"))
baseline_4 <- baseline_4 %>% mutate_at(vars(bdi_1c:bdi_21c), funs(as.numeric))
tot_bdi <- subset(baseline_4, select=c(bdi_1c:bdi_21c))
baseline_4$tot_bdi <- rowSums(tot_bdi, na.rm=TRUE)
describe(baseline_4$tot_bdi)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 10.32 7.72 9.5 9.66 8.15 0 28 28 0.55 -0.76 1.22
##################
### Hand Usage Questionnaire
# Citation: Raczkowski, D., Kalat, J. W., & Nebes, R. (1974). Reliability and validity of some handedness questionnaire items. Neuropsychologia, 12(1), 43-47.
# Sum all items (1 = Right, 2 = Either, 3 = Left). [tot_handedness]
# Possible range: 13 (completely right-handed) – 39 (completely left-handed).
baseline_4 <- baseline_4 %>% mutate(hand_1c = recode(hand_1, "2" = "1", "1" = "3", "4" = "2"))
baseline_4 <- baseline_4 %>% mutate(hand_2c = recode(hand_2, "2" = "1", "1" = "3", "4" = "2"))
baseline_4 <- baseline_4 %>% mutate(hand_3c = recode(hand_3, "2" = "1", "1" = "3", "4" = "2"))
baseline_4 <- baseline_4 %>% mutate(hand_4c = recode(hand_4, "2" = "1", "1" = "3", "4" = "2"))
baseline_4 <- baseline_4 %>% mutate(hand_5c = recode(hand_5, "2" = "1", "1" = "3", "4" = "2"))
baseline_4 <- baseline_4 %>% mutate(hand_6c = recode(hand_6, "2" = "1", "1" = "3", "4" = "2"))
baseline_4 <- baseline_4 %>% mutate(hand_7c = recode(hand_7, "2" = "1", "1" = "3", "4" = "2"))
baseline_4 <- baseline_4 %>% mutate(hand_8c = recode(hand_8, "2" = "1", "1" = "3", "4" = "2"))
baseline_4 <- baseline_4 %>% mutate(hand_9c = recode(hand_9, "2" = "1", "1" = "3", "4" = "2"))
baseline_4 <- baseline_4 %>% mutate(hand_10c = recode(hand_10, "2" = "1", "1" = "3", "4" = "2"))
baseline_4 <- baseline_4 %>% mutate(hand_11c = recode(hand_11, "2" = "1", "1" = "3", "4" = "2"))
baseline_4 <- baseline_4 %>% mutate(hand_12c = recode(hand_12, "2" = "1", "1" = "3", "4" = "2"))
baseline_4 <- baseline_4 %>% mutate(hand_bat_1c = recode(hand_bat_1, "2" = "1", "1" = "3", "3" = "2"))
baseline_4 <- baseline_4 %>% mutate_at(vars(hand_1c:hand_bat_1c), funs(as.numeric))
tot_handedness <- subset(baseline_4, select=c(hand_1c:hand_bat_1c))
baseline_4$tot_handedness <- rowSums(tot_handedness, na.rm=TRUE)
describe(baseline_4$tot_handedness)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 15.43 5.42 13 14 0 13 39 26 2.9 8.31 0.86
##################
### Behavioral Inhibition/Behavioral Activation Scales (BIS/BAS)
# Citation: Carver, C. S., & White, T. L. (1994). Behavioral inhibition, behavioral activation, and affective responses to impending reward and punishment: The BIS/BAS scales. Journal of Personality and Social Psychology, 67, 319-333.
# Answer choices range from 1 (Very true) – 4 (Very false).
# Reverse score ALL items EXCEPT for 2 and 22.
## BAS Drive: 3, 9, 12, 21 [tot_bisbas_basdr]
## BAS Fun Seeking: 5, 10, 15, 20 [tot_bisbas_basfun]
## BAS Reward Responsiveness: 4, 7, 14, 18, 23 [tot_bisbas_basrr]
## BIS: 2, 8, 13, 16, 19, 22, 24 [tot_bisbas_bis]
## Items 1, 6, 11, 17 are fillers.
# reverse score:
baseline_4$bisbas_1r <- 5 - baseline_4$bisbas_1
baseline_4$bisbas_3r <- 5 - baseline_4$bisbas_3
baseline_4$bisbas_4r <- 5 - baseline_4$bisbas_4
baseline_4$bisbas_5r <- 5 - baseline_4$bisbas_5
baseline_4$bisbas_6r <- 5 - baseline_4$bisbas_6
baseline_4$bisbas_7r <- 5 - baseline_4$bisbas_7
baseline_4$bisbas_8r <- 5 - baseline_4$bisbas_8
baseline_4$bisbas_9r <- 5 - baseline_4$bisbas_9
baseline_4$bisbas_10r <- 5 - baseline_4$bisbas_10
baseline_4$bisbas_11r <- 5 - baseline_4$bisbas_12
baseline_4$bisbas_12r <- 5 - baseline_4$bisbas_12
baseline_4$bisbas_13r <- 5 - baseline_4$bisbas_13
baseline_4$bisbas_14r <- 5 - baseline_4$bisbas_14
baseline_4$bisbas_15r <- 5 - baseline_4$bisbas_15
baseline_4$bisbas_16r <- 5 - baseline_4$bisbas_16
baseline_4$bisbas_17r <- 5 - baseline_4$bisbas_17
baseline_4$bisbas_18r <- 5 - baseline_4$bisbas_18
baseline_4$bisbas_19r <- 5 - baseline_4$bisbas_19
baseline_4$bisbas_20r <- 5 - baseline_4$bisbas_20
baseline_4$bisbas_21r <- 5 - baseline_4$bisbas_21
baseline_4$bisbas_23r <- 5 - baseline_4$bisbas_23
baseline_4$bisbas_24r <- 5 - baseline_4$bisbas_24
# BAS-Drive subscale
tot_basdr <- subset(baseline_4, select=c(bisbas_3r, bisbas_9r, bisbas_12r, bisbas_21r))
baseline_4$tot_bisbas_basdr <- rowSums(tot_basdr, na.rm=TRUE)
# BAS-Fun Seeking subscale
tot_basfun <- subset(baseline_4, select=c(bisbas_5r, bisbas_10r, bisbas_15r, bisbas_20r))
baseline_4$tot_bisbas_basfun <- rowSums(tot_basfun, na.rm=TRUE)
# BAS-Reward Responsiveness subscale
tot_basrr <- subset(baseline_4, select=c(bisbas_4r, bisbas_7r, bisbas_14r, bisbas_18r, bisbas_23r))
baseline_4$tot_bisbas_basrr <- rowSums(tot_basrr, na.rm=TRUE)
# BIS subscale
tot_bis <- subset(baseline_4, select=c(bisbas_2, bisbas_8r, bisbas_13r, bisbas_16r, bisbas_19r, bisbas_22, bisbas_24r))
baseline_4$tot_bisbas_bis <- rowSums(tot_bis, na.rm=TRUE)
describe(baseline_4$tot_bisbas_basdr)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 8.95 2.46 9 9.09 2.97 4 13 9 -0.33 -1.05 0.39
describe(baseline_4$tot_bisbas_basfun)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 9.8 2.22 10 9.78 2.22 4 14 10 -0.16 0.05 0.35
describe(baseline_4$tot_bisbas_basrr)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 15.75 2.2 16 15.94 1.48 9 19 10 -0.85 0.85 0.35
describe(baseline_4$tot_bisbas_bis)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 19.3 4.1 19 19.31 3.71 9 27 18 -0.15 -0.1 0.65
##################
### Brief Grief Questionnaire
# Citations: (1) Shear, K., & Essock, S. (2002). Brief grief questionnaire. Pittsburgh, PA: University of Pittsburgh. (2) Shear, K. M., Jackson, C. T., Essock, S. M., Donahue, S. A., & Felton, C. J. (2006). Screening for complicated grief among Project Liberty service recipients 18 months after September 11, 2001. Psychiatric Services, 57(9), 1291-1297.
# Sum all items (0 = Not at all, 1 = Somewhat, 2 = A lot). [tot_bgq]
## Possible range: 0 – 10.
## Cutoffs from Shear et al. (2006): “8 or higher, complicated grief was likely; between 5 and 7, complicated grief was likely at a subthreshold level; and less than 5, complicated grief was unlikely.” For a dichotomous variable, a score of 5 or above was taken as a positive CG screen.
tot_bgq <- subset(baseline_4, select=c(bgq_1:bgq_5))
baseline_4$tot_bgq <- rowSums(tot_bgq, na.rm=TRUE)
describe(baseline_4$tot_bgq)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 9.55 2.28 9 9.44 1.48 6 15 9 0.47 -0.33 0.36
##################
### Experiences in Close Relationships - Relationship Structures (Global Version)
# Citations: Fraley, R. C., Heffernan, M. E., Vicary, A. M., & Brumbaugh, C. C. (2011). The Experiences in Close Relationships-Relationship Structures questionnaire: A method for assessing attachment orientations across relationships. Psychological Assessment, 23, 615-625.
# Reverse-scored: 1, 2, 3, 4.
# Two subscales (NO overall total)
## Avoidance: 1-6 [tot_ecrrs_global_avoid] (average)
## Anxiety: 7-9 [tot_ecrrs_global_anx] (average)
# Fix incorrect Qualtrics coding:
baseline_4 <- baseline_4 %>% mutate(ecrrs_global_1c = recode(ecrrs_global_1, "1"="1", "2"="2", "3"="3", "4"="4", "7"="5", "8"="6", "9"="7"))
baseline_4 <- baseline_4 %>% mutate(ecrrs_global_2c = recode(ecrrs_global_2, "1"="1", "2"="2", "3"="3", "4"="4", "7"="5", "8"="6", "9"="7"))
baseline_4 <- baseline_4 %>% mutate(ecrrs_global_3c = recode(ecrrs_global_3, "1"="1", "2"="2", "3"="3", "4"="4", "7"="5", "8"="6", "9"="7"))
baseline_4 <- baseline_4 %>% mutate(ecrrs_global_4c = recode(ecrrs_global_4, "1"="1", "2"="2", "3"="3", "4"="4", "7"="5", "8"="6", "9"="7"))
baseline_4 <- baseline_4 %>% mutate(ecrrs_global_5c = recode(ecrrs_global_5, "1"="1", "2"="2", "3"="3", "4"="4", "7"="5", "8"="6", "9"="7"))
baseline_4 <- baseline_4 %>% mutate(ecrrs_global_6c = recode(ecrrs_global_6, "1"="1", "2"="2", "3"="3", "4"="4", "7"="5", "8"="6", "9"="7"))
baseline_4 <- baseline_4 %>% mutate(ecrrs_global_7c = recode(ecrrs_global_7, "1"="1", "2"="2", "3"="3", "4"="4", "7"="5", "8"="6", "9"="7"))
baseline_4 <- baseline_4 %>% mutate(ecrrs_global_8c = recode(ecrrs_global_8, "1"="1", "2"="2", "3"="3", "4"="4", "7"="5", "8"="6", "9"="7"))
baseline_4 <- baseline_4 %>% mutate(ecrrs_global_9c = recode(ecrrs_global_9, "1"="1", "2"="2", "3"="3", "4"="4", "7"="5", "8"="6", "9"="7"))
baseline_4 <- baseline_4 %>% mutate_at(vars(ecrrs_global_1c:ecrrs_global_9c), funs(as.numeric))
# Reverse code items 1-4:
baseline_4$ecrrs_global_1r <- 8 - baseline_4$ecrrs_global_1c
baseline_4$ecrrs_global_2r <- 8 - baseline_4$ecrrs_global_2c
baseline_4$ecrrs_global_3r <- 8 - baseline_4$ecrrs_global_3c
baseline_4$ecrrs_global_4r <- 8 - baseline_4$ecrrs_global_4c
tot_ecrrs_global_avoid <- subset(baseline_4, select=c(ecrrs_global_1r:ecrrs_global_4r, ecrrs_global_5c, ecrrs_global_6c))
tot_ecrrs_global_anx <- subset(baseline_4, select=c(ecrrs_global_7c:ecrrs_global_9c))
baseline_4$tot_ecrrs_global_avoid <- rowMeans(tot_ecrrs_global_avoid, na.rm=TRUE)
baseline_4$tot_ecrrs_global_anx <- rowMeans(tot_ecrrs_global_anx, na.rm=TRUE)
describe(baseline_4$tot_ecrrs_global_avoid)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 3.4 1.09 3.42 3.4 0.86 1 6.33 5.33 0.08 0.22 0.17
describe(baseline_4$tot_ecrrs_global_anx)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 3.24 1.46 3.33 3.17 1.98 1 6.33 5.33 0.36 -0.86 0.23
##################
### Experiences in Close Relationships - Relationship Structures (Romantic Partner/Spouse Version)
# Citations: Fraley, R. C., Heffernan, M. E., Vicary, A. M., & Brumbaugh, C. C. (2011). The Experiences in Close Relationships-Relationship Structures questionnaire: A method for assessing attachment orientations across relationships. Psychological Assessment, 23, 615-625.
# Reverse-scored: 1, 2, 3, 4.
# Two subscales (NO overall total)
## Avoidance: 1-6 [tot_ecrrs_global_avoid] (average)
## Anxiety: 7-9 [tot_ecrrs_global_anx] (average)
# Fix incorrect Qualtrics coding
baseline_4 <- baseline_4 %>% mutate(ecrrs_spouse_1c = recode(ecrrs_spouse_1, "1"="1", "2"="2", "3"="3", "4"="4", "7"="5", "8"="6", "9"="7"))
baseline_4 <- baseline_4 %>% mutate(ecrrs_spouse_2c = recode(ecrrs_spouse_2, "1"="1", "2"="2", "3"="3", "4"="4", "7"="5", "8"="6", "9"="7"))
baseline_4 <- baseline_4 %>% mutate(ecrrs_spouse_3c = recode(ecrrs_spouse_3, "1"="1", "2"="2", "3"="3", "4"="4", "7"="5", "8"="6", "9"="7"))
baseline_4 <- baseline_4 %>% mutate(ecrrs_spouse_4c = recode(ecrrs_spouse_4, "1"="1", "2"="2", "3"="3", "4"="4", "7"="5", "8"="6", "9"="7"))
baseline_4 <- baseline_4 %>% mutate(ecrrs_spouse_5c = recode(ecrrs_spouse_5, "1"="1", "2"="2", "3"="3", "4"="4", "7"="5", "8"="6", "9"="7"))
baseline_4 <- baseline_4 %>% mutate(ecrrs_spouse_6c = recode(ecrrs_spouse_6, "1"="1", "2"="2", "3"="3", "4"="4", "7"="5", "8"="6", "9"="7"))
baseline_4 <- baseline_4 %>% mutate(ecrrs_spouse_7c = recode(ecrrs_spouse_7, "1"="1", "2"="2", "3"="3", "4"="4", "7"="5", "8"="6", "9"="7"))
baseline_4 <- baseline_4 %>% mutate(ecrrs_spouse_8c = recode(ecrrs_spouse_8, "1"="1", "2"="2", "3"="3", "4"="4", "7"="5", "8"="6", "9"="7"))
baseline_4 <- baseline_4 %>% mutate(ecrrs_spouse_9c = recode(ecrrs_spouse_9, "1"="1", "2"="2", "3"="3", "4"="4", "7"="5", "8"="6", "9"="7"))
baseline_4 <- baseline_4 %>% mutate_at(vars(ecrrs_spouse_1c:ecrrs_spouse_9c), funs(as.numeric))
# Reverse code items 1-4:
baseline_4$ecrrs_spouse_1r <- 8 - baseline_4$ecrrs_spouse_1c
baseline_4$ecrrs_spouse_2r <- 8 - baseline_4$ecrrs_spouse_2c
baseline_4$ecrrs_spouse_3r <- 8 - baseline_4$ecrrs_spouse_3c
baseline_4$ecrrs_spouse_4r <- 8 - baseline_4$ecrrs_spouse_4c
tot_ecrrs_spouse_avoid <- subset(baseline_4, select=c(ecrrs_spouse_1r:ecrrs_spouse_4r, ecrrs_spouse_5c, ecrrs_spouse_6c))
tot_ecrrs_spouse_anx <- subset(baseline_4, select=c(ecrrs_spouse_7c:ecrrs_spouse_9c))
baseline_4$tot_ecrrs_spouse_avoid <- rowMeans(tot_ecrrs_spouse_avoid, na.rm=TRUE)
baseline_4$tot_ecrrs_spouse_anx <- rowMeans(tot_ecrrs_spouse_anx, na.rm=TRUE)
describe(baseline_4$tot_ecrrs_spouse_avoid)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 2.15 1.18 1.67 2.01 0.99 1 5.33 4.33 0.79 -0.45 0.19
describe(baseline_4$tot_ecrrs_spouse_anx)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 2.23 1.56 1.33 1.96 0.49 1 6 5 0.98 -0.35 0.25
# Save your work again
saveRDS(baseline_4, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/baseline_4.rds")
# Create a subset of only scale total scores (i.e., variables that start with "tot")
scales <- baseline_4[, grep('^tot', names(baseline_4))]
# Plot the variables:
for(i in 1:length(scales)) boxplot(scales[,i], xlab=NULL, main=names(scales[i]))
for(i in 1:length(scales)) hist(scales[,i], xlab=NULL, main=names(scales[i]))
# Check out age and timesincedeath as well:
boxplot(baseline_4$age_yrs, main="age_yrs")
boxplot(baseline_4$timesincedeath/365, main="timesincedeath") # in years
hist(baseline_4$age_yrs)
hist(baseline_4$timesincedeath/365) # in years
describe(baseline_4$age_yrs)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 69.22 6.49 70.19 69.38 7.33 57.11 79.73 22.62 -0.22 -1.03 1.03
describe(baseline_4$timesincedeath)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 468.5 248.34 429 433.97 220.17 151 1095 944 1.03 0.06 39.27
Note that there is one participant (D130) whose timesincedeath is <6 months (151 days or ~5 months). Although he was screened 3/31/16 and completed the baseline survey 4/11/16, we waited until 5/18/16 to scan him because of the time criterion, at which point it had been 6.2 months.
# View descriptives for each scale
## stargazer makes nice-looking summary tables (https://cran.r-project.org/web/packages/stargazer/vignettes/stargazer.pdf)
library(stargazer) # install.packages("stargazer") if this is the first time using the package on this machine
Please cite as:
Hlavac, Marek (2018). stargazer: Well-Formatted Regression and Summary Statistics Tables.
R package version 5.2.1. https://CRAN.R-project.org/package=stargazer
stargazer(scales, type="text")
=====================================================
Statistic N Mean St. Dev. Min Max
-----------------------------------------------------
tot_pss 40 12.925 6.750 4 28
tot_ysl 40 67.375 18.786 31 100
tot_icg 40 23.350 12.469 4 51
tot_bdi 40 10.325 7.721 0 28
tot_handedness 40 15.425 5.415 13 39
tot_bisbas_basdr 40 8.950 2.459 4 13
tot_bisbas_basfun 40 9.800 2.221 4 14
tot_bisbas_basrr 40 15.750 2.204 9 19
tot_bisbas_bis 40 19.300 4.096 9 27
tot_bgq 40 9.550 2.275 6 15
tot_ecrrs_global_avoid 40 3.400 1.087 1.000 6.333
tot_ecrrs_global_anx 40 3.242 1.464 1.000 6.333
tot_ecrrs_spouse_avoid 40 2.146 1.176 1.000 5.333
tot_ecrrs_spouse_anx 40 2.225 1.561 1.000 6.000
-----------------------------------------------------
# Make a subset of ONLY variables that are factors
# and print column names (fast way to know exactly which variables to use here)
factors <- baseline_4 %>%
select_if(is.factor)
colnames(factors)
[1] "sex_m" "knowbefore_y" "caretaker_y" "education" "highestdegree"
[6] "employment" "ethnicity_hisp" "race" "meds_y" "majorhealthprobs_y"
[11] "past2wks_injuryinfect_y" "past2wks_dentist_y" "currenttx_y" "postmenopausal_y" "n_livebirths"
[16] "n_nursed" "smoking_y" "smoking_perday" "caffeine_perday" "exercise"
# Frequency tables
# Note below that I've grouped some of the counts to make them more informative, for example highest degree by education or ethnicity_hisp by race
## demographics:
count(baseline_4,sex_m)
count(baseline_4,education,highestdegree)
count(baseline_4,employment)
count(baseline_4,race,ethnicity_hisp)
## medical:
count(baseline_4,meds_y)
count(baseline_4,majorhealthprobs_y)
count(baseline_4,past2wks_injuryinfect_y)
count(baseline_4,past2wks_dentist_y)
count(baseline_4,currenttx_y)
count(baseline_4,postmenopausal_y)
count(baseline_4,n_livebirths)
count(baseline_4,n_nursed)
count(baseline_4,smoking_perday, smoking_y)
count(baseline_4,caffeine_perday)
count(baseline_4,exercise)
## other:
count(baseline_4,knowbefore_y)
count(baseline_4,caretaker_y)
# I can look at n-way frequency tables using count as well, though these are harder to understand
## e.g., look at knowbefore broken down by both sex and race
count(baseline_4,knowbefore_y,sex_m,race)
hist and boxplot won’t work with non-numerical variables, but here’s a code snippet for a basic bar chart for a categorical variable in ggplot:
library(ggplot2)
ggplot(factors, aes(x = baseline$education)) +
geom_bar() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
This will be done together with the baseline added measures (see missing data section under Baseline added measures heading).
# The 'alpha' function is helpful because it will alert you if your reverse coding went awry somehow.
## Note that Emily Butler says it's not always correct - if it flags an issues and you've double- and triple-checked your reverse coding, ignore it.
# Primarily, we use/report the standard alpha.
library(psych)
psych::alpha(tot_pss)
Reliability analysis
Call: psych::alpha(x = tot_pss)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.88 0.88 0.92 0.43 7.7 0.027 1.3 0.67 0.42
lower alpha upper 95% confidence boundaries
0.83 0.88 0.94
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
pss_1 0.88 0.88 0.92 0.45 7.3 0.029 0.024 0.44
pss_2 0.87 0.87 0.91 0.42 6.6 0.031 0.025 0.42
pss_3 0.87 0.87 0.91 0.43 6.8 0.030 0.025 0.42
pss_4r 0.88 0.88 0.92 0.46 7.6 0.028 0.021 0.43
pss_5r 0.86 0.87 0.90 0.42 6.4 0.033 0.023 0.41
pss_6 0.87 0.87 0.92 0.43 6.9 0.031 0.028 0.44
pss_7r 0.87 0.87 0.91 0.43 6.9 0.030 0.025 0.44
pss_8r 0.86 0.86 0.90 0.41 6.4 0.033 0.022 0.42
pss_9 0.88 0.88 0.92 0.46 7.6 0.028 0.025 0.46
pss_10 0.87 0.87 0.91 0.43 6.9 0.030 0.026 0.42
Item statistics
n raw.r std.r r.cor r.drop mean sd
pss_1 40 0.62 0.63 0.59 0.53 1.45 0.90
pss_2 40 0.75 0.76 0.74 0.68 1.38 0.95
pss_3 40 0.71 0.72 0.70 0.63 1.88 0.99
pss_4r 40 0.61 0.59 0.54 0.49 1.07 1.14
pss_5r 40 0.81 0.80 0.80 0.75 1.48 1.09
pss_6 40 0.71 0.71 0.67 0.63 1.27 0.88
pss_7r 40 0.71 0.70 0.68 0.62 0.97 1.00
pss_8r 40 0.81 0.80 0.81 0.76 1.15 0.95
pss_9 40 0.55 0.58 0.51 0.47 1.32 0.76
pss_10 40 0.71 0.71 0.69 0.63 0.95 0.93
Non missing response frequency for each item
0 1 2 3 4 miss
pss_1 0.18 0.28 0.50 0.02 0.02 0
pss_2 0.15 0.48 0.25 0.10 0.02 0
pss_3 0.05 0.35 0.32 0.22 0.05 0
pss_4r 0.40 0.28 0.22 0.05 0.05 0
pss_5r 0.20 0.32 0.32 0.10 0.05 0
pss_6 0.20 0.40 0.32 0.08 0.00 0
pss_7r 0.38 0.38 0.18 0.05 0.02 0
pss_8r 0.22 0.50 0.22 0.00 0.05 0
pss_9 0.12 0.48 0.35 0.05 0.00 0
pss_10 0.42 0.22 0.32 0.02 0.00 0
psych::alpha(tot_ysl)
Reliability analysis
Call: psych::alpha(x = tot_ysl)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.96 0.96 0.99 0.52 23 0.0093 3.2 0.89 0.55
lower alpha upper 95% confidence boundaries
0.94 0.96 0.98
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
ysl_1 0.96 0.96 0.98 0.54 24 0.0093 0.017 0.57
ysl_2 0.95 0.95 0.98 0.51 21 0.0099 0.025 0.54
ysl_3 0.95 0.95 0.98 0.51 21 0.0100 0.025 0.54
ysl_4 0.96 0.96 0.98 0.52 22 0.0097 0.025 0.56
ysl_5 0.95 0.95 0.98 0.51 21 0.0099 0.025 0.54
ysl_6 0.95 0.95 0.98 0.51 21 0.0100 0.025 0.54
ysl_7 0.96 0.96 0.98 0.52 21 0.0097 0.024 0.55
ysl_8 0.95 0.95 0.98 0.51 21 0.0101 0.024 0.54
ysl_9 0.95 0.95 0.98 0.51 21 0.0101 0.024 0.54
ysl_10 0.95 0.95 0.98 0.51 21 0.0101 0.024 0.54
ysl_11 0.95 0.95 0.98 0.51 21 0.0099 0.024 0.54
ysl_12 0.96 0.96 0.98 0.52 22 0.0095 0.025 0.56
ysl_13 0.96 0.96 0.98 0.53 23 0.0092 0.023 0.56
ysl_14 0.95 0.95 0.98 0.51 21 0.0099 0.025 0.54
ysl_15 0.96 0.96 0.98 0.53 23 0.0092 0.024 0.56
ysl_16 0.96 0.96 0.98 0.53 22 0.0094 0.024 0.57
ysl_17 0.95 0.96 0.98 0.52 21 0.0098 0.024 0.54
ysl_18 0.96 0.96 0.98 0.52 22 0.0097 0.025 0.55
ysl_19 0.95 0.95 0.98 0.51 21 0.0099 0.025 0.54
ysl_20 0.95 0.96 0.98 0.51 21 0.0098 0.024 0.55
ysl_21 0.95 0.95 0.98 0.51 21 0.0102 0.023 0.54
Item statistics
n raw.r std.r r.cor r.drop mean sd
ysl_1 40 0.37 0.40 0.39 0.34 4.3 0.74
ysl_2 40 0.80 0.80 0.80 0.77 3.5 1.11
ysl_3 40 0.85 0.85 0.84 0.83 2.4 0.98
ysl_4 40 0.71 0.72 0.72 0.69 2.8 0.89
ysl_5 40 0.79 0.80 0.79 0.77 2.9 1.14
ysl_6 40 0.82 0.82 0.82 0.80 2.9 1.19
ysl_7 40 0.75 0.74 0.73 0.71 3.2 1.62
ysl_8 40 0.82 0.81 0.80 0.79 2.5 1.48
ysl_9 40 0.84 0.83 0.83 0.81 2.7 1.38
ysl_10 40 0.82 0.82 0.82 0.80 2.6 1.34
ysl_11 40 0.79 0.78 0.78 0.76 3.0 1.31
ysl_12 40 0.66 0.66 0.65 0.61 2.7 1.27
ysl_13 40 0.59 0.59 0.58 0.54 3.7 1.26
ysl_14 40 0.80 0.80 0.79 0.78 3.7 1.20
ysl_15 40 0.58 0.59 0.58 0.53 3.8 1.26
ysl_16 40 0.58 0.59 0.58 0.54 4.5 0.85
ysl_17 40 0.76 0.75 0.74 0.73 3.5 1.15
ysl_18 40 0.72 0.72 0.70 0.69 3.0 1.20
ysl_19 40 0.78 0.77 0.77 0.75 3.4 1.13
ysl_20 40 0.77 0.77 0.76 0.74 3.2 1.35
ysl_21 40 0.85 0.84 0.84 0.82 3.2 1.38
Non missing response frequency for each item
1 2 3 4 5 miss
ysl_1 0.00 0.00 0.15 0.35 0.50 0
ysl_2 0.02 0.18 0.28 0.30 0.22 0
ysl_3 0.25 0.22 0.42 0.10 0.00 0
ysl_4 0.08 0.28 0.48 0.15 0.02 0
ysl_5 0.08 0.38 0.25 0.20 0.10 0
ysl_6 0.18 0.20 0.28 0.30 0.05 0
ysl_7 0.22 0.18 0.15 0.10 0.35 0
ysl_8 0.35 0.20 0.20 0.08 0.18 0
ysl_9 0.28 0.18 0.30 0.10 0.15 0
ysl_10 0.28 0.25 0.20 0.18 0.10 0
ysl_11 0.15 0.22 0.30 0.15 0.18 0
ysl_12 0.20 0.30 0.22 0.18 0.10 0
ysl_13 0.08 0.10 0.22 0.25 0.35 0
ysl_14 0.05 0.10 0.30 0.20 0.35 0
ysl_15 0.02 0.18 0.20 0.15 0.45 0
ysl_16 0.00 0.02 0.15 0.15 0.68 0
ysl_17 0.05 0.15 0.32 0.25 0.22 0
ysl_18 0.10 0.28 0.20 0.32 0.10 0
ysl_19 0.05 0.15 0.35 0.25 0.20 0
ysl_20 0.10 0.25 0.20 0.20 0.25 0
ysl_21 0.18 0.12 0.25 0.25 0.20 0
psych::alpha(tot_icg)
Reliability analysis
Call: psych::alpha(x = tot_icg)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.92 0.92 0.96 0.37 11 0.017 1.2 0.66 0.35
lower alpha upper 95% confidence boundaries
0.89 0.92 0.95
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
icg_1 0.91 0.91 0.95 0.35 9.8 0.019 0.036 0.33
icg_2 0.92 0.91 0.96 0.37 10.5 0.018 0.039 0.34
icg_3 0.91 0.91 0.95 0.35 9.8 0.019 0.037 0.33
icg_4 0.92 0.91 0.96 0.36 10.2 0.018 0.041 0.33
icg_5 0.92 0.92 0.96 0.38 11.2 0.017 0.040 0.37
icg_6 0.91 0.91 0.95 0.36 10.2 0.018 0.038 0.33
icg_7 0.91 0.91 0.95 0.35 9.9 0.019 0.037 0.33
icg_8 0.91 0.91 0.96 0.36 10.0 0.018 0.039 0.33
icg_9 0.91 0.91 0.95 0.36 10.0 0.018 0.040 0.34
icg_10 0.92 0.91 0.96 0.36 10.2 0.018 0.041 0.34
icg_11 0.92 0.92 0.96 0.39 11.7 0.017 0.035 0.37
icg_12 0.92 0.92 0.96 0.39 11.4 0.017 0.039 0.38
icg_13 0.91 0.91 0.96 0.35 9.8 0.019 0.039 0.33
icg_14 0.92 0.92 0.95 0.39 11.3 0.016 0.037 0.37
icg_15 0.92 0.92 0.95 0.38 11.1 0.017 0.039 0.37
icg_16 0.92 0.91 0.96 0.36 10.3 0.018 0.041 0.33
icg_17 0.92 0.91 0.96 0.37 10.4 0.018 0.039 0.34
icg_18 0.92 0.91 0.96 0.37 10.7 0.017 0.042 0.36
icg_19 0.91 0.91 0.95 0.36 10.1 0.018 0.040 0.33
Item statistics
n raw.r std.r r.cor r.drop mean sd
icg_1 40 0.82 0.81 0.81 0.80 1.40 0.87
icg_2 40 0.63 0.62 0.61 0.58 1.82 0.96
icg_3 40 0.83 0.82 0.82 0.80 1.20 1.18
icg_4 40 0.70 0.71 0.70 0.65 2.50 1.15
icg_5 40 0.42 0.43 0.39 0.36 1.85 0.92
icg_6 40 0.73 0.71 0.71 0.68 1.48 1.18
icg_7 40 0.80 0.79 0.79 0.76 1.65 1.14
icg_8 40 0.76 0.76 0.76 0.72 1.38 1.08
icg_9 40 0.74 0.75 0.75 0.71 0.70 0.76
icg_10 40 0.68 0.70 0.69 0.64 0.88 0.94
icg_11 40 0.24 0.28 0.23 0.19 0.25 0.54
icg_12 40 0.37 0.38 0.33 0.30 0.72 0.91
icg_13 40 0.82 0.81 0.80 0.78 1.95 1.26
icg_14 40 0.37 0.39 0.37 0.30 0.68 0.94
icg_15 40 0.44 0.46 0.45 0.38 0.38 0.87
icg_16 40 0.69 0.68 0.66 0.63 0.75 1.21
icg_17 40 0.67 0.66 0.65 0.62 0.88 1.09
icg_18 40 0.56 0.56 0.54 0.50 0.90 1.08
icg_19 40 0.73 0.72 0.72 0.69 2.00 1.06
Non missing response frequency for each item
0 1 2 3 4 miss
icg_1 0.15 0.40 0.35 0.10 0.00 0
icg_2 0.08 0.30 0.38 0.22 0.02 0
icg_3 0.38 0.22 0.28 0.08 0.05 0
icg_4 0.08 0.10 0.28 0.35 0.20 0
icg_5 0.05 0.30 0.45 0.15 0.05 0
icg_6 0.25 0.28 0.28 0.15 0.05 0
icg_7 0.18 0.30 0.28 0.20 0.05 0
icg_8 0.25 0.30 0.30 0.12 0.02 0
icg_9 0.48 0.35 0.18 0.00 0.00 0
icg_10 0.42 0.35 0.15 0.08 0.00 0
icg_11 0.80 0.15 0.05 0.00 0.00 0
icg_12 0.52 0.28 0.15 0.05 0.00 0
icg_13 0.12 0.28 0.28 0.18 0.15 0
icg_14 0.57 0.22 0.18 0.00 0.02 0
icg_15 0.80 0.08 0.10 0.00 0.02 0
icg_16 0.65 0.12 0.10 0.08 0.05 0
icg_17 0.52 0.18 0.22 0.05 0.02 0
icg_18 0.50 0.22 0.15 0.12 0.00 0
icg_19 0.08 0.25 0.35 0.25 0.08 0
psych::alpha(tot_bgq)
Reliability analysis
Call: psych::alpha(x = tot_bgq)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.71 0.72 0.73 0.34 2.5 0.071 1.9 0.46 0.31
lower alpha upper 95% confidence boundaries
0.57 0.71 0.85
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
bgq_1 0.62 0.63 0.61 0.30 1.7 0.095 0.030 0.33
bgq_2 0.56 0.55 0.51 0.24 1.2 0.110 0.015 0.28
bgq_3 0.72 0.73 0.73 0.41 2.8 0.073 0.028 0.33
bgq_4 0.67 0.67 0.68 0.34 2.0 0.084 0.052 0.31
bgq_5 0.72 0.73 0.72 0.40 2.7 0.070 0.033 0.35
Item statistics
n raw.r std.r r.cor r.drop mean sd
bgq_1 40 0.76 0.75 0.72 0.56 1.9 0.71
bgq_2 40 0.85 0.86 0.88 0.74 2.1 0.62
bgq_3 40 0.49 0.56 0.38 0.29 2.0 0.51
bgq_4 40 0.69 0.68 0.55 0.47 1.8 0.71
bgq_5 40 0.62 0.57 0.39 0.34 1.7 0.76
Non missing response frequency for each item
1 2 3 miss
bgq_1 0.28 0.50 0.22 0
bgq_2 0.15 0.62 0.22 0
bgq_3 0.12 0.75 0.12 0
bgq_4 0.35 0.48 0.18 0
bgq_5 0.48 0.35 0.18 0
psych::alpha(tot_bdi)
Reliability analysis
Call: psych::alpha(x = tot_bdi)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.9 0.9 0.97 0.31 9.4 0.022 0.5 0.37 0.31
lower alpha upper 95% confidence boundaries
0.85 0.9 0.94
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
bdi_1c 0.89 0.90 0.97 0.31 8.9 0.023 0.036 0.31
bdi_2c 0.89 0.90 0.97 0.31 9.1 0.023 0.036 0.31
bdi_3c 0.90 0.90 0.97 0.32 9.5 0.022 0.033 0.33
bdi_4c 0.89 0.90 0.97 0.30 8.5 0.025 0.034 0.30
bdi_5c 0.89 0.90 0.97 0.31 8.8 0.023 0.036 0.30
bdi_6c 0.90 0.91 0.97 0.33 9.7 0.022 0.031 0.34
bdi_7c 0.89 0.90 0.97 0.30 8.7 0.024 0.035 0.30
bdi_8c 0.89 0.90 0.97 0.31 8.9 0.023 0.036 0.31
bdi_9c 0.90 0.90 0.97 0.31 9.1 0.023 0.035 0.32
bdi_10c 0.89 0.90 0.97 0.30 8.7 0.024 0.035 0.30
bdi_11c 0.90 0.90 0.97 0.32 9.3 0.023 0.035 0.33
bdi_12c 0.88 0.89 0.97 0.29 8.3 0.026 0.032 0.30
bdi_13c 0.89 0.90 0.97 0.31 9.1 0.023 0.035 0.31
bdi_14c 0.89 0.90 0.96 0.31 8.8 0.024 0.035 0.30
bdi_15c 0.89 0.90 0.96 0.30 8.6 0.025 0.035 0.30
bdi_16c 0.89 0.90 0.97 0.31 8.9 0.023 0.037 0.31
bdi_17c 0.89 0.90 0.97 0.31 9.0 0.023 0.035 0.31
bdi_18c 0.90 0.91 0.97 0.33 9.8 0.022 0.033 0.35
bdi_19c 0.89 0.90 0.97 0.31 8.9 0.024 0.033 0.30
bdi_20c 0.89 0.90 0.97 0.30 8.7 0.025 0.034 0.30
bdi_21c 0.91 0.91 0.97 0.32 9.6 0.020 0.033 0.33
Item statistics
n raw.r std.r r.cor r.drop mean sd
bdi_1c 39 0.59 0.61 0.60 0.54 0.41 0.50
bdi_2c 40 0.55 0.56 0.56 0.48 0.35 0.62
bdi_3c 40 0.35 0.40 0.38 0.28 0.23 0.48
bdi_4c 40 0.76 0.75 0.75 0.72 0.78 0.70
bdi_5c 40 0.61 0.64 0.63 0.56 0.42 0.50
bdi_6c 40 0.30 0.35 0.33 0.26 0.10 0.38
bdi_7c 39 0.64 0.68 0.68 0.59 0.31 0.66
bdi_8c 39 0.64 0.63 0.63 0.57 0.31 0.52
bdi_9c 39 0.50 0.54 0.54 0.47 0.13 0.34
bdi_10c 40 0.71 0.71 0.71 0.67 0.65 0.62
bdi_11c 40 0.49 0.48 0.46 0.42 0.53 0.60
bdi_12c 40 0.87 0.85 0.85 0.84 0.62 0.84
bdi_13c 39 0.57 0.53 0.52 0.50 0.64 0.74
bdi_14c 40 0.64 0.66 0.66 0.59 0.38 0.63
bdi_15c 39 0.79 0.74 0.74 0.71 0.54 0.72
bdi_16c 40 0.61 0.61 0.59 0.55 0.75 0.67
bdi_17c 40 0.55 0.57 0.57 0.50 0.23 0.48
bdi_18c 40 0.29 0.29 0.26 0.22 0.62 0.67
bdi_19c 39 0.64 0.62 0.61 0.59 0.62 0.63
bdi_20c 40 0.75 0.71 0.71 0.70 0.65 0.66
bdi_21c 40 0.45 0.38 0.36 0.33 1.15 1.14
Non missing response frequency for each item
0 1 2 3 miss
bdi_1c 0.59 0.41 0.00 0.00 0.03
bdi_2c 0.72 0.20 0.08 0.00 0.00
bdi_3c 0.80 0.18 0.02 0.00 0.00
bdi_4c 0.35 0.55 0.08 0.02 0.00
bdi_5c 0.57 0.42 0.00 0.00 0.00
bdi_6c 0.92 0.05 0.02 0.00 0.00
bdi_7c 0.79 0.10 0.10 0.00 0.03
bdi_8c 0.72 0.26 0.03 0.00 0.03
bdi_9c 0.87 0.13 0.00 0.00 0.03
bdi_10c 0.40 0.57 0.00 0.02 0.00
bdi_11c 0.52 0.42 0.05 0.00 0.00
bdi_12c 0.55 0.32 0.08 0.05 0.00
bdi_13c 0.51 0.33 0.15 0.00 0.03
bdi_14c 0.70 0.22 0.08 0.00 0.00
bdi_15c 0.59 0.28 0.13 0.00 0.03
bdi_16c 0.38 0.50 0.12 0.00 0.00
bdi_17c 0.80 0.18 0.02 0.00 0.00
bdi_18c 0.45 0.50 0.02 0.02 0.00
bdi_19c 0.46 0.46 0.08 0.00 0.03
bdi_20c 0.45 0.45 0.10 0.00 0.00
bdi_21c 0.42 0.15 0.28 0.15 0.00
psych::alpha(tot_handedness)
Matrix was not positive definite, smoothing was doneIn factor.stats, I could not find the RMSEA upper bound . Sorry about that
Matrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was done
Reliability analysis
Call: psych::alpha(x = tot_handedness)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.94 0.94 0.99 0.57 17 0.013 1.2 0.42 0.59
lower alpha upper 95% confidence boundaries
0.92 0.94 0.97
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
hand_1c 0.93 0.94 0.98 0.55 14 0.016 0.029 0.55
hand_2c 0.93 0.94 0.98 0.55 14 0.016 0.029 0.55
hand_3c 0.94 0.94 0.97 0.57 16 0.014 0.033 0.60
hand_4c 0.94 0.94 0.98 0.58 16 0.014 0.030 0.60
hand_5c 0.93 0.94 0.98 0.55 14 0.016 0.030 0.57
hand_6c 0.93 0.94 0.98 0.56 15 0.015 0.034 0.59
hand_7c 0.94 0.95 0.98 0.59 17 0.013 0.031 0.60
hand_8c 0.93 0.94 0.98 0.55 15 0.015 0.031 0.58
hand_9c 0.94 0.94 0.98 0.58 16 0.014 0.030 0.60
hand_10c 0.94 0.94 0.99 0.58 16 0.014 0.036 0.60
hand_11c 0.94 0.94 0.98 0.58 16 0.014 0.032 0.59
hand_12c 0.94 0.94 0.98 0.57 16 0.014 0.033 0.58
hand_bat_1c 0.94 0.94 0.99 0.58 16 0.013 0.034 0.60
Item statistics
n raw.r std.r r.cor r.drop mean sd
hand_1c 40 0.92 0.91 0.91 0.90 1.1 0.53
hand_2c 40 0.92 0.91 0.91 0.90 1.1 0.53
hand_3c 39 0.73 0.77 0.77 0.70 1.2 0.43
hand_4c 40 0.72 0.71 0.72 0.67 1.1 0.53
hand_5c 40 0.91 0.90 0.90 0.89 1.2 0.55
hand_6c 40 0.83 0.82 0.81 0.79 1.3 0.65
hand_7c 40 0.58 0.61 0.60 0.52 1.1 0.43
hand_8c 40 0.87 0.86 0.86 0.84 1.2 0.58
hand_9c 40 0.72 0.71 0.72 0.67 1.1 0.53
hand_10c 40 0.67 0.70 0.67 0.63 1.1 0.35
hand_11c 40 0.70 0.70 0.69 0.64 1.2 0.55
hand_12c 40 0.76 0.77 0.76 0.71 1.2 0.53
hand_bat_1c 40 0.72 0.70 0.67 0.64 1.4 0.77
Non missing response frequency for each item
1 2 3 miss
hand_1c 0.92 0.00 0.08 0.00
hand_2c 0.92 0.00 0.08 0.00
hand_3c 0.87 0.10 0.03 0.03
hand_4c 0.92 0.00 0.08 0.00
hand_5c 0.90 0.02 0.08 0.00
hand_6c 0.80 0.10 0.10 0.00
hand_7c 0.88 0.10 0.02 0.00
hand_8c 0.85 0.08 0.08 0.00
hand_9c 0.92 0.00 0.08 0.00
hand_10c 0.95 0.02 0.02 0.00
hand_11c 0.90 0.02 0.08 0.00
hand_12c 0.82 0.12 0.05 0.00
hand_bat_1c 0.80 0.02 0.18 0.00
psych::alpha(tot_bis)
Reliability analysis
Call: psych::alpha(x = tot_bis)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.83 0.83 0.84 0.41 4.8 0.042 2.8 0.59 0.43
lower alpha upper 95% confidence boundaries
0.74 0.83 0.91
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
bisbas_2 0.81 0.81 0.82 0.41 4.2 0.048 0.0181 0.48
bisbas_8r 0.80 0.80 0.81 0.40 4.0 0.049 0.0160 0.43
bisbas_13r 0.79 0.79 0.79 0.39 3.8 0.051 0.0161 0.38
bisbas_16r 0.80 0.80 0.81 0.40 4.0 0.050 0.0145 0.38
bisbas_19r 0.80 0.80 0.80 0.40 4.1 0.049 0.0099 0.41
bisbas_22 0.83 0.83 0.82 0.45 5.0 0.043 0.0068 0.49
bisbas_24r 0.80 0.80 0.80 0.41 4.1 0.049 0.0165 0.43
Item statistics
n raw.r std.r r.cor r.drop mean sd
bisbas_2 40 0.72 0.69 0.61 0.56 2.6 1.01
bisbas_8r 40 0.71 0.73 0.67 0.60 3.1 0.78
bisbas_13r 40 0.76 0.77 0.73 0.65 3.0 0.78
bisbas_16r 40 0.73 0.73 0.68 0.61 2.4 0.78
bisbas_19r 40 0.71 0.72 0.68 0.59 3.2 0.81
bisbas_22 40 0.57 0.57 0.48 0.41 2.2 0.81
bisbas_24r 40 0.72 0.71 0.65 0.59 2.8 0.87
Non missing response frequency for each item
1 2 3 4 miss
bisbas_2 0.15 0.32 0.30 0.22 0
bisbas_8r 0.02 0.18 0.48 0.32 0
bisbas_13r 0.05 0.18 0.55 0.22 0
bisbas_16r 0.12 0.40 0.42 0.05 0
bisbas_19r 0.05 0.08 0.45 0.42 0
bisbas_22 0.15 0.52 0.25 0.08 0
bisbas_24r 0.10 0.22 0.50 0.18 0
psych::alpha(tot_basdr)
Reliability analysis
Call: psych::alpha(x = tot_basdr)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.75 0.76 0.74 0.44 3.1 0.065 2.2 0.61 0.4
lower alpha upper 95% confidence boundaries
0.62 0.75 0.88
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
bisbas_3r 0.69 0.71 0.66 0.45 2.5 0.087 0.029 0.43
bisbas_9r 0.68 0.67 0.60 0.41 2.0 0.087 0.018 0.37
bisbas_12r 0.69 0.71 0.65 0.45 2.4 0.087 0.026 0.37
bisbas_21r 0.70 0.70 0.63 0.44 2.4 0.078 0.011 0.43
Item statistics
n raw.r std.r r.cor r.drop mean sd
bisbas_3r 40 0.78 0.75 0.62 0.55 2.4 0.90
bisbas_9r 40 0.75 0.79 0.71 0.59 2.5 0.68
bisbas_12r 40 0.78 0.75 0.63 0.55 2.4 0.90
bisbas_21r 40 0.73 0.76 0.66 0.52 1.7 0.76
Non missing response frequency for each item
1 2 3 4 miss
bisbas_3r 0.20 0.30 0.42 0.08 0
bisbas_9r 0.05 0.42 0.48 0.05 0
bisbas_12r 0.18 0.38 0.35 0.10 0
bisbas_21r 0.50 0.32 0.18 0.00 0
psych::alpha(tot_basfun)
Reliability analysis
Call: psych::alpha(x = tot_basfun)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.69 0.69 0.68 0.36 2.3 0.08 2.5 0.59 0.29
lower alpha upper 95% confidence boundaries
0.54 0.69 0.85
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
bisbas_5r 0.54 0.54 0.44 0.28 1.2 0.125 1.3e-04 0.29
bisbas_10r 0.56 0.56 0.46 0.30 1.3 0.121 7.1e-05 0.29
bisbas_15r 0.69 0.69 0.66 0.43 2.2 0.088 6.2e-02 0.29
bisbas_20r 0.70 0.70 0.67 0.44 2.3 0.084 5.8e-02 0.31
Item statistics
n raw.r std.r r.cor r.drop mean sd
bisbas_5r 40 0.80 0.80 0.77 0.61 3.2 0.79
bisbas_10r 40 0.79 0.79 0.75 0.58 2.7 0.79
bisbas_15r 39 0.66 0.65 0.43 0.38 2.0 0.78
bisbas_20r 40 0.65 0.64 0.42 0.36 2.0 0.80
Non missing response frequency for each item
1 2 3 4 miss
bisbas_5r 0.02 0.15 0.42 0.40 0.00
bisbas_10r 0.05 0.35 0.45 0.15 0.00
bisbas_15r 0.31 0.41 0.28 0.00 0.03
bisbas_20r 0.30 0.45 0.22 0.02 0.00
psych::alpha(tot_basrr)
Reliability analysis
Call: psych::alpha(x = tot_basrr)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.69 0.7 0.67 0.32 2.3 0.075 3.1 0.44 0.33
lower alpha upper 95% confidence boundaries
0.55 0.69 0.84
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
bisbas_4r 0.63 0.63 0.59 0.30 1.7 0.093 0.0103 0.30
bisbas_7r 0.64 0.66 0.60 0.32 1.9 0.091 0.0041 0.33
bisbas_14r 0.63 0.64 0.59 0.31 1.8 0.091 0.0070 0.33
bisbas_18r 0.66 0.68 0.62 0.34 2.1 0.087 0.0051 0.34
bisbas_23r 0.65 0.65 0.60 0.32 1.9 0.089 0.0116 0.33
Item statistics
n raw.r std.r r.cor r.drop mean sd
bisbas_4r 40 0.70 0.71 0.60 0.49 3.5 0.64
bisbas_7r 40 0.66 0.66 0.55 0.45 3.3 0.60
bisbas_14r 40 0.68 0.69 0.59 0.47 2.6 0.63
bisbas_18r 40 0.60 0.63 0.48 0.40 3.3 0.55
bisbas_23r 40 0.73 0.68 0.55 0.45 3.1 0.83
Non missing response frequency for each item
1 2 3 4 miss
bisbas_4r 0.02 0.00 0.40 0.57 0
bisbas_7r 0.00 0.08 0.57 0.35 0
bisbas_14r 0.02 0.40 0.52 0.05 0
bisbas_18r 0.00 0.05 0.62 0.32 0
bisbas_23r 0.05 0.15 0.48 0.32 0
psych::alpha(tot_ecrrs_spouse_avoid)
Reliability analysis
Call: psych::alpha(x = tot_ecrrs_spouse_avoid)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.91 0.93 0.95 0.69 13 0.023 2.1 1.2 0.68
lower alpha upper 95% confidence boundaries
0.87 0.91 0.96
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
ecrrs_spouse_1r 0.88 0.90 0.92 0.64 8.9 0.032 0.024 0.62
ecrrs_spouse_2r 0.89 0.91 0.93 0.67 10.0 0.028 0.021 0.66
ecrrs_spouse_3r 0.89 0.91 0.93 0.66 9.5 0.029 0.025 0.63
ecrrs_spouse_4r 0.90 0.92 0.94 0.70 11.5 0.027 0.029 0.66
ecrrs_spouse_5c 0.93 0.94 0.96 0.76 16.2 0.019 0.020 0.77
ecrrs_spouse_6c 0.90 0.93 0.94 0.72 12.7 0.028 0.036 0.77
Item statistics
n raw.r std.r r.cor r.drop mean sd
ecrrs_spouse_1r 40 0.94 0.96 0.97 0.92 2.0 1.2
ecrrs_spouse_2r 40 0.87 0.91 0.91 0.83 1.9 1.1
ecrrs_spouse_3r 40 0.90 0.93 0.93 0.87 1.8 1.1
ecrrs_spouse_4r 40 0.83 0.85 0.82 0.75 2.0 1.4
ecrrs_spouse_5c 40 0.77 0.72 0.64 0.62 2.7 1.9
ecrrs_spouse_6c 40 0.83 0.81 0.77 0.74 2.3 1.6
Non missing response frequency for each item
1 2 3 4 5 6 7 miss
ecrrs_spouse_1r 0.42 0.30 0.12 0.12 0.00 0.02 0.00 0
ecrrs_spouse_2r 0.42 0.40 0.05 0.10 0.00 0.02 0.00 0
ecrrs_spouse_3r 0.50 0.32 0.05 0.10 0.02 0.00 0.00 0
ecrrs_spouse_4r 0.50 0.22 0.10 0.12 0.02 0.00 0.02 0
ecrrs_spouse_5c 0.38 0.22 0.02 0.20 0.05 0.10 0.02 0
ecrrs_spouse_6c 0.48 0.22 0.00 0.15 0.12 0.02 0.00 0
psych::alpha(tot_ecrrs_spouse_anx)
Reliability analysis
Call: psych::alpha(x = tot_ecrrs_spouse_anx)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.86 0.87 0.85 0.68 6.4 0.04 2.2 1.6 0.64
lower alpha upper 95% confidence boundaries
0.78 0.86 0.94
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
ecrrs_spouse_7c 0.92 0.92 0.86 0.86 12.2 0.024 NA 0.86
ecrrs_spouse_8c 0.70 0.71 0.55 0.55 2.4 0.092 NA 0.55
ecrrs_spouse_9c 0.78 0.78 0.64 0.64 3.5 0.070 NA 0.64
Item statistics
n raw.r std.r r.cor r.drop mean sd
ecrrs_spouse_7c 40 0.83 0.82 0.65 0.62 2.2 1.9
ecrrs_spouse_8c 40 0.93 0.94 0.93 0.84 2.3 1.8
ecrrs_spouse_9c 40 0.89 0.90 0.88 0.77 2.1 1.6
Non missing response frequency for each item
1 2 3 4 5 6 7 miss
ecrrs_spouse_7c 0.57 0.15 0.02 0.08 0.10 0.02 0.05 0
ecrrs_spouse_8c 0.52 0.18 0.00 0.15 0.08 0.05 0.02 0
ecrrs_spouse_9c 0.57 0.18 0.00 0.15 0.02 0.08 0.00 0
# save the cleaned data
saveRDS(baseline_4, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/baseline.rds")
write.csv(baseline_4, file = "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/baseline.csv")
# 'haven' package should allow you to save as .sav file but won't work for me - file is blank when I open it in spss
# 'foreign' package hasn't worked either - may be compatibility issue with newer versions of SPSS?
This section of the script deals with the “post” addendum to the baseline survey, containing additional trait measures that participants completed at home after they finished their two experimental sessions. Ultimately, these data will be merged with the baseline dataset.
What has been done up to this point: (1) codebook created, (2) data exported from Qualtrics.
Task: Import data from CSV file except for the first 17 columns (1:17 is just Qualtrics junk).
# run install.packages("tidyverse") if this is the first time using dplyr on your local machine
library(dplyr)
filter <- dplyr::filter
select <- dplyr::select
baseline_post <- read.csv("~/Dropbox/GLASS Lab/OT Study/data/raw-data/OT+fMRI+Post_January+18%2C+2019_14.24.csv", stringsAsFactors = FALSE, na.strings="")[ ,-c(2:17)]
# na.strings = "" replaces all instances where missing data is represented by blank cells with NA, which is how R handles missing values.
View(baseline_post)
Note that we need to correct some of the IDs to match the baseline dataset so that the two datasets can ultimately be merged.
# Found some duplicate IDs:
# Duplicate IDs with non-duplicated data: D131 (row 31 blank), D145 (row 43 blank)
# Duplicate IDs with duplicated data: D130 (looks like data was entered 2x? lines 33 and 49)
baseline_post <- baseline_post %>% filter(!grepl("2016-05-23 06:48:13", StartDate)) %>%
filter(!grepl("2016-10-19 19:26:04", StartDate)) %>%
filter(!grepl("2016-06-13 15:35:02", StartDate))
# drop those rows based on their value in StartDate, then get rid of StartDate
baseline_post$StartDate <- NULL
# Also corrected some of the IDs so that data can ultimately be merged by ID:
baseline_post <- baseline_post %>% mutate(ID = as.character(recode(ID, ":D101" = "D101",
"d104" = "D104",
"D121_b" = "D121",
"D117_c" = "D117",
"D 120" = "D120",
"D128 (entered from hard copy by SS 4/13/16)" = "D128",
"D130 [entered from hard copy by SS 6/13/16, survey postmarked 5/31/16]" = "D130"
)))
baseline_post_0 <- baseline_post %>% filter(grepl("^D1", ID, ignore.case = TRUE))
View(baseline_post_0)
# Now we have 40 observations of 150 variables, instead of 49.
The name to the left of the equal sign is the new name, the one on the right is what the variable was named in Qualtrics.
baseline_post_1 <- rename(baseline_post_0, ID = ID, ucla_loneliness_1 = UCLA_1.20_1,
ucla_loneliness_2 = UCLA_1.20_2,
ucla_loneliness_3 = UCLA_1.20_3,
ucla_loneliness_4 = UCLA_1.20_4,
ucla_loneliness_5 = UCLA_1.20_5,
ucla_loneliness_6 = UCLA_1.20_6,
ucla_loneliness_7 = UCLA_1.20_7,
ucla_loneliness_8 = UCLA_1.20_8,
ucla_loneliness_9 = UCLA_1.20_9,
ucla_loneliness_10 = UCLA_1.20_10,
ucla_loneliness_11 = UCLA_1.20_11,
ucla_loneliness_12 = UCLA_1.20_12,
ucla_loneliness_13 = UCLA_1.20_13,
ucla_loneliness_14 = UCLA_1.20_14,
ucla_loneliness_15 = UCLA_1.20_15,
ucla_loneliness_16 = UCLA_1.20_16,
ucla_loneliness_17 = UCLA_1.20_17,
ucla_loneliness_18 = UCLA_1.20_18,
ucla_loneliness_19 = UCLA_1.20_19,
ucla_loneliness_20 = UCLA_1.20_20,
gcq_1 = GCS.1.38_1,
gcq_2 = GCS.1.38_2,
gcq_3 = GCS.1.38_3,
gcq_4 = GCS.1.38_4,
gcq_5 = GCS.1.38_5,
gcq_6 = GCS.1.38_6,
gcq_7 = GCS.1.38_7,
gcq_8 = GCS.1.38_8,
gcq_9 = GCS.1.38_9,
gcq_10 = GCS.1.38_10,
gcq_11 = GCS.1.38_11,
gcq_12 = GCS.1.38_12,
gcq_13 = GCS.1.38_13,
gcq_14 = GCS.1.38_14,
gcq_15 = GCS.1.38_15,
gcq_16 = GCS.1.38_16,
gcq_17 = GCS.1.38_17,
gcq_18 = GCS.1.38_18,
gcq_19 = GCS.1.38_19,
gcq_20 = GCS.1.38_20,
gcq_21 = GCS.1.38_21,
gcq_22 = GCS.1.38_22,
gcq_23 = GCS.1.38_23,
gcq_24 = GCS.1.38_24,
gcq_25 = GCS.1.38_25,
gcq_26 = GCS.1.38_26,
gcq_27 = GCS.1.38_27,
gcq_28 = GCS.1.38_28,
gcq_29 = GCS.1.38_29,
gcq_30 = GCS.1.38_30,
gcq_31 = GCS.1.38_31,
gcq_32 = GCS.1.38_32,
gcq_33 = GCS.1.38_33,
gcq_34 = GCS.1.38_34,
gcq_35 = GCS.1.38_35,
gcq_36 = GCS.1.38_36,
gcq_37 = GCS.1.38_37,
gcq_38 = GCS.1.38_38,
srrs_1 = LES.1.51_1,
srrs_2 = LES.1.51_2,
srrs_3 = LES.1.51_3,
srrs_4 = LES.1.51_4,
srrs_5 = LES.1.51_5,
srrs_6 = LES.1.51_6,
srrs_7 = LES.1.51_7,
srrs_8 = LES.1.51_8,
srrs_9 = LES.1.51_9,
srrs_10 = LES.1.51_10,
srrs_11 = LES.1.51_11,
srrs_12 = LES.1.51_12,
srrs_13 = LES.1.51_13,
srrs_14 = LES.1.51_14,
srrs_15 = LES.1.51_15,
srrs_16 = LES.1.51_16,
srrs_17 = LES.1.51_17,
srrs_18 = LES.1.51_18,
srrs_19 = LES.1.51_19,
srrs_20 = LES.1.51_20,
srrs_21 = LES.1.51_21,
srrs_22 = LES.1.51_22,
srrs_23 = LES.1.51_23,
srrs_24 = LES.1.51_24,
srrs_25 = LES.1.51_25,
srrs_26 = LES.1.51_26,
srrs_27 = LES.1.51_27,
srrs_28 = LES.1.51_28,
srrs_29 = LES.1.51_29,
srrs_30 = LES.1.51_30,
srrs_31 = LES.1.51_31,
srrs_32 = LES.1.51_32,
srrs_33 = LES.1.51_33,
srrs_34 = LES.1.51_34,
srrs_35 = LES.1.51_35,
srrs_36 = LES.1.51_36,
srrs_37 = LES.1.51_37,
srrs_38 = LES.1.51_38,
srrs_39 = LES.1.51_39,
srrs_40 = LES.1.51_40,
srrs_41 = LES.1.51_41,
srrs_42 = LES.1.51_42,
srrs_43 = LES.1.51_43,
srrs_44 = LES.1.51_44,
srrs_45 = LES.1.51_45,
srrs_46 = LES.1.51_46,
srrs_47 = LES.1.51_47,
srrs_48 = LES.1.51_48,
srrs_49 = LES.1.51_49,
srrs_50 = LES.1.51_50,
srrs_51 = LES.1.51_51,
ppss_fr_1 = PPSS.Fr_1,
ppss_fr_2 = PPSS.Fr_2,
ppss_fr_3 = PPSS.Fr_3,
ppss_fr_4 = PPSS.Fr_4,
ppss_fr_5 = PPSS.Fr_5,
ppss_fr_6 = PPSS.Fr_6,
ppss_fr_7 = PPSS.Fr_7,
ppss_fr_8 = PPSS.Fr_8,
ppss_fr_9 = PPSS.Fr_9,
ppss_fr_10 = PPSS.Fr_10,
ppss_fr_11 = PPSS.Fr_11,
ppss_fr_12 = PPSS.Fr_12,
ppss_fr_13 = PPSS.Fr_13,
ppss_fr_14 = PPSS.Fr_14,
ppss_fr_15 = PPSS.Fr_15,
ppss_fr_16 = PPSS.Fr_16,
ppss_fr_17 = PPSS.Fr_21,
ppss_fr_18 = PPSS.Fr_17,
ppss_fr_19 = PPSS.Fr_18,
ppss_fr_20 = PPSS.Fr_19,
ppss_fa_1 = PPSS.Fa_1,
ppss_fa_2 = PPSS.Fa_14,
ppss_fa_3 = PPSS.Fa_2,
ppss_fa_4 = PPSS.Fa_15,
ppss_fa_5 = PPSS.Fa_3,
ppss_fa_6 = PPSS.Fa_27,
ppss_fa_7 = PPSS.Fa_4,
ppss_fa_8 = PPSS.Fa_5,
ppss_fa_9 = PPSS.Fa_8,
ppss_fa_10 = PPSS.Fa_9,
ppss_fa_11 = PPSS.Fa_10,
ppss_fa_12 = PPSS.Fa_11,
ppss_fa_13 = PPSS.Fa_12,
ppss_fa_14 = PPSS.Fa_13,
ppss_fa_15 = PPSS.Fa_6,
ppss_fa_16 = PPSS.Fa_28,
ppss_fa_17 = PPSS.Fa_16,
ppss_fa_18 = PPSS.Fa_21,
ppss_fa_19 = PPSS.Fa_17,
ppss_fa_20 = PPSS.Fa_19
)
# Finally, let's make all of the variables (except ID) numeric rather than chr.
colnames(baseline_post_1)
baseline_post_1 <- baseline_post_1 %>% mutate_at(vars(ucla_loneliness_1:ppss_fa_20), funs(as.numeric))
# Check it out:
colnames(baseline_post_1)
# R data format (.rds) preserves data structures, such as column data types (numeric, character or factor).
saveRDS(baseline_post_1, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/baseline_post_1.rds")
# baseline_post_1 <- readRDS("~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/baseline_post_1.rds")
# The only variables we need to make into factors are the SRRS variables, in which participants indicate yes or no to each stressful life event.
labels_yn <- c("No", "Yes")
levels_yn <- c("2", "1")
baseline_post_2 <- baseline_post_1 %>% mutate_at(vars(starts_with("SR")),
funs(factor(., levels = levels_yn, labels = labels_yn, ordered = TRUE)))
# this is an ordered factor with two levels: "No" [1] < "Yes" [2]
# confirm that 1's in post_1 are 2's in post_2 and vice versa:
str(baseline_post_2$srrs_1)
Ord.factor w/ 2 levels "No"<"Yes": 1 2 1 2 1 2 1 1 1 2 ...
str(baseline_post_1$srrs_1)
num [1:40] 2 1 2 1 2 1 2 2 2 1 ...
# Another way to do this would be to make each item a factor where "no" = 0 and "yes" = whatever the rating is
write.csv(baseline_post_2, file = "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/baseline_post_2.csv")
saveRDS(baseline_post_2, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/baseline_post_2.rds")
# baseline_post_2 <- readRDS("~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/baseline_post_2.rds")
# For this section, you'll need the 'psych' package
## install.packages("psych") if you don't have it on this machine
library(psych)
baseline_post_3 <- baseline_post_2 # baseline_post_3 will contain the scored measures
##################
### Social Readjustment Rating Scale – Revised
# Citation: Hobson, C. J., Kamen, J., Szostek, J., Nethercut, C. M., Tiedmann, J. W., & Wojnarowicz, S. (1998). Stressful life events: A revision and update of the social readjustment rating scale. International Journal of Stress Management, 5(1), 1-23.
# Each event is weighted out of 100 points.
# Total score is sum of all responses [tot_srrs]
# Number of total stressful life events: [tot_n_srrs]
srrs_factor <- select(baseline_post_3, starts_with("srrs"))
baseline_post_3$tot_srrs_n <- rowSums(srrs_factor[-c(3,47)] == "Yes")
# drop 'death of a close family member' (item 3, column 3) since it seems that some participants may have answered referring to their spouse but it is unclear
# drop 'death of a spouse' (item 47, column 47) since we are interested in stressors outside of bereavement
describe(baseline_post_3$tot_srrs_n)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 3.33 3.25 3 2.81 2.97 0 14 14 1.33 1.54 0.51
# Total score (not counting items 3 and 47):
select(baseline_post_3, starts_with("srrs")) %>% mutate_at(vars(starts_with("srrs")),
funs(as.numeric)) %>% rename_at(vars(starts_with("srrs")),function(x) paste0(x,"c")) -> srrs
srrs$srrs_1c <- as.numeric(recode(srrs$srrs_1c, "2" = "32", "1" = "0")) # Changing work responsibilities (increased/decreased hours/travel)
srrs$srrs_2c <- as.numeric(recode(srrs$srrs_2c, "2" = "62", "1" = "0")) # Experiencing financial problems/difficulties (bankruptcy, credit card debt, college costs, tax problems)
srrs$srrs_3c <- as.numeric(recode(srrs$srrs_3c, "2" = "79", "1" = "0")) # Death of close family member
srrs$srrs_4c <- as.numeric(recode(srrs$srrs_4c, "2" = "35", "1" = "0")) # Change in residence
srrs$srrs_5c <- as.numeric(recode(srrs$srrs_5c, "2" = "43", "1" = "0")) # Changing employers/career
srrs$srrs_6c <- as.numeric(recode(srrs$srrs_6c, "2" = "45", "1" = "0")) # Employer reorganization/downsizing
srrs$srrs_7c <- as.numeric(recode(srrs$srrs_7c, "2" = "37", "1" = "0")) # Major disagreement with boss/coworker
srrs$srrs_8c <- as.numeric(recode(srrs$srrs_8c, "2" = "33", "1" = "0")) # Change in employment position (i.e., lateral transfer, promotion)
srrs$srrs_9c <- as.numeric(recode(srrs$srrs_9c, "2" = "22", "1" = "0")) # Receiving a ticket for violating the law (traffic, parking)
srrs$srrs_10c <- as.numeric(recode(srrs$srrs_10c, "2" = "33", "1" = "0")) # Gaining a new family member (through birth, adoption, marriage)
srrs$srrs_11c <- as.numeric(recode(srrs$srrs_11c, "2" = "72", "1" = "0")) # Major injury/illness to close family member (i.e., cancer, AIDS, etc.)
srrs$srrs_12c <- as.numeric(recode(srrs$srrs_12c, "2" = "47", "1" = "0")) # Attempting to modify addictive behavior of self (i.e., smoking, alcohol, drugs, etc.)
srrs$srrs_13c <- as.numeric(recode(srrs$srrs_13c, "2" = "30", "1" = "0")) # Obtaining a major loan other than home mortgage (car, boat, etc.)
srrs$srrs_14c <- as.numeric(recode(srrs$srrs_14c, "2" = "61", "1" = "0")) # Death of close friend
srrs$srrs_15c <- as.numeric(recode(srrs$srrs_15c, "2" = "30", "1" = "0")) # Obtaining a home mortgage
srrs$srrs_16c <- as.numeric(recode(srrs$srrs_16c, "2" = "64", "1" = "0")) # Being fired/laid off/unemployed
srrs$srrs_17c <- as.numeric(recode(srrs$srrs_17c, "2" = "53", "1" = "0")) # Experiencing/involved in auto accident
srrs$srrs_18c <- as.numeric(recode(srrs$srrs_18c, "2" = "46", "1" = "0")) # Discovering/attempting to modify addictive behavior of close family member (i.e., smoking, alcohol, drugs, etc.)
srrs$srrs_19c <- as.numeric(recode(srrs$srrs_19c, "2" = "38", "1" = "0")) # Spouse/mate begins/ceases work outside the home
srrs$srrs_20c <- as.numeric(recode(srrs$srrs_20c, "2" = "56", "1" = "0")) # Assuming responsibility for sick or elderly loved one
srrs$srrs_21c <- as.numeric(recode(srrs$srrs_21c, "2" = "30", "1" = "0")) # Child leaving home (i.e., marriage, standing college, etc.)
srrs$srrs_22c <- as.numeric(recode(srrs$srrs_22c, "2" = "78", "1" = "0")) # Major injury/illness to self (cancer, AIDS, etc.)
srrs$srrs_23c <- as.numeric(recode(srrs$srrs_23c, "2" = "56", "1" = "0")) # Loss of/or major reduction in health insurance/benefits
srrs$srrs_24c <- as.numeric(recode(srrs$srrs_24c, "2" = "34", "1" = "0")) # Finding appropriate child care/day care
srrs$srrs_25c <- as.numeric(recode(srrs$srrs_25c, "2" = "66", "1" = "0")) # Separation or reconciliation with spouse/mate
srrs$srrs_26c <- as.numeric(recode(srrs$srrs_26c, "2" = "70", "1" = "0")) # Being a victim of crime (theft, robbery, assault, rape, etc.)
srrs$srrs_27c <- as.numeric(recode(srrs$srrs_27c, "2" = "41", "1" = "0")) # Pregnancy of spouse/mate/self
srrs$srrs_28c <- as.numeric(recode(srrs$srrs_28c, "2" = "53", "1" = "0")) # Major disagreement over child support/custody/visitation
srrs$srrs_29c <- as.numeric(recode(srrs$srrs_29c, "2" = "49", "1" = "0")) # Child develops behavior or learning problems
srrs$srrs_30c <- as.numeric(recode(srrs$srrs_30c, "2" = "26", "1" = "0")) # Beginning/ceasing formal education
srrs$srrs_31c <- as.numeric(recode(srrs$srrs_31c, "2" = "56", "1" = "0")) # Self/close family member being arrested for violating the law
srrs$srrs_32c <- as.numeric(recode(srrs$srrs_32c, "2" = "50", "1" = "0")) # Adult child moving in with parent/parent moving in with adult child
srrs$srrs_33c <- as.numeric(recode(srrs$srrs_33c, "2" = "59", "1" = "0")) # Surviving a disaster (fire, flood, earthquake, tornado, hurricane)
srrs$srrs_34c <- as.numeric(recode(srrs$srrs_34c, "2" = "42", "1" = "0")) # Failure to obtain/qualify for a mortgage
srrs$srrs_35c <- as.numeric(recode(srrs$srrs_35c, "2" = "38", "1" = "0")) # Experiencing employment discrimination/sexual harassment
srrs$srrs_36c <- as.numeric(recode(srrs$srrs_36c, "2" = "39", "1" = "0")) # Experiencing discrimination/harassment outside the workplace
srrs$srrs_37c <- as.numeric(recode(srrs$srrs_37c, "2" = "28", "1" = "0")) # Retirement
srrs$srrs_38c <- as.numeric(recode(srrs$srrs_38c, "2" = "43", "1" = "0")) # Getting married/remarried (self)
srrs$srrs_39c <- as.numeric(recode(srrs$srrs_39c, "2" = "59", "1" = "0")) # Becoming a single parent
srrs$srrs_40c <- as.numeric(recode(srrs$srrs_40c, "2" = "71", "1" = "0")) # Divorce
srrs$srrs_41c <- as.numeric(recode(srrs$srrs_41c, "2" = "69", "1" = "0")) # Infidelity (cheating on spouse/mate)
srrs$srrs_42c <- as.numeric(recode(srrs$srrs_42c, "2" = "33", "1" = "0")) # Experiencing a large unexpected monetary gain
srrs$srrs_43c <- as.numeric(recode(srrs$srrs_43c, "2" = "44", "1" = "0")) # Dealing with infertility/miscarriage
srrs$srrs_44c <- as.numeric(recode(srrs$srrs_44c, "2" = "53", "1" = "0")) # Being disciplined at work/demoted
srrs$srrs_45c <- as.numeric(recode(srrs$srrs_45c, "2" = "69", "1" = "0")) # Experiencing domestic violence/sexual abuse
srrs$srrs_46c <- as.numeric(recode(srrs$srrs_46c, "2" = "76", "1" = "0")) # Detention in jail or other institution (mental, drug rehab, etc.)
srrs$srrs_47c <- as.numeric(recode(srrs$srrs_47c, "2" = "87", "1" = "0")) # Death of spouse/mate
srrs$srrs_48c <- as.numeric(recode(srrs$srrs_48c, "2" = "51", "1" = "0")) # Dealing with unwanted pregnancy
srrs$srrs_49c <- as.numeric(recode(srrs$srrs_49c, "2" = "71", "1" = "0")) # Foreclosure on loan/mortgage
srrs$srrs_50c <- as.numeric(recode(srrs$srrs_50c, "2" = "39", "1" = "0")) # Release from jail
srrs$srrs_51c <- as.numeric(recode(srrs$srrs_51c, "2" = "69", "1" = "0")) # Being the victim of police brutality
# Attach tot_srrs back to the baseline_post_3 dataframe, minus the 'death of spouse' and 'death of close family member' items mentioned above:
baseline_post_3$tot_srrs <- rowSums(srrs[-c(3,47)], na.rm=TRUE)
describe(baseline_post_3$tot_srrs)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 161.1 156.09 135.5 137.62 123.8 0 705 705 1.41 2.22 24.68
##################
### UCLA Loneliness Scale - Version 3
# Citation: Russell, D. (1996). UCLA Loneliness Scale (Version 3): Reliability, validity, and factor structure. Journal of Personality Assessment, 66, 20-40.
# Answer choices range from 1 (Never) – 4 (Often).
# Reverse-scored: 1, 5, 6, 9, 10, 15, 16, 19, 20.
# Sum all items for total score [tot_ucla_loneliness].
# reverse-score items:
baseline_post_3$ucla_loneliness_1r <- 6 - baseline_post_2$ucla_loneliness_1
baseline_post_3$ucla_loneliness_5r <- 6 - baseline_post_2$ucla_loneliness_5
baseline_post_3$ucla_loneliness_6r <- 6 - baseline_post_2$ucla_loneliness_6
baseline_post_3$ucla_loneliness_9r <- 6 - baseline_post_2$ucla_loneliness_9
baseline_post_3$ucla_loneliness_10r <- 6 - baseline_post_2$ucla_loneliness_10
baseline_post_3$ucla_loneliness_15r <- 6 - baseline_post_2$ucla_loneliness_15
baseline_post_3$ucla_loneliness_16r <- 6 - baseline_post_2$ucla_loneliness_16
baseline_post_3$ucla_loneliness_19r <- 6 - baseline_post_2$ucla_loneliness_19
baseline_post_3$ucla_loneliness_20r <- 6 - baseline_post_2$ucla_loneliness_20
# total score:
tot_ucla_loneliness <- subset(baseline_post_3, select=c("ucla_loneliness_1r","ucla_loneliness_2", "ucla_loneliness_3", "ucla_loneliness_4", "ucla_loneliness_5r", "ucla_loneliness_6r", "ucla_loneliness_7", "ucla_loneliness_8", "ucla_loneliness_9r", "ucla_loneliness_10r", "ucla_loneliness_11", "ucla_loneliness_12", "ucla_loneliness_13", "ucla_loneliness_14", "ucla_loneliness_15r", "ucla_loneliness_16r", "ucla_loneliness_17", "ucla_loneliness_18", "ucla_loneliness_19r", "ucla_loneliness_20r"))
baseline_post_3$tot_ucla_loneliness <- rowSums(tot_ucla_loneliness, na.rm=TRUE)
describe(baseline_post_3$tot_ucla_loneliness)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 56.58 10.58 57 56.25 11.86 36 79 43 0.11 -0.88 1.67
##################
### Grief Cognitions Scale
# Citation: Boelen, P. & Lensvelt-Mulders, G. (2005). Psychometric properties of the Grief Cognitions Questionnaire (GCQ). Journal of Psychopathology and Behavioral Assessment, 27, 291–303.
# Answer choices range from 0 (strong disagree) to 5 (strongly agree)
# NO reverse scored items.
# Sum all items for total score [tot_gcq].
# 9 subscales:
# Self: 1, 7, 9, 22, 25, 37 [tot_gcq_self]
# World: 3, 10, 19, 34 [tot_gcq_world]
# Life: 12, 15, 20, 32 [tot_gcq_life]
# Future: 5, 13, 21, 27, 35 [tot_gcq_future]
# Self-Blame: 2, 17, 24, 30, 33 [tot_gcq_blame]
# Others: 4, 18, 29 [tot_gcq_others]
# Appropriateness of grief: 11, 16, 26, 31 [tot_gcq_approp]
# Cherish grief: 6, 14, 28 [tot_gcq_cherish]
# Threatening interpretation of grief: 8, 23, 36, 38 [tot_gcq_threat]
# Self:
tot_gcq_self <- subset(baseline_post_2, select=c("gcq_1", "gcq_7", "gcq_9", "gcq_22", "gcq_25", "gcq_37"))
baseline_post_3$tot_gcq_self <- rowSums(tot_gcq_self, na.rm=TRUE)
describe(baseline_post_3$tot_gcq_self)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 6.75 6.34 5.5 6.03 6.67 0 25 25 0.81 -0.13 1
# World:
tot_gcq_world <- subset(baseline_post_2, select=c("gcq_3", "gcq_10", "gcq_19", "gcq_34"))
baseline_post_3$tot_gcq_world <- rowSums(tot_gcq_world, na.rm=TRUE)
describe(baseline_post_3$tot_gcq_world)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 2.75 3.41 1.5 2.16 2.22 0 12 12 1.2 0.29 0.54
# Life:
tot_gcq_life <- subset(baseline_post_2, select=c("gcq_12", "gcq_15", "gcq_20", "gcq_32"))
baseline_post_3$tot_gcq_life <- rowSums(tot_gcq_life, na.rm=TRUE)
describe(baseline_post_3$tot_gcq_life)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 4.28 5.11 3 3.47 4.45 0 17 17 1 -0.23 0.81
# Future:
tot_gcq_future <- subset(baseline_post_2, select=c("gcq_5", "gcq_13", "gcq_21", "gcq_27", "gcq_35"))
baseline_post_3$tot_gcq_future <- rowSums(tot_gcq_future, na.rm=TRUE)
describe(baseline_post_3$tot_gcq_future)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 7.2 6.52 6 6.47 7.41 0 25 25 0.83 -0.15 1.03
# Self-Blame:
tot_gcq_blame <- subset(baseline_post_2, select=c("gcq_2", "gcq_17", "gcq_24", "gcq_30", "gcq_33"))
baseline_post_3$tot_gcq_blame <- rowSums(tot_gcq_blame, na.rm=TRUE)
describe(baseline_post_3$tot_gcq_blame)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 6.22 6.51 3 5.22 4.45 0 24 24 1.09 0.18 1.03
# Others:
tot_gcq_others <- subset(baseline_post_2, select=c("gcq_4", "gcq_18", "gcq_29"))
baseline_post_3$tot_gcq_others <- rowSums(tot_gcq_others, na.rm=TRUE)
describe(baseline_post_3$tot_gcq_others)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 3.77 3.45 3 3.44 4.45 0 12 12 0.6 -0.76 0.54
# Appropriateness of grief:
tot_gcq_approp <- subset(baseline_post_2, select=c("gcq_11", "gcq_16", "gcq_26", "gcq_31"))
baseline_post_3$tot_gcq_approp <- rowSums(tot_gcq_approp, na.rm=TRUE)
describe(baseline_post_3$tot_gcq_approp)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 4.17 4.21 3 3.56 3.71 0 15 15 1.03 0.02 0.66
# Cherish grief:
tot_gcq_cherish <- subset(baseline_post_2, select=c("gcq_6", "gcq_14", "gcq_28"))
baseline_post_3$tot_gcq_cherish <- rowSums(tot_gcq_cherish, na.rm=TRUE)
describe(baseline_post_3$tot_gcq_cherish)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 3.15 3.61 2 2.53 2.97 0 14 14 1.37 0.98 0.57
# Threatening interpretation of grief: 8, 23, 36, 38
# threat: 3, 10, 19, 34
tot_gcq_threat <- subset(baseline_post_2, select=c("gcq_8", "gcq_23", "gcq_36", "gcq_38"))
baseline_post_3$tot_gcq_threat <- rowSums(tot_gcq_threat, na.rm=TRUE)
describe(baseline_post_3$tot_gcq_threat)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 4.17 4.7 3 3.41 4.45 0 16 16 1.04 -0.03 0.74
##################
### Procidano Perceived Social Support Scale - Friends Version
# Citation: Procidano, M. E., & Heller, K. (1983). Measures of perceived social support from friends and from family: Three validation studies. American Journal of Community Psychology, 11(1), 1-24.
# Answer choices are 1 (Yes), 0 (No), NA/not scored (Don't know).
# Reverse scored items: 2, 6, 7, 15, 18, 20.
# Sum all items (possible range: 0 – 20) [tot_ppss_fr]
# recode the responses from Qualtrics (where 1 = Yes, 2 = No) into 1 = Yes, 0 = No):
baseline_post_3 <- baseline_post_3 %>% mutate_at(vars(starts_with("ppss_fr")),
funs(recode(., "1"="1", "2"="0")))
baseline_post_3 <- baseline_post_3 %>% mutate_at(vars(starts_with("ppss_fr")), funs(as.numeric))
# compare before and after:
str(baseline_post_2$ppss_fr_1) # before recoding
num [1:40] 2 1 NA 1 2 1 1 NA 1 2 ...
str(baseline_post_3$ppss_fr_1) # after recoding
num [1:40] 0 1 NA 1 0 1 1 NA 1 0 ...
# reverse-score items:
baseline_post_3$ppss_fr_2r <- as.numeric(recode(baseline_post_3$ppss_fr_2, "1" = "0", "0" = "1"))
baseline_post_3$ppss_fr_6r <- as.numeric(recode(baseline_post_3$ppss_fr_6, "1" = "0", "0" = "1"))
baseline_post_3$ppss_fr_7r <- as.numeric(recode(baseline_post_3$ppss_fr_7, "1" = "0", "0" = "1"))
baseline_post_3$ppss_fr_15r <- as.numeric(recode(baseline_post_3$ppss_fr_15, "1" = "0", "0" = "1"))
baseline_post_3$ppss_fr_18r <- as.numeric(recode(baseline_post_3$ppss_fr_18, "1" = "0", "0" = "1"))
baseline_post_3$ppss_fr_20r <- as.numeric(recode(baseline_post_3$ppss_fr_20, "1" = "0", "0" = "1"))
# check that it worked:
str(baseline_post_3$ppss_fr_2)
num [1:40] NA NA 0 0 1 0 0 1 0 1 ...
str(baseline_post_3$ppss_fr_2r)
num [1:40] NA NA 1 1 0 1 1 0 1 0 ...
# total score:
tot_ppss_fr <- subset(baseline_post_3, select=c("ppss_fr_1", "ppss_fr_2r", "ppss_fr_3", "ppss_fr_4", "ppss_fr_5", "ppss_fr_6r", "ppss_fr_7r", "ppss_fr_8", "ppss_fr_9", "ppss_fr_10", "ppss_fr_11", "ppss_fr_12", "ppss_fr_13", "ppss_fr_14", "ppss_fr_15r", "ppss_fr_16", "ppss_fr_17", "ppss_fr_18r", "ppss_fr_19", "ppss_fr_20r"))
baseline_post_3$tot_ppss_fr <- rowSums(tot_ppss_fr, na.rm=TRUE)
describe(baseline_post_3$tot_ppss_fr)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 12.12 5.08 12.5 12.5 5.19 2 20 18 -0.51 -0.79 0.8
##################
### Procidano Perceived Social Support Scale - Family Version
# Citation: Procidano, M. E., & Heller, K. (1983). Measures of perceived social support from friends and from family: Three validation studies. American Journal of Community Psychology, 11(1), 1-24.
# Answer choices are 1 (Yes), 0 (No), NA/not scored (Don't know).
# Reverse scored items: 3, 4, 16, 19, 20.
# Sum all items (possible range: 0 – 20) [tot_ppss_fa]
# recode the responses from Qualtrics (where 1 = Yes, 2 = No) into 1 = Yes, 0 = No):
baseline_post_3 <- baseline_post_3 %>% mutate_at(vars(starts_with("ppss_fa")),
funs(recode(., "1"="1", "2"="0")))
baseline_post_3 <- baseline_post_3 %>% mutate_at(vars(starts_with("ppss_fa")), funs(as.numeric))
# compare before and after:
str(baseline_post_2$ppss_fa_1) # before recoding
num [1:40] 2 1 2 1 2 1 1 1 1 2 ...
str(baseline_post_3$ppss_fa_1) # after recoding
num [1:40] 0 1 0 1 0 1 1 1 1 0 ...
# reverse-score items:
baseline_post_3$ppss_fa_3r <- as.numeric(recode(baseline_post_3$ppss_fa_3, "1" = "0", "0" = "1"))
baseline_post_3$ppss_fa_4r <- as.numeric(recode(baseline_post_3$ppss_fa_4, "1" = "0", "0" = "1"))
baseline_post_3$ppss_fa_16r <- as.numeric(recode(baseline_post_3$ppss_fa_16, "1" = "0", "0" = "1"))
baseline_post_3$ppss_fa_19r <- as.numeric(recode(baseline_post_3$ppss_fa_19, "1" = "0", "0" = "1"))
baseline_post_3$ppss_fa_20r <- as.numeric(recode(baseline_post_3$ppss_fa_20, "1" = "0", "0" = "1"))
# check that it worked:
str(baseline_post_3$ppss_fa_3)
num [1:40] NA NA 1 0 1 0 1 NA 0 0 ...
str(baseline_post_3$ppss_fa_3r)
num [1:40] NA NA 0 1 0 1 0 NA 1 1 ...
# total score:
tot_ppss_fa <- subset(baseline_post_3, select=c("ppss_fa_1", "ppss_fa_2", "ppss_fa_3r", "ppss_fa_4r", "ppss_fa_5", "ppss_fa_6", "ppss_fa_7", "ppss_fa_8", "ppss_fa_9", "ppss_fa_10", "ppss_fa_11", "ppss_fa_12", "ppss_fa_13", "ppss_fa_14", "ppss_fa_15", "ppss_fa_16r", "ppss_fa_17", "ppss_fa_18", "ppss_fa_19r", "ppss_fa_20r"))
baseline_post_3$tot_ppss_fa <- rowSums(tot_ppss_fa, na.rm=TRUE)
describe(baseline_post_3$tot_ppss_fa)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 11.85 6.22 13.5 12.34 6.67 0 20 20 -0.63 -0.99 0.98
# check that all "tot_*" variables appear
colnames(baseline_post_3)
[1] "ID" "ucla_loneliness_1" "ucla_loneliness_2" "ucla_loneliness_3" "ucla_loneliness_4" "ucla_loneliness_5"
[7] "ucla_loneliness_6" "ucla_loneliness_7" "ucla_loneliness_8" "ucla_loneliness_9" "ucla_loneliness_10" "ucla_loneliness_11"
[13] "ucla_loneliness_12" "ucla_loneliness_13" "ucla_loneliness_14" "ucla_loneliness_15" "ucla_loneliness_16" "ucla_loneliness_17"
[19] "ucla_loneliness_18" "ucla_loneliness_19" "ucla_loneliness_20" "gcq_1" "gcq_2" "gcq_3"
[25] "gcq_4" "gcq_5" "gcq_6" "gcq_7" "gcq_8" "gcq_9"
[31] "gcq_10" "gcq_11" "gcq_12" "gcq_13" "gcq_14" "gcq_15"
[37] "gcq_16" "gcq_17" "gcq_18" "gcq_19" "gcq_20" "gcq_21"
[43] "gcq_22" "gcq_23" "gcq_24" "gcq_25" "gcq_26" "gcq_27"
[49] "gcq_28" "gcq_29" "gcq_30" "gcq_31" "gcq_32" "gcq_33"
[55] "gcq_34" "gcq_35" "gcq_36" "gcq_37" "gcq_38" "srrs_1"
[61] "srrs_2" "srrs_3" "srrs_4" "srrs_5" "srrs_6" "srrs_7"
[67] "srrs_8" "srrs_9" "srrs_10" "srrs_11" "srrs_12" "srrs_13"
[73] "srrs_14" "srrs_15" "srrs_16" "srrs_17" "srrs_18" "srrs_19"
[79] "srrs_20" "srrs_21" "srrs_22" "srrs_23" "srrs_24" "srrs_25"
[85] "srrs_26" "srrs_27" "srrs_28" "srrs_29" "srrs_30" "srrs_31"
[91] "srrs_32" "srrs_33" "srrs_34" "srrs_35" "srrs_36" "srrs_37"
[97] "srrs_38" "srrs_39" "srrs_40" "srrs_41" "srrs_42" "srrs_43"
[103] "srrs_44" "srrs_45" "srrs_46" "srrs_47" "srrs_48" "srrs_49"
[109] "srrs_50" "srrs_51" "ppss_fr_1" "ppss_fr_2" "ppss_fr_3" "ppss_fr_4"
[115] "ppss_fr_5" "ppss_fr_6" "ppss_fr_7" "ppss_fr_8" "ppss_fr_9" "ppss_fr_10"
[121] "ppss_fr_11" "ppss_fr_12" "ppss_fr_13" "ppss_fr_14" "ppss_fr_15" "ppss_fr_16"
[127] "ppss_fr_17" "ppss_fr_18" "ppss_fr_19" "ppss_fr_20" "ppss_fa_1" "ppss_fa_2"
[133] "ppss_fa_3" "ppss_fa_4" "ppss_fa_5" "ppss_fa_6" "ppss_fa_7" "ppss_fa_8"
[139] "ppss_fa_9" "ppss_fa_10" "ppss_fa_11" "ppss_fa_12" "ppss_fa_13" "ppss_fa_14"
[145] "ppss_fa_15" "ppss_fa_16" "ppss_fa_17" "ppss_fa_18" "ppss_fa_19" "ppss_fa_20"
[151] "tot_srrs_n" "tot_srrs" "ucla_loneliness_1r" "ucla_loneliness_5r" "ucla_loneliness_6r" "ucla_loneliness_9r"
[157] "ucla_loneliness_10r" "ucla_loneliness_15r" "ucla_loneliness_16r" "ucla_loneliness_19r" "ucla_loneliness_20r" "tot_ucla_loneliness"
[163] "tot_gcq_self" "tot_gcq_world" "tot_gcq_life" "tot_gcq_future" "tot_gcq_blame" "tot_gcq_others"
[169] "tot_gcq_approp" "tot_gcq_cherish" "tot_gcq_threat" "ppss_fr_2r" "ppss_fr_6r" "ppss_fr_7r"
[175] "ppss_fr_15r" "ppss_fr_18r" "ppss_fr_20r" "tot_ppss_fr" "ppss_fa_3r" "ppss_fa_4r"
[181] "ppss_fa_16r" "ppss_fa_19r" "ppss_fa_20r" "tot_ppss_fa"
# save the cleaned and scored data
saveRDS(baseline_post_3, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/baseline_post_3.rds")
# baseline_post_3 <- readRDS("~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/baseline_post_3.rds")
# Create a subset of only scale total scores (i.e., variables that start with "tot")
scales_post <- baseline_post_3[, grep('^tot', names(baseline_post_3))]
# Plot the variables:
for(i in 1:length(scales_post)) boxplot(scales_post[,i], xlab=NULL, main=names(scales_post[i]))
for(i in 1:length(scales_post)) hist(scales_post[,i], xlab=NULL, main=names(scales_post[i]))
# View descriptives for each scale
## stargazer makes nice-looking summary tables (https://cran.r-project.org/web/packages/stargazer/vignettes/stargazer.pdf)
library(stargazer) # install.packages("stargazer") if this is the first time using the package on this machine
stargazer(scales_post, type="text")
===============================================
Statistic N Mean St. Dev. Min Max
-----------------------------------------------
tot_srrs_n 40 3.325 3.253 0 14
tot_srrs 40 161.100 156.091 0 705
tot_ucla_loneliness 40 56.575 10.583 36 79
tot_gcq_self 40 6.750 6.344 0 25
tot_gcq_world 40 2.750 3.410 0 12
tot_gcq_life 40 4.275 5.114 0 17
tot_gcq_future 40 7.200 6.525 0 25
tot_gcq_blame 40 6.225 6.510 0 24
tot_gcq_others 40 3.775 3.445 0 12
tot_gcq_approp 40 4.175 4.206 0 15
tot_gcq_cherish 40 3.150 3.613 0 14
tot_gcq_threat 40 4.175 4.701 0 16
tot_ppss_fr 40 12.125 5.085 2 20
tot_ppss_fa 40 11.850 6.225 0 20
-----------------------------------------------
# Make a subset of ONLY variables that are factors
# and print column names (fast way to know exactly which variables to use here)
factors <- baseline_post_3 %>%
select_if(is.factor)
colnames(factors)
[1] "srrs_1" "srrs_2" "srrs_3" "srrs_4" "srrs_5" "srrs_6" "srrs_7" "srrs_8" "srrs_9" "srrs_10" "srrs_11" "srrs_12" "srrs_13" "srrs_14" "srrs_15"
[16] "srrs_16" "srrs_17" "srrs_18" "srrs_19" "srrs_20" "srrs_21" "srrs_22" "srrs_23" "srrs_24" "srrs_25" "srrs_26" "srrs_27" "srrs_28" "srrs_29" "srrs_30"
[31] "srrs_31" "srrs_32" "srrs_33" "srrs_34" "srrs_35" "srrs_36" "srrs_37" "srrs_38" "srrs_39" "srrs_40" "srrs_41" "srrs_42" "srrs_43" "srrs_44" "srrs_45"
[46] "srrs_46" "srrs_47" "srrs_48" "srrs_49" "srrs_50" "srrs_51"
## SRRS: Frequency of stressful life events in past 12 months
count(baseline_post_3,srrs_1) # Changing work responsibilities (increased/decreased hours/travel)
count(baseline_post_3,srrs_2) # Experiencing financial problems/difficulties (bankruptcy, credit card debt, college costs, tax problems)
count(baseline_post_3,srrs_3) # Death of close family member
count(baseline_post_3,srrs_4) # Change in residence
count(baseline_post_3,srrs_5) # Changing employers/career
count(baseline_post_3,srrs_6) # Employer reorganization/downsizing
count(baseline_post_3,srrs_7) # Major disagreement with boss/coworker
count(baseline_post_3,srrs_8) # Change in employment position (i.e., lateral transfer, promotion)
count(baseline_post_3,srrs_9) # Receiving a ticket for violating the law (traffic, parking)
count(baseline_post_3,srrs_10) # Gaining a new family member (through birth, adoption, marriage)
count(baseline_post_3,srrs_11) # Major injury/illness to close family member (i.e., cancer, AIDS, etc.)
count(baseline_post_3,srrs_12) # Attempting to modify addictive behavior of self (i.e., smoking, alcohol, drugs, etc.)
count(baseline_post_3,srrs_13) # Obtaining a major loan other than home mortgage (car, boat, etc.)
count(baseline_post_3,srrs_14) # Death of close friend
count(baseline_post_3,srrs_15) # Obtaining a home mortgage
count(baseline_post_3,srrs_16) # Being fired/laid off/unemployed
count(baseline_post_3,srrs_17) # Experiencing/involved in auto accident
count(baseline_post_3,srrs_18) # Discovering/attempting to modify addictive behavior of close family member (i.e., smoking, alcohol, drugs, etc.)
count(baseline_post_3,srrs_19) # Spouse/mate begins/ceases work outside the home
count(baseline_post_3,srrs_20) # Assuming responsibility for sick or elderly loved one
count(baseline_post_3,srrs_21) # Child leaving home (i.e., marriage, standing college, etc.)
count(baseline_post_3,srrs_22) # Major injury/illness to self (cancer, AIDS, etc.)
count(baseline_post_3,srrs_23) # Loss of/or major reduction in health insurance/benefits
count(baseline_post_3,srrs_24) # Finding appropriate child care/day care
count(baseline_post_3,srrs_25) # Separation or reconciliation with spouse/mate
count(baseline_post_3,srrs_26) # Being a victim of crime (theft, robbery, assault, rape, etc.)
count(baseline_post_3,srrs_27) # Pregnancy of spouse/mate/self
count(baseline_post_3,srrs_28) # Major disagreement over child support/custody/visitation
count(baseline_post_3,srrs_29) # Child develops behavior or learning problems
count(baseline_post_3,srrs_30) # Beginning/ceasing formal education
count(baseline_post_3,srrs_31) # Self/close family member being arrested for violating the law
count(baseline_post_3,srrs_32) # Adult child moving in with parent/parent moving in with adult child
count(baseline_post_3,srrs_33) # Surviving a disaster (fire, flood, earthquake, tornado, hurricane
count(baseline_post_3,srrs_34) # Failure to obtain/qualify for a mortgage
count(baseline_post_3,srrs_35) # Experiencing employment discrimination/sexual harassment
count(baseline_post_3,srrs_36) # Experiencing discrimination/harassment outside the workplace
count(baseline_post_3,srrs_37) # Retirement
count(baseline_post_3,srrs_38) # Getting married/remarried (self)
count(baseline_post_3,srrs_39) # Becoming a single parent
count(baseline_post_3,srrs_40) # Divorce
count(baseline_post_3,srrs_41) # Infidelity (cheating on spouse/mate)
count(baseline_post_3,srrs_42) # Experiencing a large unexpected monetary gain
count(baseline_post_3,srrs_43) # Dealing with infertility/miscarriage
count(baseline_post_3,srrs_44) # Being disciplined at work/demoted
count(baseline_post_3,srrs_45) # Experiencing domestic violence/sexual abuse
count(baseline_post_3,srrs_46) # Detention in jail or other institution (mental, drug rehab, etc.)
count(baseline_post_3,srrs_47) # Death of spouse/mate
count(baseline_post_3,srrs_48) # Dealing with unwanted pregnancy
count(baseline_post_3,srrs_49) # Foreclosure on loan/mortgage
count(baseline_post_3,srrs_50) # Release from jail
count(baseline_post_3,srrs_51) # Being the victim of police brutality
(For all other items, 0 reported incidence in this sample).
# The 'alpha' function is helpful because it will alert you if your reverse coding went awry somehow.
## Note that Emily Butler says it's not always correct - if it flags an issues and you've double- and triple-checked your reverse coding, ignore it.
# Primarily, we use/report the standard alpha.
library(psych)
psych::alpha(tot_gcq_approp)
Reliability analysis
Call: psych::alpha(x = tot_gcq_approp)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.88 0.88 0.87 0.65 7.5 0.029 1 1.1 0.69
lower alpha upper 95% confidence boundaries
0.82 0.88 0.94
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
gcq_11 0.89 0.90 0.86 0.75 9.0 0.028 0.0003 0.75
gcq_16 0.81 0.81 0.77 0.59 4.3 0.051 0.0214 0.54
gcq_26 0.83 0.84 0.81 0.63 5.1 0.043 0.0210 0.65
gcq_31 0.84 0.84 0.79 0.64 5.3 0.042 0.0092 0.65
Item statistics
n raw.r std.r r.cor r.drop mean sd
gcq_11 40 0.76 0.77 0.66 0.62 0.78 1.1
gcq_16 40 0.92 0.91 0.89 0.84 1.23 1.4
gcq_26 40 0.89 0.88 0.83 0.78 1.25 1.4
gcq_31 40 0.86 0.87 0.83 0.77 0.93 1.0
Non missing response frequency for each item
0 1 2 3 4 5 miss
gcq_11 0.52 0.32 0.05 0.05 0.05 0.00 0
gcq_16 0.38 0.32 0.12 0.08 0.08 0.02 0
gcq_26 0.40 0.25 0.15 0.10 0.10 0.00 0
gcq_31 0.42 0.35 0.12 0.08 0.02 0.00 0
psych::alpha(tot_gcq_blame)
Reliability analysis
Call: psych::alpha(x = tot_gcq_blame)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.89 0.89 0.91 0.62 8.3 0.027 1.2 1.3 0.62
lower alpha upper 95% confidence boundaries
0.84 0.89 0.94
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
gcq_2 0.87 0.88 0.89 0.64 7.0 0.033 0.018 0.62
gcq_17 0.85 0.85 0.86 0.59 5.7 0.040 0.019 0.56
gcq_24 0.86 0.86 0.88 0.61 6.2 0.037 0.024 0.57
gcq_30 0.89 0.89 0.88 0.67 8.0 0.029 0.014 0.65
gcq_33 0.87 0.87 0.85 0.62 6.5 0.033 0.025 0.60
Item statistics
n raw.r std.r r.cor r.drop mean sd
gcq_2 40 0.82 0.82 0.77 0.72 1.23 1.5
gcq_17 40 0.90 0.89 0.87 0.83 0.97 1.6
gcq_24 40 0.87 0.86 0.81 0.77 1.40 1.8
gcq_30 40 0.75 0.77 0.72 0.64 1.23 1.3
gcq_33 40 0.83 0.84 0.82 0.73 1.40 1.5
Non missing response frequency for each item
0 1 2 3 4 5 miss
gcq_2 0.45 0.25 0.10 0.10 0.02 0.08 0
gcq_17 0.62 0.12 0.08 0.08 0.02 0.08 0
gcq_24 0.50 0.18 0.02 0.12 0.08 0.10 0
gcq_30 0.40 0.22 0.22 0.05 0.10 0.00 0
gcq_33 0.40 0.22 0.10 0.18 0.05 0.05 0
psych::alpha(tot_gcq_cherish)
Reliability analysis
Call: psych::alpha(x = tot_gcq_cherish)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.9 0.92 0.89 0.79 11 0.025 1.1 1.2 0.77
lower alpha upper 95% confidence boundaries
0.85 0.9 0.95
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
gcq_6 0.90 0.91 0.83 0.83 10.0 0.029 NA 0.83
gcq_14 0.84 0.87 0.77 0.77 6.9 0.043 NA 0.77
gcq_28 0.85 0.87 0.76 0.76 6.5 0.044 NA 0.76
Item statistics
n raw.r std.r r.cor r.drop mean sd
gcq_6 40 0.93 0.91 0.83 0.80 1.35 1.6
gcq_14 40 0.93 0.93 0.89 0.84 1.05 1.2
gcq_28 40 0.92 0.94 0.90 0.85 0.75 1.1
Non missing response frequency for each item
0 1 2 3 4 5 miss
gcq_6 0.40 0.25 0.18 0.02 0.08 0.08 0
gcq_14 0.42 0.30 0.15 0.08 0.02 0.02 0
gcq_28 0.55 0.28 0.10 0.02 0.05 0.00 0
psych::alpha(tot_gcq_future)
Reliability analysis
Call: psych::alpha(x = tot_gcq_future)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.93 0.93 0.93 0.73 14 0.019 1.4 1.3 0.73
lower alpha upper 95% confidence boundaries
0.89 0.93 0.96
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
gcq_5 0.94 0.94 0.93 0.80 15.7 0.017 0.0047 0.78
gcq_13 0.90 0.90 0.89 0.70 9.5 0.027 0.0107 0.69
gcq_21 0.92 0.93 0.92 0.76 12.4 0.021 0.0121 0.74
gcq_27 0.90 0.91 0.90 0.71 9.7 0.026 0.0136 0.71
gcq_35 0.90 0.90 0.88 0.69 8.9 0.027 0.0081 0.69
Item statistics
n raw.r std.r r.cor r.drop mean sd
gcq_5 40 0.80 0.80 0.71 0.68 1.4 1.5
gcq_13 40 0.92 0.92 0.91 0.87 1.4 1.4
gcq_21 40 0.86 0.85 0.79 0.77 1.6 1.7
gcq_27 40 0.91 0.92 0.90 0.86 1.5 1.5
gcq_35 40 0.94 0.94 0.95 0.90 1.3 1.3
Non missing response frequency for each item
0 1 2 3 4 5 miss
gcq_5 0.38 0.20 0.20 0.10 0.08 0.05 0
gcq_13 0.38 0.25 0.15 0.12 0.08 0.02 0
gcq_21 0.30 0.35 0.05 0.12 0.08 0.10 0
gcq_27 0.30 0.28 0.22 0.08 0.08 0.05 0
gcq_35 0.32 0.38 0.10 0.12 0.05 0.02 0
psych::alpha(tot_gcq_life)
Reliability analysis
Call: psych::alpha(x = tot_gcq_life)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.95 0.95 0.95 0.83 19 0.013 1.1 1.3 0.8
lower alpha upper 95% confidence boundaries
0.92 0.95 0.97
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
gcq_12 0.93 0.93 0.91 0.82 14 0.018 0.00151 0.82
gcq_15 0.94 0.95 0.93 0.85 17 0.016 0.00413 0.87
gcq_20 0.93 0.94 0.92 0.83 15 0.017 0.00470 0.79
gcq_32 0.91 0.92 0.89 0.80 12 0.022 0.00034 0.79
Item statistics
n raw.r std.r r.cor r.drop mean sd
gcq_12 40 0.93 0.93 0.92 0.88 1.10 1.4
gcq_15 40 0.90 0.91 0.86 0.84 0.95 1.2
gcq_20 40 0.93 0.93 0.90 0.87 1.07 1.5
gcq_32 40 0.96 0.96 0.95 0.92 1.15 1.4
Non missing response frequency for each item
0 1 2 3 4 5 miss
gcq_12 0.52 0.15 0.10 0.18 0.02 0.02 0
gcq_15 0.50 0.20 0.18 0.10 0.02 0.00 0
gcq_20 0.52 0.22 0.08 0.05 0.08 0.05 0
gcq_32 0.45 0.25 0.12 0.05 0.12 0.00 0
psych::alpha(tot_gcq_others)
Reliability analysis
Call: psych::alpha(x = tot_gcq_others)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.79 0.81 0.74 0.58 4.2 0.056 1.3 1.1 0.57
lower alpha upper 95% confidence boundaries
0.68 0.79 0.89
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
gcq_4 0.68 0.73 0.57 0.57 2.7 0.088 NA 0.57
gcq_18 0.75 0.76 0.61 0.61 3.2 0.076 NA 0.61
gcq_29 0.70 0.72 0.56 0.56 2.5 0.090 NA 0.56
Item statistics
n raw.r std.r r.cor r.drop mean sd
gcq_4 40 0.84 0.85 0.74 0.65 1.40 1.3
gcq_18 40 0.88 0.84 0.70 0.63 1.52 1.7
gcq_29 40 0.82 0.86 0.75 0.67 0.85 1.1
Non missing response frequency for each item
0 1 2 3 4 5 miss
gcq_4 0.30 0.28 0.25 0.10 0.05 0.02 0
gcq_18 0.45 0.10 0.15 0.12 0.12 0.05 0
gcq_29 0.48 0.32 0.12 0.02 0.05 0.00 0
psych::alpha(tot_gcq_self)
Reliability analysis
Call: psych::alpha(x = tot_gcq_self)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.91 0.91 0.92 0.64 11 0.022 1.1 1.1 0.66
lower alpha upper 95% confidence boundaries
0.87 0.91 0.95
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
gcq_1 0.88 0.89 0.89 0.62 8.2 0.030 0.0158 0.65
gcq_7 0.90 0.91 0.91 0.66 9.8 0.024 0.0152 0.71
gcq_9 0.90 0.91 0.90 0.66 9.7 0.025 0.0114 0.65
gcq_22 0.88 0.89 0.89 0.61 7.8 0.031 0.0162 0.64
gcq_25 0.88 0.89 0.89 0.61 7.8 0.030 0.0162 0.63
gcq_37 0.91 0.92 0.91 0.69 10.9 0.021 0.0057 0.69
Item statistics
n raw.r std.r r.cor r.drop mean sd
gcq_1 40 0.88 0.88 0.86 0.83 0.95 1.2
gcq_7 40 0.78 0.80 0.74 0.69 1.00 1.2
gcq_9 40 0.78 0.80 0.76 0.70 0.80 1.0
gcq_22 40 0.90 0.90 0.88 0.84 1.35 1.4
gcq_25 40 0.90 0.90 0.88 0.85 1.35 1.2
gcq_37 40 0.78 0.75 0.69 0.65 1.30 1.6
Non missing response frequency for each item
0 1 2 3 4 5 miss
gcq_1 0.52 0.15 0.20 0.10 0.02 0.00 0
gcq_7 0.50 0.18 0.20 0.08 0.05 0.00 0
gcq_9 0.50 0.30 0.12 0.05 0.02 0.00 0
gcq_22 0.38 0.28 0.05 0.25 0.02 0.02 0
gcq_25 0.25 0.42 0.12 0.12 0.08 0.00 0
gcq_37 0.42 0.28 0.05 0.12 0.08 0.05 0
psych::alpha(tot_gcq_threat)
Reliability analysis
Call: psych::alpha(x = tot_gcq_threat)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.92 0.92 0.92 0.74 11 0.022 1 1.2 0.76
lower alpha upper 95% confidence boundaries
0.87 0.92 0.96
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
gcq_8 0.86 0.87 0.84 0.68 6.4 0.040 0.0166 0.72
gcq_23 0.92 0.92 0.89 0.79 11.5 0.023 0.0029 0.78
gcq_36 0.87 0.87 0.86 0.70 6.9 0.036 0.0200 0.74
gcq_38 0.92 0.92 0.90 0.79 11.5 0.022 0.0042 0.81
Item statistics
n raw.r std.r r.cor r.drop mean sd
gcq_8 40 0.95 0.95 0.94 0.90 1.1 1.4
gcq_23 40 0.85 0.85 0.80 0.74 0.9 1.3
gcq_36 40 0.93 0.94 0.91 0.88 1.0 1.2
gcq_38 40 0.86 0.85 0.79 0.74 1.2 1.4
Non missing response frequency for each item
0 1 2 3 4 5 miss
gcq_8 0.52 0.18 0.12 0.10 0.05 0.02 0
gcq_23 0.52 0.25 0.10 0.08 0.02 0.02 0
gcq_36 0.45 0.30 0.02 0.22 0.00 0.00 0
gcq_38 0.42 0.25 0.15 0.08 0.08 0.02 0
psych::alpha(tot_gcq_world)
Reliability analysis
Call: psych::alpha(x = tot_gcq_world)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.87 0.9 0.9 0.68 8.6 0.031 0.69 0.85 0.68
lower alpha upper 95% confidence boundaries
0.81 0.87 0.93
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
gcq_3 0.83 0.86 0.82 0.67 6.2 0.039 0.0082 0.71
gcq_10 0.81 0.86 0.83 0.67 6.0 0.049 0.0233 0.58
gcq_19 0.86 0.89 0.86 0.73 8.3 0.035 0.0096 0.71
gcq_34 0.85 0.85 0.80 0.66 5.8 0.042 0.0065 0.65
Item statistics
n raw.r std.r r.cor r.drop mean sd
gcq_3 40 0.87 0.88 0.85 0.74 0.75 1.06
gcq_10 40 0.89 0.89 0.84 0.80 0.78 1.00
gcq_19 40 0.86 0.83 0.75 0.71 0.85 1.23
gcq_34 40 0.86 0.89 0.87 0.80 0.38 0.63
Non missing response frequency for each item
0 1 2 3 4 miss
gcq_3 0.57 0.22 0.08 0.12 0.00 0
gcq_10 0.52 0.28 0.10 0.10 0.00 0
gcq_19 0.55 0.25 0.08 0.05 0.08 0
gcq_34 0.70 0.22 0.08 0.00 0.00 0
psych::alpha(tot_ucla_loneliness)
Reliability analysis
Call: psych::alpha(x = tot_ucla_loneliness)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.94 0.94 0.98 0.45 16 0.013 2.8 0.53 0.47
lower alpha upper 95% confidence boundaries
0.92 0.94 0.97
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
ucla_loneliness_1r 0.94 0.94 0.98 0.45 16 0.013 0.033 0.47
ucla_loneliness_2 0.94 0.94 0.98 0.46 16 0.013 0.031 0.47
ucla_loneliness_3 0.94 0.94 0.97 0.44 15 0.014 0.030 0.46
ucla_loneliness_4 0.94 0.94 0.98 0.46 16 0.013 0.031 0.47
ucla_loneliness_5r 0.94 0.94 0.98 0.45 16 0.013 0.033 0.47
ucla_loneliness_6r 0.94 0.94 0.98 0.45 15 0.013 0.032 0.46
ucla_loneliness_7 0.94 0.94 0.98 0.44 15 0.014 0.031 0.46
ucla_loneliness_8 0.94 0.94 0.98 0.45 16 0.013 0.033 0.47
ucla_loneliness_9r 0.94 0.94 0.98 0.45 16 0.013 0.033 0.47
ucla_loneliness_10r 0.94 0.94 0.98 0.45 15 0.014 0.031 0.46
ucla_loneliness_11 0.94 0.94 0.98 0.47 17 0.013 0.029 0.48
ucla_loneliness_12 0.94 0.94 0.98 0.45 16 0.013 0.032 0.47
ucla_loneliness_13 0.94 0.94 0.97 0.44 15 0.014 0.032 0.46
ucla_loneliness_14 0.94 0.94 0.98 0.45 15 0.014 0.033 0.46
ucla_loneliness_15r 0.94 0.94 0.98 0.44 15 0.014 0.032 0.46
ucla_loneliness_16r 0.94 0.94 0.98 0.44 15 0.014 0.030 0.46
ucla_loneliness_17 0.95 0.95 0.98 0.48 18 0.011 0.022 0.48
ucla_loneliness_18 0.94 0.94 0.98 0.45 15 0.014 0.033 0.47
ucla_loneliness_19r 0.94 0.94 0.98 0.44 15 0.014 0.030 0.46
ucla_loneliness_20r 0.94 0.94 0.98 0.44 15 0.014 0.031 0.47
Item statistics
n raw.r std.r r.cor r.drop mean sd
ucla_loneliness_1r 40 0.65 0.67 0.65 0.62 2.9 0.55
ucla_loneliness_2 40 0.55 0.54 0.53 0.49 2.9 0.76
ucla_loneliness_3 40 0.84 0.82 0.82 0.80 2.5 1.01
ucla_loneliness_4 40 0.61 0.61 0.61 0.57 3.0 0.60
ucla_loneliness_5r 40 0.67 0.68 0.67 0.63 3.1 0.74
ucla_loneliness_6r 40 0.71 0.72 0.72 0.67 3.1 0.66
ucla_loneliness_7 40 0.83 0.81 0.80 0.79 2.5 1.04
ucla_loneliness_8 40 0.66 0.68 0.67 0.63 2.8 0.62
ucla_loneliness_9r 40 0.66 0.67 0.65 0.62 2.9 0.66
ucla_loneliness_10r 40 0.75 0.75 0.75 0.72 3.2 0.65
ucla_loneliness_11 40 0.46 0.46 0.45 0.42 2.6 0.59
ucla_loneliness_12 40 0.65 0.66 0.65 0.61 2.5 0.82
ucla_loneliness_13 40 0.79 0.79 0.79 0.76 2.8 0.72
ucla_loneliness_14 40 0.76 0.76 0.75 0.73 2.5 0.75
ucla_loneliness_15r 40 0.78 0.77 0.77 0.75 3.1 0.86
ucla_loneliness_16r 40 0.85 0.85 0.85 0.83 3.1 0.77
ucla_loneliness_17 40 0.28 0.29 0.27 0.21 2.5 0.88
ucla_loneliness_18 40 0.74 0.75 0.74 0.71 2.7 0.78
ucla_loneliness_19r 40 0.79 0.78 0.78 0.75 2.9 0.83
ucla_loneliness_20r 40 0.79 0.77 0.77 0.75 2.9 0.87
Non missing response frequency for each item
1 2 3 4 5 miss
ucla_loneliness_1r 0.00 0.20 0.70 0.10 0.00 0
ucla_loneliness_2 0.05 0.18 0.57 0.20 0.00 0
ucla_loneliness_3 0.22 0.15 0.48 0.15 0.00 0
ucla_loneliness_4 0.00 0.18 0.65 0.18 0.00 0
ucla_loneliness_5r 0.00 0.20 0.52 0.25 0.02 0
ucla_loneliness_6r 0.00 0.15 0.55 0.30 0.00 0
ucla_loneliness_7 0.25 0.18 0.42 0.15 0.00 0
ucla_loneliness_8 0.02 0.25 0.65 0.08 0.00 0
ucla_loneliness_9r 0.00 0.30 0.55 0.15 0.00 0
ucla_loneliness_10r 0.00 0.12 0.55 0.32 0.00 0
ucla_loneliness_11 0.02 0.35 0.60 0.02 0.00 0
ucla_loneliness_12 0.10 0.38 0.42 0.10 0.00 0
ucla_loneliness_13 0.05 0.22 0.60 0.12 0.00 0
ucla_loneliness_14 0.10 0.32 0.52 0.05 0.00 0
ucla_loneliness_15r 0.00 0.28 0.42 0.25 0.05 0
ucla_loneliness_16r 0.00 0.18 0.55 0.22 0.05 0
ucla_loneliness_17 0.18 0.25 0.50 0.08 0.00 0
ucla_loneliness_18 0.08 0.25 0.55 0.12 0.00 0
ucla_loneliness_19r 0.00 0.38 0.45 0.12 0.05 0
ucla_loneliness_20r 0.00 0.38 0.40 0.18 0.05 0
psych::alpha(tot_ppss_fa)
Matrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was done
Reliability analysis
Call: psych::alpha(x = tot_ppss_fa)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.96 0.96 1 0.57 27 0.0084 0.69 0.34 0.57
lower alpha upper 95% confidence boundaries
0.95 0.96 0.98
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
ppss_fa_1 0.96 0.96 1 0.56 25 0.0091 0.025 0.57
ppss_fa_2 0.96 0.96 1 0.58 26 0.0085 0.024 0.59
ppss_fa_3r 0.96 0.96 1 0.58 26 0.0087 0.026 0.57
ppss_fa_4r 0.96 0.96 1 0.58 26 0.0087 0.027 0.58
ppss_fa_5 0.96 0.96 1 0.56 24 0.0094 0.024 0.56
ppss_fa_6 0.96 0.96 1 0.59 27 0.0084 0.026 0.60
ppss_fa_7 0.96 0.97 1 0.59 28 0.0083 0.022 0.60
ppss_fa_8 0.96 0.96 1 0.57 25 0.0091 0.027 0.56
ppss_fa_9 0.96 0.96 1 0.58 26 0.0086 0.027 0.59
ppss_fa_10 0.96 0.96 1 0.57 26 0.0089 0.027 0.57
ppss_fa_11 0.96 0.96 1 0.58 26 0.0086 0.026 0.58
ppss_fa_12 0.96 0.96 1 0.58 26 0.0087 0.027 0.58
ppss_fa_13 0.96 0.96 1 0.58 26 0.0086 0.025 0.58
ppss_fa_14 0.96 0.96 1 0.57 26 0.0088 0.027 0.57
ppss_fa_15 0.96 0.96 1 0.57 25 0.0089 0.025 0.57
ppss_fa_16r 0.96 0.96 1 0.57 25 0.0092 0.026 0.56
ppss_fa_17 0.96 0.96 1 0.57 26 0.0088 0.027 0.58
ppss_fa_18 0.96 0.96 1 0.57 25 0.0090 0.028 0.57
ppss_fa_19r 0.96 0.96 1 0.57 25 0.0091 0.025 0.57
ppss_fa_20r 0.96 0.96 1 0.57 25 0.0090 0.026 0.56
Item statistics
n raw.r std.r r.cor r.drop mean sd
ppss_fa_1 40 0.88 0.88 0.88 0.86 0.75 0.44
ppss_fa_2 39 0.68 0.68 0.68 0.65 0.67 0.48
ppss_fa_3r 24 0.77 0.74 0.74 0.71 0.58 0.50
ppss_fa_4r 36 0.75 0.73 0.73 0.70 0.69 0.47
ppss_fa_5 30 0.94 0.98 0.98 0.97 0.77 0.43
ppss_fa_6 35 0.66 0.65 0.65 0.61 0.57 0.50
ppss_fa_7 40 0.52 0.55 0.55 0.50 0.80 0.41
ppss_fa_8 38 0.86 0.86 0.86 0.84 0.66 0.48
ppss_fa_9 37 0.67 0.68 0.68 0.65 0.86 0.35
ppss_fa_10 36 0.75 0.78 0.78 0.76 0.67 0.48
ppss_fa_11 37 0.73 0.72 0.72 0.68 0.62 0.49
ppss_fa_12 39 0.74 0.73 0.73 0.70 0.72 0.46
ppss_fa_13 35 0.71 0.71 0.71 0.68 0.66 0.48
ppss_fa_14 39 0.78 0.78 0.78 0.76 0.56 0.50
ppss_fa_15 33 0.78 0.79 0.79 0.76 0.70 0.47
ppss_fa_16r 37 0.86 0.87 0.87 0.85 0.70 0.46
ppss_fa_17 29 0.75 0.78 0.78 0.75 0.52 0.51
ppss_fa_18 29 0.78 0.82 0.82 0.79 0.69 0.47
ppss_fa_19r 21 0.77 0.87 0.87 0.84 0.62 0.50
ppss_fa_20r 38 0.84 0.85 0.85 0.83 0.79 0.41
Non missing response frequency for each item
0 1 miss
ppss_fa_1 0.25 0.75 0.00
ppss_fa_2 0.33 0.67 0.03
ppss_fa_3r 0.42 0.58 0.40
ppss_fa_4r 0.31 0.69 0.10
ppss_fa_5 0.23 0.77 0.25
ppss_fa_6 0.43 0.57 0.12
ppss_fa_7 0.20 0.80 0.00
ppss_fa_8 0.34 0.66 0.05
ppss_fa_9 0.14 0.86 0.07
ppss_fa_10 0.33 0.67 0.10
ppss_fa_11 0.38 0.62 0.07
ppss_fa_12 0.28 0.72 0.03
ppss_fa_13 0.34 0.66 0.12
ppss_fa_14 0.44 0.56 0.03
ppss_fa_15 0.30 0.70 0.18
ppss_fa_16r 0.30 0.70 0.07
ppss_fa_17 0.48 0.52 0.28
ppss_fa_18 0.31 0.69 0.28
ppss_fa_19r 0.38 0.62 0.48
ppss_fa_20r 0.21 0.79 0.05
psych::alpha(tot_ppss_fr)
Item = ppss_fr_20r had no variance and was deletedMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was doneMatrix was not positive definite, smoothing was done
Reliability analysis
Call: psych::alpha(x = tot_ppss_fr)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.93 0.93 1 0.41 13 0.016 0.72 0.29 0.41
lower alpha upper 95% confidence boundaries
0.9 0.93 0.96
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
ppss_fr_1 0.92 0.92 1 0.40 12 0.018 0.035 0.40
ppss_fr_2r 0.93 0.93 1 0.42 13 0.017 0.038 0.41
ppss_fr_3 0.92 0.92 1 0.40 12 0.018 0.038 0.38
ppss_fr_4 0.93 0.93 1 0.43 13 0.017 0.037 0.43
ppss_fr_5 0.93 0.93 1 0.42 13 0.017 0.040 0.41
ppss_fr_6r 0.93 0.93 1 0.43 14 0.016 0.038 0.44
ppss_fr_7r 0.92 0.93 1 0.41 13 0.017 0.041 0.41
ppss_fr_8 0.93 0.93 1 0.43 13 0.017 0.038 0.43
ppss_fr_9 0.92 0.93 1 0.41 13 0.017 0.038 0.40
ppss_fr_10 0.92 0.93 1 0.41 13 0.017 0.038 0.41
ppss_fr_11 0.93 0.93 1 0.42 13 0.017 0.039 0.41
ppss_fr_12 0.92 0.92 1 0.41 12 0.018 0.038 0.40
ppss_fr_13 0.93 0.93 1 0.42 13 0.017 0.040 0.43
ppss_fr_14 0.92 0.92 1 0.40 12 0.018 0.034 0.39
ppss_fr_15r 0.92 0.93 1 0.41 13 0.017 0.040 0.41
ppss_fr_16 0.92 0.93 1 0.41 13 0.017 0.040 0.41
ppss_fr_17 0.93 0.93 1 0.41 13 0.017 0.040 0.41
ppss_fr_18r 0.92 0.92 1 0.40 12 0.019 0.037 0.40
ppss_fr_19 0.93 0.93 1 0.42 13 0.017 0.041 0.41
Item statistics
n raw.r std.r r.cor r.drop mean sd
ppss_fr_1 34 0.80 0.86 0.86 0.84 0.82 0.39
ppss_fr_2r 30 0.66 0.62 0.62 0.59 0.60 0.50
ppss_fr_3 34 0.75 0.85 0.85 0.82 0.88 0.33
ppss_fr_4 38 0.52 0.51 0.51 0.44 0.87 0.34
ppss_fr_5 36 0.60 0.58 0.58 0.52 0.72 0.45
ppss_fr_6r 31 0.50 0.44 0.44 0.37 0.61 0.50
ppss_fr_7r 31 0.67 0.67 0.67 0.61 0.61 0.50
ppss_fr_8 39 0.41 0.50 0.50 0.43 0.85 0.37
ppss_fr_9 34 0.71 0.70 0.70 0.66 0.76 0.43
ppss_fr_10 35 0.67 0.70 0.70 0.66 0.71 0.46
ppss_fr_11 33 0.57 0.55 0.55 0.50 0.73 0.45
ppss_fr_12 35 0.76 0.76 0.76 0.73 0.60 0.50
ppss_fr_13 37 0.63 0.61 0.61 0.58 0.46 0.51
ppss_fr_14 26 0.79 0.85 0.85 0.82 0.73 0.45
ppss_fr_15r 39 0.67 0.67 0.67 0.61 0.79 0.41
ppss_fr_16 27 0.61 0.65 0.65 0.62 0.74 0.45
ppss_fr_17 29 0.69 0.67 0.67 0.61 0.86 0.35
ppss_fr_18r 21 0.79 0.84 0.84 0.82 0.48 0.51
ppss_fr_19 36 0.63 0.64 0.64 0.57 0.75 0.44
Non missing response frequency for each item
0 1 miss
ppss_fr_1 0.18 0.82 0.15
ppss_fr_2r 0.40 0.60 0.25
ppss_fr_3 0.12 0.88 0.15
ppss_fr_4 0.13 0.87 0.05
ppss_fr_5 0.28 0.72 0.10
ppss_fr_6r 0.39 0.61 0.22
ppss_fr_7r 0.39 0.61 0.22
ppss_fr_8 0.15 0.85 0.03
ppss_fr_9 0.24 0.76 0.15
ppss_fr_10 0.29 0.71 0.12
ppss_fr_11 0.27 0.73 0.18
ppss_fr_12 0.40 0.60 0.12
ppss_fr_13 0.54 0.46 0.07
ppss_fr_14 0.27 0.73 0.35
ppss_fr_15r 0.21 0.79 0.03
ppss_fr_16 0.26 0.74 0.32
ppss_fr_17 0.14 0.86 0.28
ppss_fr_18r 0.52 0.48 0.48
ppss_fr_19 0.25 0.75 0.10
baseline_4 <- readRDS("~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/baseline.rds")
names(baseline_4)
[1] "startdate" "ID" "dob" "sex_m" "dateofdeath"
[6] "knowbefore_y" "caretaker_y" "education" "highestdegree" "education_other"
[11] "employment" "householdsize" "householdsize_adult" "householdsize_income" "ethnicity_hisp"
[16] "race" "race_other" "learnaboutstudy" "meds_y" "meds_which"
[21] "meds_dx" "meds_dose" "majorhealthprobs_y" "majorhealthprobs_what" "past2wks_injuryinfect_y"
[26] "past2wks_dentist_y" "currenttx_y" "postmenopausal_y" "lastperiod" "n_pregnancies"
[31] "n_livebirths" "n_nursed" "allergies" "surgeries_past6mos" "alcohol"
[36] "smoking_y" "smoking_howlong" "smoking_perday" "caffeine_perday" "exercise"
[41] "pss_1" "pss_2" "pss_3" "pss_4" "pss_5"
[46] "pss_6" "pss_7" "pss_8" "pss_9" "pss_10"
[51] "ysl_1" "ysl_2" "ysl_3" "ysl_4" "ysl_5"
[56] "ysl_6" "ysl_7" "ysl_8" "ysl_9" "ysl_10"
[61] "ysl_11" "ysl_12" "ysl_13" "ysl_14" "ysl_15"
[66] "ysl_16" "ysl_17" "ysl_18" "ysl_19" "ysl_20"
[71] "ysl_21" "icg_1" "icg_2" "icg_3" "icg_4"
[76] "icg_5" "icg_6" "icg_7" "icg_8" "icg_9"
[81] "icg_10" "icg_11" "icg_12" "icg_13" "icg_14"
[86] "icg_15" "icg_16" "icg_17" "icg_18" "icg_19"
[91] "bdi_1" "bdi_2" "bdi_3" "bdi_4" "bdi_5"
[96] "bdi_6" "bdi_7" "bdi_8" "bdi_9" "bdi_10"
[101] "bdi_11" "bdi_12" "bdi_13" "bdi_14" "bdi_15"
[106] "bdi_16" "bdi_17" "bdi_18" "bdi_19" "bdi_20"
[111] "bdi_21" "hand_1" "hand_2" "hand_3" "hand_4"
[116] "hand_5" "hand_6" "hand_7" "hand_8" "hand_9"
[121] "hand_10" "hand_11" "hand_12" "hand_bat_1" "bisbas_1"
[126] "bisbas_2" "bisbas_3" "bisbas_4" "bisbas_5" "bisbas_6"
[131] "bisbas_7" "bisbas_8" "bisbas_9" "bisbas_10" "bisbas_11"
[136] "bisbas_12" "bisbas_13" "bisbas_14" "bisbas_15" "bisbas_16"
[141] "bisbas_17" "bisbas_18" "bisbas_19" "bisbas_20" "bisbas_21"
[146] "bisbas_22" "bisbas_23" "bisbas_24" "bgq_1" "bgq_2"
[151] "bgq_3" "bgq_4" "bgq_5" "ecrrs_global_1" "ecrrs_global_2"
[156] "ecrrs_global_3" "ecrrs_global_4" "ecrrs_global_5" "ecrrs_global_6" "ecrrs_global_7"
[161] "ecrrs_global_8" "ecrrs_global_9" "ecrrs_spouse_1" "ecrrs_spouse_2" "ecrrs_spouse_3"
[166] "ecrrs_spouse_4" "ecrrs_spouse_5" "ecrrs_spouse_6" "ecrrs_spouse_7" "ecrrs_spouse_8"
[171] "ecrrs_spouse_9" "timesincedeath" "age" "age_yrs" "pss_4r"
[176] "pss_5r" "pss_7r" "pss_8r" "tot_pss" "tot_ysl"
[181] "tot_icg" "bdi_1c" "bdi_2c" "bdi_3c" "bdi_4c"
[186] "bdi_5c" "bdi_6c" "bdi_7c" "bdi_8c" "bdi_9c"
[191] "bdi_10c" "bdi_11c" "bdi_12c" "bdi_13c" "bdi_14c"
[196] "bdi_15c" "bdi_16c" "bdi_17c" "bdi_18c" "bdi_19c"
[201] "bdi_20c" "bdi_21c" "tot_bdi" "hand_1c" "hand_2c"
[206] "hand_3c" "hand_4c" "hand_5c" "hand_6c" "hand_7c"
[211] "hand_8c" "hand_9c" "hand_10c" "hand_11c" "hand_12c"
[216] "hand_bat_1c" "tot_handedness" "bisbas_1r" "bisbas_3r" "bisbas_4r"
[221] "bisbas_5r" "bisbas_6r" "bisbas_7r" "bisbas_8r" "bisbas_9r"
[226] "bisbas_10r" "bisbas_11r" "bisbas_12r" "bisbas_13r" "bisbas_14r"
[231] "bisbas_15r" "bisbas_16r" "bisbas_17r" "bisbas_18r" "bisbas_19r"
[236] "bisbas_20r" "bisbas_21r" "bisbas_23r" "bisbas_24r" "tot_bisbas_basdr"
[241] "tot_bisbas_basfun" "tot_bisbas_basrr" "tot_bisbas_bis" "tot_bgq" "ecrrs_global_1c"
[246] "ecrrs_global_2c" "ecrrs_global_3c" "ecrrs_global_4c" "ecrrs_global_5c" "ecrrs_global_6c"
[251] "ecrrs_global_7c" "ecrrs_global_8c" "ecrrs_global_9c" "ecrrs_global_1r" "ecrrs_global_2r"
[256] "ecrrs_global_3r" "ecrrs_global_4r" "tot_ecrrs_global_avoid" "tot_ecrrs_global_anx" "ecrrs_spouse_1c"
[261] "ecrrs_spouse_2c" "ecrrs_spouse_3c" "ecrrs_spouse_4c" "ecrrs_spouse_5c" "ecrrs_spouse_6c"
[266] "ecrrs_spouse_7c" "ecrrs_spouse_8c" "ecrrs_spouse_9c" "ecrrs_spouse_1r" "ecrrs_spouse_2r"
[271] "ecrrs_spouse_3r" "ecrrs_spouse_4r" "tot_ecrrs_spouse_avoid" "tot_ecrrs_spouse_anx"
baseline_4 <- baseline_4 %>% mutate(ID = recode(ID, "d130" = "D130")) # make d130 -> D130
baseline_all <- left_join(baseline_4,baseline_post_3, by="ID") #merge by ID
View(baseline_all)
names(baseline_all)
[1] "startdate" "ID" "dob" "sex_m" "dateofdeath"
[6] "knowbefore_y" "caretaker_y" "education" "highestdegree" "education_other"
[11] "employment" "householdsize" "householdsize_adult" "householdsize_income" "ethnicity_hisp"
[16] "race" "race_other" "learnaboutstudy" "meds_y" "meds_which"
[21] "meds_dx" "meds_dose" "majorhealthprobs_y" "majorhealthprobs_what" "past2wks_injuryinfect_y"
[26] "past2wks_dentist_y" "currenttx_y" "postmenopausal_y" "lastperiod" "n_pregnancies"
[31] "n_livebirths" "n_nursed" "allergies" "surgeries_past6mos" "alcohol"
[36] "smoking_y" "smoking_howlong" "smoking_perday" "caffeine_perday" "exercise"
[41] "pss_1" "pss_2" "pss_3" "pss_4" "pss_5"
[46] "pss_6" "pss_7" "pss_8" "pss_9" "pss_10"
[51] "ysl_1" "ysl_2" "ysl_3" "ysl_4" "ysl_5"
[56] "ysl_6" "ysl_7" "ysl_8" "ysl_9" "ysl_10"
[61] "ysl_11" "ysl_12" "ysl_13" "ysl_14" "ysl_15"
[66] "ysl_16" "ysl_17" "ysl_18" "ysl_19" "ysl_20"
[71] "ysl_21" "icg_1" "icg_2" "icg_3" "icg_4"
[76] "icg_5" "icg_6" "icg_7" "icg_8" "icg_9"
[81] "icg_10" "icg_11" "icg_12" "icg_13" "icg_14"
[86] "icg_15" "icg_16" "icg_17" "icg_18" "icg_19"
[91] "bdi_1" "bdi_2" "bdi_3" "bdi_4" "bdi_5"
[96] "bdi_6" "bdi_7" "bdi_8" "bdi_9" "bdi_10"
[101] "bdi_11" "bdi_12" "bdi_13" "bdi_14" "bdi_15"
[106] "bdi_16" "bdi_17" "bdi_18" "bdi_19" "bdi_20"
[111] "bdi_21" "hand_1" "hand_2" "hand_3" "hand_4"
[116] "hand_5" "hand_6" "hand_7" "hand_8" "hand_9"
[121] "hand_10" "hand_11" "hand_12" "hand_bat_1" "bisbas_1"
[126] "bisbas_2" "bisbas_3" "bisbas_4" "bisbas_5" "bisbas_6"
[131] "bisbas_7" "bisbas_8" "bisbas_9" "bisbas_10" "bisbas_11"
[136] "bisbas_12" "bisbas_13" "bisbas_14" "bisbas_15" "bisbas_16"
[141] "bisbas_17" "bisbas_18" "bisbas_19" "bisbas_20" "bisbas_21"
[146] "bisbas_22" "bisbas_23" "bisbas_24" "bgq_1" "bgq_2"
[151] "bgq_3" "bgq_4" "bgq_5" "ecrrs_global_1" "ecrrs_global_2"
[156] "ecrrs_global_3" "ecrrs_global_4" "ecrrs_global_5" "ecrrs_global_6" "ecrrs_global_7"
[161] "ecrrs_global_8" "ecrrs_global_9" "ecrrs_spouse_1" "ecrrs_spouse_2" "ecrrs_spouse_3"
[166] "ecrrs_spouse_4" "ecrrs_spouse_5" "ecrrs_spouse_6" "ecrrs_spouse_7" "ecrrs_spouse_8"
[171] "ecrrs_spouse_9" "timesincedeath" "age" "age_yrs" "pss_4r"
[176] "pss_5r" "pss_7r" "pss_8r" "tot_pss" "tot_ysl"
[181] "tot_icg" "bdi_1c" "bdi_2c" "bdi_3c" "bdi_4c"
[186] "bdi_5c" "bdi_6c" "bdi_7c" "bdi_8c" "bdi_9c"
[191] "bdi_10c" "bdi_11c" "bdi_12c" "bdi_13c" "bdi_14c"
[196] "bdi_15c" "bdi_16c" "bdi_17c" "bdi_18c" "bdi_19c"
[201] "bdi_20c" "bdi_21c" "tot_bdi" "hand_1c" "hand_2c"
[206] "hand_3c" "hand_4c" "hand_5c" "hand_6c" "hand_7c"
[211] "hand_8c" "hand_9c" "hand_10c" "hand_11c" "hand_12c"
[216] "hand_bat_1c" "tot_handedness" "bisbas_1r" "bisbas_3r" "bisbas_4r"
[221] "bisbas_5r" "bisbas_6r" "bisbas_7r" "bisbas_8r" "bisbas_9r"
[226] "bisbas_10r" "bisbas_11r" "bisbas_12r" "bisbas_13r" "bisbas_14r"
[231] "bisbas_15r" "bisbas_16r" "bisbas_17r" "bisbas_18r" "bisbas_19r"
[236] "bisbas_20r" "bisbas_21r" "bisbas_23r" "bisbas_24r" "tot_bisbas_basdr"
[241] "tot_bisbas_basfun" "tot_bisbas_basrr" "tot_bisbas_bis" "tot_bgq" "ecrrs_global_1c"
[246] "ecrrs_global_2c" "ecrrs_global_3c" "ecrrs_global_4c" "ecrrs_global_5c" "ecrrs_global_6c"
[251] "ecrrs_global_7c" "ecrrs_global_8c" "ecrrs_global_9c" "ecrrs_global_1r" "ecrrs_global_2r"
[256] "ecrrs_global_3r" "ecrrs_global_4r" "tot_ecrrs_global_avoid" "tot_ecrrs_global_anx" "ecrrs_spouse_1c"
[261] "ecrrs_spouse_2c" "ecrrs_spouse_3c" "ecrrs_spouse_4c" "ecrrs_spouse_5c" "ecrrs_spouse_6c"
[266] "ecrrs_spouse_7c" "ecrrs_spouse_8c" "ecrrs_spouse_9c" "ecrrs_spouse_1r" "ecrrs_spouse_2r"
[271] "ecrrs_spouse_3r" "ecrrs_spouse_4r" "tot_ecrrs_spouse_avoid" "tot_ecrrs_spouse_anx" "ucla_loneliness_1"
[276] "ucla_loneliness_2" "ucla_loneliness_3" "ucla_loneliness_4" "ucla_loneliness_5" "ucla_loneliness_6"
[281] "ucla_loneliness_7" "ucla_loneliness_8" "ucla_loneliness_9" "ucla_loneliness_10" "ucla_loneliness_11"
[286] "ucla_loneliness_12" "ucla_loneliness_13" "ucla_loneliness_14" "ucla_loneliness_15" "ucla_loneliness_16"
[291] "ucla_loneliness_17" "ucla_loneliness_18" "ucla_loneliness_19" "ucla_loneliness_20" "gcq_1"
[296] "gcq_2" "gcq_3" "gcq_4" "gcq_5" "gcq_6"
[301] "gcq_7" "gcq_8" "gcq_9" "gcq_10" "gcq_11"
[306] "gcq_12" "gcq_13" "gcq_14" "gcq_15" "gcq_16"
[311] "gcq_17" "gcq_18" "gcq_19" "gcq_20" "gcq_21"
[316] "gcq_22" "gcq_23" "gcq_24" "gcq_25" "gcq_26"
[321] "gcq_27" "gcq_28" "gcq_29" "gcq_30" "gcq_31"
[326] "gcq_32" "gcq_33" "gcq_34" "gcq_35" "gcq_36"
[331] "gcq_37" "gcq_38" "srrs_1" "srrs_2" "srrs_3"
[336] "srrs_4" "srrs_5" "srrs_6" "srrs_7" "srrs_8"
[341] "srrs_9" "srrs_10" "srrs_11" "srrs_12" "srrs_13"
[346] "srrs_14" "srrs_15" "srrs_16" "srrs_17" "srrs_18"
[351] "srrs_19" "srrs_20" "srrs_21" "srrs_22" "srrs_23"
[356] "srrs_24" "srrs_25" "srrs_26" "srrs_27" "srrs_28"
[361] "srrs_29" "srrs_30" "srrs_31" "srrs_32" "srrs_33"
[366] "srrs_34" "srrs_35" "srrs_36" "srrs_37" "srrs_38"
[371] "srrs_39" "srrs_40" "srrs_41" "srrs_42" "srrs_43"
[376] "srrs_44" "srrs_45" "srrs_46" "srrs_47" "srrs_48"
[381] "srrs_49" "srrs_50" "srrs_51" "ppss_fr_1" "ppss_fr_2"
[386] "ppss_fr_3" "ppss_fr_4" "ppss_fr_5" "ppss_fr_6" "ppss_fr_7"
[391] "ppss_fr_8" "ppss_fr_9" "ppss_fr_10" "ppss_fr_11" "ppss_fr_12"
[396] "ppss_fr_13" "ppss_fr_14" "ppss_fr_15" "ppss_fr_16" "ppss_fr_17"
[401] "ppss_fr_18" "ppss_fr_19" "ppss_fr_20" "ppss_fa_1" "ppss_fa_2"
[406] "ppss_fa_3" "ppss_fa_4" "ppss_fa_5" "ppss_fa_6" "ppss_fa_7"
[411] "ppss_fa_8" "ppss_fa_9" "ppss_fa_10" "ppss_fa_11" "ppss_fa_12"
[416] "ppss_fa_13" "ppss_fa_14" "ppss_fa_15" "ppss_fa_16" "ppss_fa_17"
[421] "ppss_fa_18" "ppss_fa_19" "ppss_fa_20" "tot_srrs_n" "tot_srrs"
[426] "ucla_loneliness_1r" "ucla_loneliness_5r" "ucla_loneliness_6r" "ucla_loneliness_9r" "ucla_loneliness_10r"
[431] "ucla_loneliness_15r" "ucla_loneliness_16r" "ucla_loneliness_19r" "ucla_loneliness_20r" "tot_ucla_loneliness"
[436] "tot_gcq_self" "tot_gcq_world" "tot_gcq_life" "tot_gcq_future" "tot_gcq_blame"
[441] "tot_gcq_others" "tot_gcq_approp" "tot_gcq_cherish" "tot_gcq_threat" "ppss_fr_2r"
[446] "ppss_fr_6r" "ppss_fr_7r" "ppss_fr_15r" "ppss_fr_18r" "ppss_fr_20r"
[451] "tot_ppss_fr" "ppss_fa_3r" "ppss_fa_4r" "ppss_fa_16r" "ppss_fa_19r"
[456] "ppss_fa_20r" "tot_ppss_fa"
This results in 40 observations of 457 variables.
# save it
saveRDS(baseline_all, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/baseline_with_post-baseline.rds")
# Save it as a csv file
write.csv(baseline_all, file = "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/baseline_with_post-baseline.csv")
baseline_NA <- baseline_all %>%
select_if(function(x) any(is.na(x))) %>%
summarise_all(funs(mean(is.na(.)))) # use sum() to find n missing values
baseline_NA_long <- gather(baseline_NA) # create long data that lists variables with any NAs, and % of data missing
# tests for MAR/MCAR? BaylorEdPsych package doesn't work for me...
# equivalent to SUM.x() in SPSS? (only compute SUM if participant has responses on a certain number of items)
# another approach, although this works best with much smaller datasets (too many variables here to visualize)
library(mice)
library(VIM)
aggr = aggr(baseline_4, col=mdc(2:457), numbers=TRUE, sortVars=TRUE, labels=names(baseline_all), cex.axis=.7, gap=3, ylab=c("Proportion of missingness","Missingness Pattern"))
not enough vertical space to display frequencies (too many combinations)
Variables sorted by number of missings:
Variable Count
race_other 0.975
education_other 0.950
lastperiod 0.925
smoking_howlong 0.925
smoking_perday 0.925
majorhealthprobs_what 0.725
postmenopausal_y 0.350
n_livebirths 0.300
n_nursed 0.300
surgeries_past6mos 0.300
meds_dose 0.200
meds_dx 0.175
meds_which 0.150
n_pregnancies 0.100
learnaboutstudy 0.025
meds_y 0.025
past2wks_injuryinfect_y 0.025
allergies 0.025
bdi_1 0.025
bdi_7 0.025
bdi_8 0.025
bdi_9 0.025
bdi_13 0.025
bdi_15 0.025
bdi_19 0.025
hand_3 0.025
bisbas_11 0.025
bisbas_15 0.025
bdi_1c 0.025
bdi_7c 0.025
bdi_8c 0.025
bdi_9c 0.025
bdi_13c 0.025
bdi_15c 0.025
bdi_19c 0.025
hand_3c 0.025
bisbas_15r 0.025
startdate 0.000
ID 0.000
dob 0.000
sex_m 0.000
dateofdeath 0.000
knowbefore_y 0.000
caretaker_y 0.000
education 0.000
highestdegree 0.000
employment 0.000
householdsize 0.000
householdsize_adult 0.000
householdsize_income 0.000
ethnicity_hisp 0.000
race 0.000
majorhealthprobs_y 0.000
past2wks_dentist_y 0.000
currenttx_y 0.000
alcohol 0.000
smoking_y 0.000
caffeine_perday 0.000
exercise 0.000
pss_1 0.000
pss_2 0.000
pss_3 0.000
pss_4 0.000
pss_5 0.000
pss_6 0.000
pss_7 0.000
pss_8 0.000
pss_9 0.000
pss_10 0.000
ysl_1 0.000
ysl_2 0.000
ysl_3 0.000
ysl_4 0.000
ysl_5 0.000
ysl_6 0.000
ysl_7 0.000
ysl_8 0.000
ysl_9 0.000
ysl_10 0.000
ysl_11 0.000
ysl_12 0.000
ysl_13 0.000
ysl_14 0.000
ysl_15 0.000
ysl_16 0.000
ysl_17 0.000
ysl_18 0.000
ysl_19 0.000
ysl_20 0.000
ysl_21 0.000
icg_1 0.000
icg_2 0.000
icg_3 0.000
icg_4 0.000
icg_5 0.000
icg_6 0.000
icg_7 0.000
icg_8 0.000
icg_9 0.000
icg_10 0.000
icg_11 0.000
icg_12 0.000
icg_13 0.000
icg_14 0.000
icg_15 0.000
icg_16 0.000
icg_17 0.000
icg_18 0.000
icg_19 0.000
bdi_2 0.000
bdi_3 0.000
bdi_4 0.000
bdi_5 0.000
bdi_6 0.000
bdi_10 0.000
bdi_11 0.000
bdi_12 0.000
bdi_14 0.000
bdi_16 0.000
bdi_17 0.000
bdi_18 0.000
bdi_20 0.000
bdi_21 0.000
hand_1 0.000
hand_2 0.000
hand_4 0.000
hand_5 0.000
hand_6 0.000
hand_7 0.000
hand_8 0.000
hand_9 0.000
hand_10 0.000
hand_11 0.000
hand_12 0.000
hand_bat_1 0.000
bisbas_1 0.000
bisbas_2 0.000
bisbas_3 0.000
bisbas_4 0.000
bisbas_5 0.000
bisbas_6 0.000
bisbas_7 0.000
bisbas_8 0.000
bisbas_9 0.000
bisbas_10 0.000
bisbas_12 0.000
bisbas_13 0.000
bisbas_14 0.000
bisbas_16 0.000
bisbas_17 0.000
bisbas_18 0.000
bisbas_19 0.000
bisbas_20 0.000
bisbas_21 0.000
bisbas_22 0.000
bisbas_23 0.000
bisbas_24 0.000
bgq_1 0.000
bgq_2 0.000
bgq_3 0.000
bgq_4 0.000
bgq_5 0.000
ecrrs_global_1 0.000
ecrrs_global_2 0.000
ecrrs_global_3 0.000
ecrrs_global_4 0.000
ecrrs_global_5 0.000
ecrrs_global_6 0.000
ecrrs_global_7 0.000
ecrrs_global_8 0.000
ecrrs_global_9 0.000
ecrrs_spouse_1 0.000
ecrrs_spouse_2 0.000
ecrrs_spouse_3 0.000
ecrrs_spouse_4 0.000
ecrrs_spouse_5 0.000
ecrrs_spouse_6 0.000
ecrrs_spouse_7 0.000
ecrrs_spouse_8 0.000
ecrrs_spouse_9 0.000
timesincedeath 0.000
age 0.000
age_yrs 0.000
pss_4r 0.000
pss_5r 0.000
pss_7r 0.000
pss_8r 0.000
tot_pss 0.000
tot_ysl 0.000
tot_icg 0.000
bdi_2c 0.000
bdi_3c 0.000
bdi_4c 0.000
bdi_5c 0.000
bdi_6c 0.000
bdi_10c 0.000
bdi_11c 0.000
bdi_12c 0.000
bdi_14c 0.000
bdi_16c 0.000
bdi_17c 0.000
bdi_18c 0.000
bdi_20c 0.000
bdi_21c 0.000
tot_bdi 0.000
hand_1c 0.000
hand_2c 0.000
hand_4c 0.000
hand_5c 0.000
hand_6c 0.000
hand_7c 0.000
hand_8c 0.000
hand_9c 0.000
hand_10c 0.000
hand_11c 0.000
hand_12c 0.000
hand_bat_1c 0.000
tot_handedness 0.000
bisbas_1r 0.000
bisbas_3r 0.000
bisbas_4r 0.000
bisbas_5r 0.000
bisbas_6r 0.000
bisbas_7r 0.000
bisbas_8r 0.000
bisbas_9r 0.000
bisbas_10r 0.000
bisbas_11r 0.000
bisbas_12r 0.000
bisbas_13r 0.000
bisbas_14r 0.000
bisbas_16r 0.000
bisbas_17r 0.000
bisbas_18r 0.000
bisbas_19r 0.000
bisbas_20r 0.000
bisbas_21r 0.000
bisbas_23r 0.000
bisbas_24r 0.000
tot_bisbas_basdr 0.000
tot_bisbas_basfun 0.000
tot_bisbas_basrr 0.000
tot_bisbas_bis 0.000
tot_bgq 0.000
ecrrs_global_1c 0.000
ecrrs_global_2c 0.000
ecrrs_global_3c 0.000
ecrrs_global_4c 0.000
ecrrs_global_5c 0.000
ecrrs_global_6c 0.000
ecrrs_global_7c 0.000
ecrrs_global_8c 0.000
ecrrs_global_9c 0.000
ecrrs_global_1r 0.000
ecrrs_global_2r 0.000
ecrrs_global_3r 0.000
ecrrs_global_4r 0.000
tot_ecrrs_global_avoid 0.000
tot_ecrrs_global_anx 0.000
ecrrs_spouse_1c 0.000
ecrrs_spouse_2c 0.000
ecrrs_spouse_3c 0.000
ecrrs_spouse_4c 0.000
ecrrs_spouse_5c 0.000
ecrrs_spouse_6c 0.000
ecrrs_spouse_7c 0.000
ecrrs_spouse_8c 0.000
ecrrs_spouse_9c 0.000
ecrrs_spouse_1r 0.000
ecrrs_spouse_2r 0.000
ecrrs_spouse_3r 0.000
ecrrs_spouse_4r 0.000
tot_ecrrs_spouse_avoid 0.000
tot_ecrrs_spouse_anx 0.000
We have 86/457 variables missing some amount of data, though some are because the question doesn’t apply (e.g., education_other or lastperiod), and others are because “don’t know” was recoded as NA and not scored for the PPSS. One person missed BDI item 9 (suicidality), which may not be at random…
This section of the script deals with the surveys that participants completed pre- and post-fMRI. Data from the two visits were entered as (e.g.) D141 at visit 1 and D141_b at visit 2, so need to organize data such that rather than one variable for two cases, there are two variables for one case. Each participant returned for two fMRI sessions, so variables appended “_v1” are from the first visit, and variables appended “_v2” are from the second visit.
What has been done up to this point: (1) codebook created, (2) data exported from Qualtrics.
Task: Import data from CSV files except for the first 17 columns (1:17 is just Qualtrics junk).
# run install.packages("tidyverse") if this is the first time using dplyr on your local machine
library(tidyverse)
filter <- dplyr::filter
select <- dplyr::select
pre_fmri <- read.csv("~/Dropbox/GLASS Lab/OT Study/data/raw-data/OT+fMRI+At+The+Scanner_January+18%2C+2019_14.22.csv", stringsAsFactors = FALSE, na.strings="")[ ,-c(2:17)]
post_fmri <- read.csv("~/Dropbox/GLASS Lab/OT Study/data/raw-data/OT+fMRI+At+The+Scanner+Post-Scan_January+18%2C+2019_14.23.csv", stringsAsFactors = FALSE, na.strings="")[ ,-c(2:17)]
# na.strings = "" replaces all instances where missing data is represented by blank cells with NA, which is how R handles missing values.
View(pre_fmri)
View(post_fmri)
NOTE: In
pre_fmri, there were two cases labeled “D115_b” with non-matching data. Figured out that this is because D115_b completed the pre survey before AND after the scan (rather than completing the post survey after). I kept the case that starts Q176_1 = 4, Q176_2 = 1, Q176_3 = 2… as D115_b and changed the other to D115_b_post. Why? According to the raw AAT data, the task was run at 2:15pm and 2:25pm. In Qualtrics, the first (now D115_b) was completed at 1:15pm and the second (now D115_b_post) was completed at 2:55pm (both on 2/12/2016). These two cases need to be separated out and dealt with later.
post_fmri_0 <- post_fmri %>% filter(grepl("^D1", ID, ignore.case = TRUE))
View(post_fmri_0)
# Save it so we don't need to go through all THAT again
write.csv(post_fmri_0, file = "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/post_fmri_0.csv")
# There are two variables at the end of post_fmri that are also Qualtrics junk.
# Get their names and remove them:
names(post_fmri_0)
[1] "StartDate" "ID" "Q176_1" "Q176_2" "Q176_3" "Q176_4" "Q176_5" "Q176_6"
[9] "Q176_7" "Q176_8" "Q176_9" "Q176_10" "Q176_11" "Q176_12" "Q176_13" "Q176_14"
[17] "Q176_15" "Q176_16" "Q176_17" "Q176_18" "Q176_19" "Q176_20" "STAI.S_1" "STAI.S_2"
[25] "STAI.S_3" "STAI.S_4" "STAI.S_5" "STAI.S_6" "STAI.S_7" "STAI.S_8" "STAI.S_9" "STAI.S_10"
[33] "STAI.S_11" "STAI.S_12" "STAI.S_13" "STAI.S_14" "STAI.S_15" "STAI.S_16" "STAI.S_17" "STAI.S_18"
[41] "STAI.S_19" "STAI.S_20" "SROE.1" "SROE.2" "Q7" "ID...Topics" "SROE.2...Topics"
post_fmri_0$ID...Topics <- NULL
post_fmri_0$SROE.2...Topics <- NULL
# also remove StartDate
post_fmri_0$StartDate <- NULL
write.csv(post_fmri_0, file = "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/post_fmri_0.csv") # 80 observations of 44 variables
The name to the left of the equal sign is the new name, the one on the right is what the variable was named in Qualtrics.
#### PRE-FMRI
pre_fmri_1 <- rename(pre_fmri_0, ID = ID, pre_panas_1 = Q176_1,
pre_panas_2 = Q176_2,
pre_panas_3 = Q176_3,
pre_panas_4 = Q176_4,
pre_panas_5 = Q176_5,
pre_panas_6 = Q176_6,
pre_panas_7 = Q176_7,
pre_panas_8 = Q176_8,
pre_panas_9 = Q176_9,
pre_panas_10 = Q176_10,
pre_panas_11 = Q176_11,
pre_panas_12 = Q176_12,
pre_panas_13 = Q176_13,
pre_panas_14 = Q176_14,
pre_panas_15 = Q176_15,
pre_panas_16 = Q176_16,
pre_panas_17 = Q176_17,
pre_panas_18 = Q176_18,
pre_panas_19 = Q176_19,
pre_panas_20 = Q176_20,
pre_stai_1 = STAI.S_1,
pre_stai_2 = STAI.S_2,
pre_stai_3 = STAI.S_3,
pre_stai_4 = STAI.S_4,
pre_stai_5 = STAI.S_5,
pre_stai_6 = STAI.S_6,
pre_stai_7 = STAI.S_7,
pre_stai_8 = STAI.S_8,
pre_stai_9 = STAI.S_9,
pre_stai_10 = STAI.S_10,
pre_stai_11 = STAI.S_11,
pre_stai_12 = STAI.S_12,
pre_stai_13 = STAI.S_13,
pre_stai_14 = STAI.S_14,
pre_stai_15 = STAI.S_15,
pre_stai_16 = STAI.S_16,
pre_stai_17 = STAI.S_17,
pre_stai_18 = STAI.S_18,
pre_stai_19 = STAI.S_19,
pre_stai_20 = STAI.S_20
)
# Make all of the variables (except ID) numeric rather than chr:
pre_fmri_1 <- pre_fmri_1 %>% mutate_at(vars(-ID), funs(as.numeric))
# Check it out:
names(pre_fmri_1)
[1] "ID" "pre_panas_1" "pre_panas_2" "pre_panas_3" "pre_panas_4" "pre_panas_5" "pre_panas_6" "pre_panas_7" "pre_panas_8" "pre_panas_9"
[11] "pre_panas_10" "pre_panas_11" "pre_panas_12" "pre_panas_13" "pre_panas_14" "pre_panas_15" "pre_panas_16" "pre_panas_17" "pre_panas_18" "pre_panas_19"
[21] "pre_panas_20" "pre_stai_1" "pre_stai_2" "pre_stai_3" "pre_stai_4" "pre_stai_5" "pre_stai_6" "pre_stai_7" "pre_stai_8" "pre_stai_9"
[31] "pre_stai_10" "pre_stai_11" "pre_stai_12" "pre_stai_13" "pre_stai_14" "pre_stai_15" "pre_stai_16" "pre_stai_17" "pre_stai_18" "pre_stai_19"
[41] "pre_stai_20"
str(pre_fmri_1)
'data.frame': 85 obs. of 41 variables:
$ ID : chr "D101" "D101_b" "D102" "D102_b" ...
$ pre_panas_1 : num 4 4 5 5 5 5 4 4 4 5 ...
$ pre_panas_2 : num 1 1 2 1 3 3 1 1 1 2 ...
$ pre_panas_3 : num 2 1 4 4 3 3 3 3 3 3 ...
$ pre_panas_4 : num 1 1 1 1 2 3 1 1 1 2 ...
$ pre_panas_5 : num 3 3 4 5 3 2 4 4 1 3 ...
$ pre_panas_6 : num 1 1 1 1 1 1 1 1 2 1 ...
$ pre_panas_7 : num 1 1 3 1 3 3 2 1 2 1 ...
$ pre_panas_8 : num 1 1 1 1 1 1 1 1 1 1 ...
$ pre_panas_9 : num 4 2 5 5 5 3 3 4 3 4 ...
$ pre_panas_10: num 1 1 4 4 2 3 3 4 2 2 ...
$ pre_panas_11: num 1 1 1 1 1 1 1 1 1 1 ...
$ pre_panas_12: num 4 4 5 5 5 4 4 3 4 5 ...
$ pre_panas_13: num 1 1 1 1 1 1 1 1 1 1 ...
$ pre_panas_14: num 2 2 4 5 3 3 3 4 1 2 ...
$ pre_panas_15: num 1 1 2 2 4 3 3 1 3 3 ...
$ pre_panas_16: num 3 4 4 5 5 4 3 4 1 3 ...
$ pre_panas_17: num 4 4 5 5 5 4 4 4 2 5 ...
$ pre_panas_18: num 1 1 1 1 4 3 3 2 1 2 ...
$ pre_panas_19: num 4 4 3 5 4 2 4 5 1 3 ...
$ pre_panas_20: num 1 1 1 1 3 3 2 1 1 1 ...
$ pre_stai_1 : num 4 4 3 3 2 2 3 4 3 3 ...
$ pre_stai_2 : num 4 4 4 4 3 2 4 4 3 3 ...
$ pre_stai_3 : num 1 1 2 1 3 3 2 1 2 2 ...
$ pre_stai_4 : num 1 1 1 1 3 2 2 1 1 1 ...
$ pre_stai_5 : num 4 4 3 4 2 2 3 3 2 2 ...
$ pre_stai_6 : num 1 1 1 1 2 2 1 1 1 2 ...
$ pre_stai_7 : num 1 4 1 1 4 4 1 1 1 2 ...
$ pre_stai_8 : num 4 4 4 3 1 1 3 4 2 4 ...
$ pre_stai_9 : num 1 1 1 1 3 2 1 1 1 1 ...
$ pre_stai_10 : num 4 4 3 4 2 2 4 3 3 3 ...
$ pre_stai_11 : num 4 4 4 4 2 3 2 4 2 3 ...
$ pre_stai_12 : num 1 1 1 1 3 2 1 1 2 2 ...
$ pre_stai_13 : num 1 1 1 1 3 2 1 1 1 2 ...
$ pre_stai_14 : num 1 1 2 3 1 1 2 1 1 1 ...
$ pre_stai_15 : num 4 4 1 4 1 1 4 4 2 3 ...
$ pre_stai_16 : num 4 4 4 3 1 1 3 4 2 3 ...
$ pre_stai_17 : num 1 1 1 1 4 3 1 1 2 2 ...
$ pre_stai_18 : num 1 1 3 1 4 2 1 1 1 1 ...
$ pre_stai_19 : num 4 3 3 4 2 2 4 4 3 3 ...
$ pre_stai_20 : num 3 3 3 4 1 2 4 4 3 4 ...
# Save it:
saveRDS(pre_fmri_1, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/pre_fmri_1.rds")
#### POST-FMRI
post_fmri_1 <- rename(post_fmri_0, ID = ID, post_panas_1 = Q176_1,
post_panas_2 = Q176_2,
post_panas_3 = Q176_3,
post_panas_4 = Q176_4,
post_panas_5 = Q176_5,
post_panas_6 = Q176_6,
post_panas_7 = Q176_7,
post_panas_8 = Q176_8,
post_panas_9 = Q176_9,
post_panas_10 = Q176_10,
post_panas_11 = Q176_11,
post_panas_12 = Q176_12,
post_panas_13 = Q176_13,
post_panas_14 = Q176_14,
post_panas_15 = Q176_15,
post_panas_16 = Q176_16,
post_panas_17 = Q176_17,
post_panas_18 = Q176_18,
post_panas_19 = Q176_19,
post_panas_20 = Q176_20,
post_stai_1 = STAI.S_1,
post_stai_2 = STAI.S_2,
post_stai_3 = STAI.S_3,
post_stai_4 = STAI.S_4,
post_stai_5 = STAI.S_5,
post_stai_6 = STAI.S_6,
post_stai_7 = STAI.S_7,
post_stai_8 = STAI.S_8,
post_stai_9 = STAI.S_9,
post_stai_10 = STAI.S_10,
post_stai_11 = STAI.S_11,
post_stai_12 = STAI.S_12,
post_stai_13 = STAI.S_13,
post_stai_14 = STAI.S_14,
post_stai_15 = STAI.S_15,
post_stai_16 = STAI.S_16,
post_stai_17 = STAI.S_17,
post_stai_18 = STAI.S_18,
post_stai_19 = STAI.S_19,
post_stai_20 = STAI.S_20,
post_sroe_1 = SROE.1,
post_sroe_2 = SROE.2,
post_sroe_3 = Q7
)
# Make all of the variables (except ID and SROE 1 and 2 vars) numeric rather than chr:
post_fmri_1 <- post_fmri_1 %>% mutate_at(vars(-c(ID,post_sroe_1,post_sroe_2)), funs(as.numeric))
# Check it out:
names(post_fmri_1)
[1] "ID" "post_panas_1" "post_panas_2" "post_panas_3" "post_panas_4" "post_panas_5" "post_panas_6" "post_panas_7" "post_panas_8"
[10] "post_panas_9" "post_panas_10" "post_panas_11" "post_panas_12" "post_panas_13" "post_panas_14" "post_panas_15" "post_panas_16" "post_panas_17"
[19] "post_panas_18" "post_panas_19" "post_panas_20" "post_stai_1" "post_stai_2" "post_stai_3" "post_stai_4" "post_stai_5" "post_stai_6"
[28] "post_stai_7" "post_stai_8" "post_stai_9" "post_stai_10" "post_stai_11" "post_stai_12" "post_stai_13" "post_stai_14" "post_stai_15"
[37] "post_stai_16" "post_stai_17" "post_stai_18" "post_stai_19" "post_stai_20" "post_sroe_1" "post_sroe_2" "post_sroe_3"
str(post_fmri_1)
'data.frame': 81 obs. of 44 variables:
$ ID : chr "D101" "D101_b" "D102" "D102_b" ...
$ post_panas_1 : num 3 3 5 5 5 5 4 5 3 2 ...
$ post_panas_2 : num 1 1 1 1 1 1 2 1 1 2 ...
$ post_panas_3 : num 1 1 3 5 3 3 3 4 3 1 ...
$ post_panas_4 : num 1 1 2 1 1 1 1 1 1 1 ...
$ post_panas_5 : num 3 2 4 5 4 2 4 5 2 3 ...
$ post_panas_6 : num 1 1 1 1 1 1 1 1 2 1 ...
$ post_panas_7 : num 1 1 1 1 1 1 2 1 1 1 ...
$ post_panas_8 : num 1 1 1 1 1 1 1 1 1 1 ...
$ post_panas_9 : num 2 2 4 5 5 3 3 4 3 4 ...
$ post_panas_10: num 1 1 4 4 3 3 4 5 2 2 ...
$ post_panas_11: num 1 1 1 1 1 1 1 1 1 1 ...
$ post_panas_12: num 3 5 4 5 4 4 4 4 3 3 ...
$ post_panas_13: num 1 1 1 1 1 1 1 1 1 1 ...
$ post_panas_14: num 2 1 4 4 3 3 3 4 2 2 ...
$ post_panas_15: num 1 1 1 2 2 2 1 1 2 2 ...
$ post_panas_16: num 2 1 4 5 5 3 4 5 2 3 ...
$ post_panas_17: num 3 5 3 5 4 4 3 4 3 3 ...
$ post_panas_18: num 1 1 1 2 2 2 1 1 1 1 ...
$ post_panas_19: num 3 3 3 5 3 3 4 5 2 3 ...
$ post_panas_20: num 1 1 1 1 1 1 1 1 1 1 ...
$ post_stai_1 : num 4 3 4 3 2 2 4 4 3 2 ...
$ post_stai_2 : num 4 4 4 4 3 3 4 4 3 3 ...
$ post_stai_3 : num 1 1 1 1 2 1 1 1 2 2 ...
$ post_stai_4 : num 1 1 1 1 1 1 1 1 1 1 ...
$ post_stai_5 : num 4 4 4 4 3 3 4 4 2 3 ...
$ post_stai_6 : num 1 1 1 1 1 1 1 1 1 1 ...
$ post_stai_7 : num 1 1 1 1 4 3 1 1 1 2 ...
$ post_stai_8 : num 2 4 3 3 2 2 3 4 3 3 ...
$ post_stai_9 : num 1 1 1 1 2 1 1 1 1 1 ...
$ post_stai_10 : num 3 3 4 4 3 3 3 4 3 4 ...
$ post_stai_11 : num 3 4 4 4 3 3 4 4 3 3 ...
$ post_stai_12 : num 1 1 1 2 2 2 2 1 2 2 ...
$ post_stai_13 : num 1 1 1 1 2 1 1 1 1 1 ...
$ post_stai_14 : num 1 1 1 1 1 1 1 1 1 2 ...
$ post_stai_15 : num 4 3 4 4 3 2 4 4 3 3 ...
$ post_stai_16 : num 2 4 4 3 3 2 4 3 2 3 ...
$ post_stai_17 : num 1 1 1 1 2 2 1 1 2 2 ...
$ post_stai_18 : num 1 1 1 1 1 1 4 1 2 1 ...
$ post_stai_19 : num 3 3 3 3 3 2 4 4 3 3 ...
$ post_stai_20 : num 2 3 4 4 3 3 4 4 3 4 ...
$ post_sroe_1 : chr "The first time I saw the photo of Julie and her new glasses, it took my breath away because that's an incredibly characteristic"| __truncated__ "This time I was far more focused on the frame and only made a couple of conscious errors with the joystick." "inrent" "focused" ...
$ post_sroe_2 : chr "I was trying not to look at the photos and struggling with that. I noticed that the male looked vaguely like me in that he was "| __truncated__ "I was trying hard NOT to look at the pictures but focus on the task. This may have been easier since I already was familiar wit"| __truncated__ "trying to concentrate on the frame not the pictures, but the coffin was very stark" "concentrating on the frames" ...
$ post_sroe_3 : num 20 19 19 19 19 20 19 17 19 20 ...
# Save it:
saveRDS(post_fmri_1, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/post_fmri_1.rds")
# For this section, you'll need the 'psych' package
## install.packages("psych") if you don't have it on this machine
library(psych)
pre_fmri_2 <- pre_fmri_1 # pre_fmri_2 will contain the scored measures
##################
### Positive and Negative Affect Schedule (PANAS) – State Version
# Citation: Watson, D., Clark, L. A., & Tellegen, A. (1988). Development and validation of brief measures of positive and negative affect: the PANAS scales. Journal of Personality and Social Psychology, 54(6), 1063.
# Answer choices range from 1 (Very slightly or not at all) – 4 (Extremely).
# No reverse-scored items.
# Positive affect: 1, 3, 5, 9, 10, 12, 14, 16, 17, 19 [tot_pre_panas_pa]
# Negative affect: 2, 4, 6, 7, 8, 11, 13, 15, 18, 20 [tot_pre_panas_na]
# total score:
tot_pre_panas_pa <- subset(pre_fmri_2, select=c("pre_panas_1","pre_panas_3", "pre_panas_5", "pre_panas_9","pre_panas_10","pre_panas_12","pre_panas_14","pre_panas_16","pre_panas_17","pre_panas_19"))
tot_pre_panas_na <- subset(pre_fmri_2, select=c("pre_panas_2","pre_panas_4", "pre_panas_6", "pre_panas_7","pre_panas_8","pre_panas_11","pre_panas_13","pre_panas_15","pre_panas_18","pre_panas_20"))
pre_fmri_2$tot_pre_panas_pa <- rowSums(tot_pre_panas_pa, na.rm=TRUE)
describe(pre_fmri_2$tot_pre_panas_pa)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 85 33.46 6.85 33 33.45 7.41 14 50 36 0.05 -0.08 0.74
pre_fmri_2$tot_pre_panas_na <- rowSums(tot_pre_panas_na, na.rm=TRUE)
describe(pre_fmri_2$tot_pre_panas_na)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 85 12.86 3.48 12 12.26 2.97 10 27 17 1.59 2.65 0.38
##################
### State-Trait Anxiety Inventory (STAI) – State Version
# Citation: Spielberger, C.D. (1983). Manual for the State-Trait Anxiety Inventory (STAI). Palo Alto, CA: Consulting Psychologists Press.
# Answer choices range from 1 (Not at all) – 4 (Very much so).
# Reverse-scored: 1, 2, 5, 8, 10, 11, 15, 16, 19, 20.
# Sum total score [tot_pre_stai]
pre_fmri_2$pre_stai_1r <- 5 - pre_fmri_2$pre_stai_1
pre_fmri_2$pre_stai_2r <- 5 - pre_fmri_2$pre_stai_2
pre_fmri_2$pre_stai_5r <- 5 - pre_fmri_2$pre_stai_5
pre_fmri_2$pre_stai_8r <- 5 - pre_fmri_2$pre_stai_8
pre_fmri_2$pre_stai_10r <- 5 - pre_fmri_2$pre_stai_10
pre_fmri_2$pre_stai_11r <- 5 - pre_fmri_2$pre_stai_11
pre_fmri_2$pre_stai_15r <- 5 - pre_fmri_2$pre_stai_15
pre_fmri_2$pre_stai_16r <- 5 - pre_fmri_2$pre_stai_16
pre_fmri_2$pre_stai_19r <- 5 - pre_fmri_2$pre_stai_19
pre_fmri_2$pre_stai_20r <- 5 - pre_fmri_2$pre_stai_20
# total score:
tot_pre_stai <- subset(pre_fmri_2, select=c("pre_stai_1r","pre_stai_2r","pre_stai_3","pre_stai_4","pre_stai_5r","pre_stai_6","pre_stai_7","pre_stai_8r", "pre_stai_9","pre_stai_10r","pre_stai_11r","pre_stai_12","pre_stai_13","pre_stai_14","pre_stai_15r","pre_stai_16r","pre_stai_17","pre_stai_18","pre_stai_19r","pre_stai_20r"))
pre_fmri_2$tot_pre_stai <- rowSums(tot_pre_stai, na.rm=TRUE)
describe(pre_fmri_2$tot_pre_stai)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 85 32.28 9.38 31 31.2 8.9 20 63 43 1.05 1.04 1.02
# check that all "tot_*" variables appear
names(pre_fmri_2)
[1] "ID" "pre_panas_1" "pre_panas_2" "pre_panas_3" "pre_panas_4" "pre_panas_5" "pre_panas_6" "pre_panas_7"
[9] "pre_panas_8" "pre_panas_9" "pre_panas_10" "pre_panas_11" "pre_panas_12" "pre_panas_13" "pre_panas_14" "pre_panas_15"
[17] "pre_panas_16" "pre_panas_17" "pre_panas_18" "pre_panas_19" "pre_panas_20" "pre_stai_1" "pre_stai_2" "pre_stai_3"
[25] "pre_stai_4" "pre_stai_5" "pre_stai_6" "pre_stai_7" "pre_stai_8" "pre_stai_9" "pre_stai_10" "pre_stai_11"
[33] "pre_stai_12" "pre_stai_13" "pre_stai_14" "pre_stai_15" "pre_stai_16" "pre_stai_17" "pre_stai_18" "pre_stai_19"
[41] "pre_stai_20" "tot_pre_panas_pa" "tot_pre_panas_na" "pre_stai_1r" "pre_stai_2r" "pre_stai_5r" "pre_stai_8r" "pre_stai_10r"
[49] "pre_stai_11r" "pre_stai_15r" "pre_stai_16r" "pre_stai_19r" "pre_stai_20r" "tot_pre_stai"
# save the cleaned and scored data
saveRDS(pre_fmri_2, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/pre_fmri_2.rds")
post_fmri_2 <- post_fmri_1 # post_fmri_2 will contain the scored measures
# Recode the sroe_3 item (rate task difficulty).
# Should be on scale of 1 (easy) to 5 (nearly impossible)
# No one endorsed "nearly impossible"
post_fmri_2 <- post_fmri_2 %>% mutate(post_sroe_3 = as.numeric(recode(post_sroe_3, "17" = "1", "19" = "2", "20" = "3", "21" = "4")))
##################
### Positive and Negative Affect Schedule (PANAS) – State Version
# Citation: Watson, D., Clark, L. A., & Tellegen, A. (1988). Development and validation of brief measures of positive and negative affect: the PANAS scales. Journal of Personality and Social Psychology, 54(6), 1063.
# Answer choices range from 1 (Very slightly or not at all) – 4 (Extremely).
# No reverse-scored items.
# Positive affect: 1, 3, 5, 9, 10, 12, 14, 16, 17, 19 [tot_post_panas_pa]
# Negative affect: 2, 4, 6, 7, 8, 11, 13, 15, 18, 20 [tot_post_panas_na]
# total score:
tot_post_panas_pa <- subset(post_fmri_2, select=c("post_panas_1","post_panas_3", "post_panas_5", "post_panas_9","post_panas_10","post_panas_12","post_panas_14","post_panas_16","post_panas_17","post_panas_19"))
tot_post_panas_na <- subset(post_fmri_2, select=c("post_panas_2","post_panas_4", "post_panas_6", "post_panas_7","post_panas_8","post_panas_11","post_panas_13","post_panas_15","post_panas_18","post_panas_20"))
post_fmri_2$tot_post_panas_pa <- rowSums(tot_post_panas_pa, na.rm=TRUE)
describe(post_fmri_2$tot_post_panas_pa)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 81 33.57 7.48 33 33.43 7.41 17 50 33 0.09 -0.62 0.83
post_fmri_2$tot_post_panas_na <- rowSums(tot_post_panas_na, na.rm=TRUE)
describe(post_fmri_2$tot_post_panas_na)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 81 11.33 1.86 10 10.97 0 10 19 9 1.69 3.01 0.21
##################
### State-Trait Anxiety Inventory (STAI) – State Version
# Citation: Spielberger, C.D. (1983). Manual for the State-Trait Anxiety Inventory (STAI). Palo Alto, CA: Consulting Psychologists Press.
# Answer choices range from 1 (Not at all) – 4 (Very much so).
# Reverse-scored: 1, 2, 5, 8, 10, 11, 15, 16, 19, 20.
# Sum total score [tot_post_stai]
post_fmri_2$post_stai_1r <- 5 - post_fmri_2$post_stai_1
post_fmri_2$post_stai_2r <- 5 - post_fmri_2$post_stai_2
post_fmri_2$post_stai_5r <- 5 - post_fmri_2$post_stai_5
post_fmri_2$post_stai_8r <- 5 - post_fmri_2$post_stai_8
post_fmri_2$post_stai_10r <- 5 - post_fmri_2$post_stai_10
post_fmri_2$post_stai_11r <- 5 - post_fmri_2$post_stai_11
post_fmri_2$post_stai_15r <- 5 - post_fmri_2$post_stai_15
post_fmri_2$post_stai_16r <- 5 - post_fmri_2$post_stai_16
post_fmri_2$post_stai_19r <- 5 - post_fmri_2$post_stai_19
post_fmri_2$post_stai_20r <- 5 - post_fmri_2$post_stai_20
# total score:
tot_post_stai <- subset(post_fmri_2, select=c("post_stai_1r","post_stai_2r","post_stai_3","post_stai_4","post_stai_5r","post_stai_6","post_stai_7","post_stai_8r", "post_stai_9","post_stai_10r","post_stai_11r","post_stai_12","post_stai_13","post_stai_14","post_stai_15r","post_stai_16r","post_stai_17","post_stai_18","post_stai_19r","post_stai_20r"))
post_fmri_2$tot_post_stai <- rowSums(tot_post_stai, na.rm=TRUE)
describe(post_fmri_2$tot_post_stai)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 81 29.99 8.34 28 29 7.41 20 61 41 1.18 1.44 0.93
# check that all "tot_*" variables appear
names(post_fmri_2)
[1] "ID" "post_panas_1" "post_panas_2" "post_panas_3" "post_panas_4" "post_panas_5" "post_panas_6"
[8] "post_panas_7" "post_panas_8" "post_panas_9" "post_panas_10" "post_panas_11" "post_panas_12" "post_panas_13"
[15] "post_panas_14" "post_panas_15" "post_panas_16" "post_panas_17" "post_panas_18" "post_panas_19" "post_panas_20"
[22] "post_stai_1" "post_stai_2" "post_stai_3" "post_stai_4" "post_stai_5" "post_stai_6" "post_stai_7"
[29] "post_stai_8" "post_stai_9" "post_stai_10" "post_stai_11" "post_stai_12" "post_stai_13" "post_stai_14"
[36] "post_stai_15" "post_stai_16" "post_stai_17" "post_stai_18" "post_stai_19" "post_stai_20" "post_sroe_1"
[43] "post_sroe_2" "post_sroe_3" "tot_post_panas_pa" "tot_post_panas_na" "post_stai_1r" "post_stai_2r" "post_stai_5r"
[50] "post_stai_8r" "post_stai_10r" "post_stai_11r" "post_stai_15r" "post_stai_16r" "post_stai_19r" "post_stai_20r"
[57] "tot_post_stai"
# save the cleaned and scored data
saveRDS(post_fmri_2, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/post_fmri_2.rds")
Now we need to create two subsets: one for the first visit, one for the second visit (we’ll put them back together later).
# pre_fmri, first visit:
pre_fmri_v1 <- filter(pre_fmri_2, !grepl("_b",ID)) # i.e., filter if does not contain string "_b"
View(pre_fmri_v1)
# pre_fmri, second visit:
pre_fmri_v2 <- filter(pre_fmri_2, grepl("_b",ID))
View(pre_fmri_v2)
names(pre_fmri_v2)
[1] "ID" "pre_panas_1" "pre_panas_2" "pre_panas_3" "pre_panas_4" "pre_panas_5" "pre_panas_6" "pre_panas_7"
[9] "pre_panas_8" "pre_panas_9" "pre_panas_10" "pre_panas_11" "pre_panas_12" "pre_panas_13" "pre_panas_14" "pre_panas_15"
[17] "pre_panas_16" "pre_panas_17" "pre_panas_18" "pre_panas_19" "pre_panas_20" "pre_stai_1" "pre_stai_2" "pre_stai_3"
[25] "pre_stai_4" "pre_stai_5" "pre_stai_6" "pre_stai_7" "pre_stai_8" "pre_stai_9" "pre_stai_10" "pre_stai_11"
[33] "pre_stai_12" "pre_stai_13" "pre_stai_14" "pre_stai_15" "pre_stai_16" "pre_stai_17" "pre_stai_18" "pre_stai_19"
[41] "pre_stai_20" "tot_pre_panas_pa" "tot_pre_panas_na" "pre_stai_1r" "pre_stai_2r" "pre_stai_5r" "pre_stai_8r" "pre_stai_10r"
[49] "pre_stai_11r" "pre_stai_15r" "pre_stai_16r" "pre_stai_19r" "pre_stai_20r" "tot_pre_stai"
# post_fmri, first visit:
post_fmri_v1 <- filter(post_fmri_2, !grepl("_b",ID))
View(post_fmri_v1)
# post_fmri, second visit:
post_fmri_v2 <- filter(post_fmri_2, grepl("_b",ID))
View(post_fmri_v2)
# Remove "_b" from the second visit datasets so that we can merge _v1 and _v2 back together eventually
pre_fmri_v2 <- pre_fmri_v2 %>%
mutate(ID = str_replace(ID, "_b", ""))
post_fmri_v2 <- post_fmri_v2 %>%
mutate(ID = str_replace(ID, "_b", ""))
# Add a suffix to the end of variables denoting which visit:
pre_fmri_v1 <- pre_fmri_v1 %>%
rename_at(vars(-ID),function(x) paste0(x,"_v1"))
pre_fmri_v2 <- pre_fmri_v2 %>%
rename_at(vars(-ID),function(x) paste0(x,"_v2"))
post_fmri_v1 <- post_fmri_v1 %>%
rename_at(vars(-ID),function(x) paste0(x,"_v1"))
post_fmri_v2 <- post_fmri_v2 %>%
rename_at(vars(-ID),function(x) paste0(x,"_v2"))
Then, dealing with D115_b’s post-fMRI data that’s in the pre_fmri dataset…
D115_post_fmri_v2 <- filter(pre_fmri_2, grepl("post",ID)) # i.e., filter if does not contain string "post"
View(D115_post_fmri_v2)
D115_post_fmri_v2 <- D115_post_fmri_v2 %>% mutate(ID = recode(ID, "D115_b_post" = "D115")) # changed D115_b_post to D115
# rename "pre" to "post"
names(D115_post_fmri_v2) <- gsub("pre", "post", names(D115_post_fmri_v2))
names(D115_post_fmri_v2) # it worked!
[1] "ID" "post_panas_1" "post_panas_2" "post_panas_3" "post_panas_4" "post_panas_5" "post_panas_6"
[8] "post_panas_7" "post_panas_8" "post_panas_9" "post_panas_10" "post_panas_11" "post_panas_12" "post_panas_13"
[15] "post_panas_14" "post_panas_15" "post_panas_16" "post_panas_17" "post_panas_18" "post_panas_19" "post_panas_20"
[22] "post_stai_1" "post_stai_2" "post_stai_3" "post_stai_4" "post_stai_5" "post_stai_6" "post_stai_7"
[29] "post_stai_8" "post_stai_9" "post_stai_10" "post_stai_11" "post_stai_12" "post_stai_13" "post_stai_14"
[36] "post_stai_15" "post_stai_16" "post_stai_17" "post_stai_18" "post_stai_19" "post_stai_20" "tot_post_panas_pa"
[43] "tot_post_panas_na" "post_stai_1r" "post_stai_2r" "post_stai_5r" "post_stai_8r" "post_stai_10r" "post_stai_11r"
[50] "post_stai_15r" "post_stai_16r" "post_stai_19r" "post_stai_20r" "tot_post_stai"
# add a suffix to the end of variables denoting second visit:
D115_post_fmri_v2 <- D115_post_fmri_v2 %>%
rename_at(vars(-ID),function(x) paste0(x,"_v2"))
# attach back to post_fmri_v2
post_fmri_v2 <- bind_rows(D115_post_fmri_v2,post_fmri_v2)
View(post_fmri_v2)
# and finally, drop D115_post from the (incorrect) pre-fmri visit 2 dataset
pre_fmri_v2 <- filter(pre_fmri_v2, !grepl("post",ID))
Merging first and second visits back together…
### PRE
## Put them back together
pre_fmri_3 <- left_join(pre_fmri_v1, pre_fmri_v2, by="ID") # merge pre_v1 and pre_v2 by ID
View(pre_fmri_3)
names(pre_fmri_3)
[1] "ID" "pre_panas_1_v1" "pre_panas_2_v1" "pre_panas_3_v1" "pre_panas_4_v1" "pre_panas_5_v1"
[7] "pre_panas_6_v1" "pre_panas_7_v1" "pre_panas_8_v1" "pre_panas_9_v1" "pre_panas_10_v1" "pre_panas_11_v1"
[13] "pre_panas_12_v1" "pre_panas_13_v1" "pre_panas_14_v1" "pre_panas_15_v1" "pre_panas_16_v1" "pre_panas_17_v1"
[19] "pre_panas_18_v1" "pre_panas_19_v1" "pre_panas_20_v1" "pre_stai_1_v1" "pre_stai_2_v1" "pre_stai_3_v1"
[25] "pre_stai_4_v1" "pre_stai_5_v1" "pre_stai_6_v1" "pre_stai_7_v1" "pre_stai_8_v1" "pre_stai_9_v1"
[31] "pre_stai_10_v1" "pre_stai_11_v1" "pre_stai_12_v1" "pre_stai_13_v1" "pre_stai_14_v1" "pre_stai_15_v1"
[37] "pre_stai_16_v1" "pre_stai_17_v1" "pre_stai_18_v1" "pre_stai_19_v1" "pre_stai_20_v1" "tot_pre_panas_pa_v1"
[43] "tot_pre_panas_na_v1" "pre_stai_1r_v1" "pre_stai_2r_v1" "pre_stai_5r_v1" "pre_stai_8r_v1" "pre_stai_10r_v1"
[49] "pre_stai_11r_v1" "pre_stai_15r_v1" "pre_stai_16r_v1" "pre_stai_19r_v1" "pre_stai_20r_v1" "tot_pre_stai_v1"
[55] "pre_panas_1_v2" "pre_panas_2_v2" "pre_panas_3_v2" "pre_panas_4_v2" "pre_panas_5_v2" "pre_panas_6_v2"
[61] "pre_panas_7_v2" "pre_panas_8_v2" "pre_panas_9_v2" "pre_panas_10_v2" "pre_panas_11_v2" "pre_panas_12_v2"
[67] "pre_panas_13_v2" "pre_panas_14_v2" "pre_panas_15_v2" "pre_panas_16_v2" "pre_panas_17_v2" "pre_panas_18_v2"
[73] "pre_panas_19_v2" "pre_panas_20_v2" "pre_stai_1_v2" "pre_stai_2_v2" "pre_stai_3_v2" "pre_stai_4_v2"
[79] "pre_stai_5_v2" "pre_stai_6_v2" "pre_stai_7_v2" "pre_stai_8_v2" "pre_stai_9_v2" "pre_stai_10_v2"
[85] "pre_stai_11_v2" "pre_stai_12_v2" "pre_stai_13_v2" "pre_stai_14_v2" "pre_stai_15_v2" "pre_stai_16_v2"
[91] "pre_stai_17_v2" "pre_stai_18_v2" "pre_stai_19_v2" "pre_stai_20_v2" "tot_pre_panas_pa_v2" "tot_pre_panas_na_v2"
[97] "pre_stai_1r_v2" "pre_stai_2r_v2" "pre_stai_5r_v2" "pre_stai_8r_v2" "pre_stai_10r_v2" "pre_stai_11r_v2"
[103] "pre_stai_15r_v2" "pre_stai_16r_v2" "pre_stai_19r_v2" "pre_stai_20r_v2" "tot_pre_stai_v2"
pre_fmri_NA_v2 <- subset(pre_fmri_3, is.na(tot_pre_stai_v2))
pre_fmri_NA_v2$ID
[1] "D108" "D111" "D109" "D124" "D130"
# we are missing pre_fmri_v2 data from D108, D111, D109, and D124. This is correct: all were dropped.
# there's something weird going on with D130. D130 is NOT missing data but for some reason when these data are merged, the _v2 data is dropped. Only way I've found to fix this is to fix it manually and retype "D130" in pre_fmri_v2.
fix(pre_fmri_v2)
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
running command ''/usr/bin/otool' -L '/Library/Frameworks/R.framework/Resources/modules/R_de.so'' had status 1
pre_fmri_3 <- left_join(pre_fmri_v1, pre_fmri_v2, by="ID") # merge pre_v1 and pre_v2 by ID
pre_fmri_NA_v2 <- subset(pre_fmri_3, is.na(tot_pre_stai_v2))
pre_fmri_NA_v2$ID
[1] "D108" "D111" "D109" "D124"
# now only missing D108, D109, D111, D124.
# save it
saveRDS(pre_fmri_3, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/pre_fmri_3.rds")
### POST
## Put them back together (POST)
post_fmri_3 <- left_join(post_fmri_v1, post_fmri_v2, by="ID") # merge post_v1 and post_v2 by ID
View(post_fmri_3)
names(post_fmri_3)
[1] "ID" "post_panas_1_v1" "post_panas_2_v1" "post_panas_3_v1" "post_panas_4_v1" "post_panas_5_v1"
[7] "post_panas_6_v1" "post_panas_7_v1" "post_panas_8_v1" "post_panas_9_v1" "post_panas_10_v1" "post_panas_11_v1"
[13] "post_panas_12_v1" "post_panas_13_v1" "post_panas_14_v1" "post_panas_15_v1" "post_panas_16_v1" "post_panas_17_v1"
[19] "post_panas_18_v1" "post_panas_19_v1" "post_panas_20_v1" "post_stai_1_v1" "post_stai_2_v1" "post_stai_3_v1"
[25] "post_stai_4_v1" "post_stai_5_v1" "post_stai_6_v1" "post_stai_7_v1" "post_stai_8_v1" "post_stai_9_v1"
[31] "post_stai_10_v1" "post_stai_11_v1" "post_stai_12_v1" "post_stai_13_v1" "post_stai_14_v1" "post_stai_15_v1"
[37] "post_stai_16_v1" "post_stai_17_v1" "post_stai_18_v1" "post_stai_19_v1" "post_stai_20_v1" "post_sroe_1_v1"
[43] "post_sroe_2_v1" "post_sroe_3_v1" "tot_post_panas_pa_v1" "tot_post_panas_na_v1" "post_stai_1r_v1" "post_stai_2r_v1"
[49] "post_stai_5r_v1" "post_stai_8r_v1" "post_stai_10r_v1" "post_stai_11r_v1" "post_stai_15r_v1" "post_stai_16r_v1"
[55] "post_stai_19r_v1" "post_stai_20r_v1" "tot_post_stai_v1" "post_panas_1_v2" "post_panas_2_v2" "post_panas_3_v2"
[61] "post_panas_4_v2" "post_panas_5_v2" "post_panas_6_v2" "post_panas_7_v2" "post_panas_8_v2" "post_panas_9_v2"
[67] "post_panas_10_v2" "post_panas_11_v2" "post_panas_12_v2" "post_panas_13_v2" "post_panas_14_v2" "post_panas_15_v2"
[73] "post_panas_16_v2" "post_panas_17_v2" "post_panas_18_v2" "post_panas_19_v2" "post_panas_20_v2" "post_stai_1_v2"
[79] "post_stai_2_v2" "post_stai_3_v2" "post_stai_4_v2" "post_stai_5_v2" "post_stai_6_v2" "post_stai_7_v2"
[85] "post_stai_8_v2" "post_stai_9_v2" "post_stai_10_v2" "post_stai_11_v2" "post_stai_12_v2" "post_stai_13_v2"
[91] "post_stai_14_v2" "post_stai_15_v2" "post_stai_16_v2" "post_stai_17_v2" "post_stai_18_v2" "post_stai_19_v2"
[97] "post_stai_20_v2" "tot_post_panas_pa_v2" "tot_post_panas_na_v2" "post_stai_1r_v2" "post_stai_2r_v2" "post_stai_5r_v2"
[103] "post_stai_8r_v2" "post_stai_10r_v2" "post_stai_11r_v2" "post_stai_15r_v2" "post_stai_16r_v2" "post_stai_19r_v2"
[109] "post_stai_20r_v2" "tot_post_stai_v2" "post_sroe_1_v2" "post_sroe_2_v2" "post_sroe_3_v2"
post_fmri_NA_v2 <- subset(post_fmri_3, is.na(tot_post_stai_v2))
post_fmri_NA_v2$ID
[1] "D108" "D111"
# we are missing post_fmri_v2 data from D108 and D111. This is correct: both were dropped.
# save it
saveRDS(post_fmri_3, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/post_fmri_3.rds")
Then merging pre and post together…
pre_post_fmri <- left_join(pre_fmri_3, post_fmri_3, by="ID")
View(pre_post_fmri)
names(pre_post_fmri)
[1] "ID" "pre_panas_1_v1" "pre_panas_2_v1" "pre_panas_3_v1" "pre_panas_4_v1" "pre_panas_5_v1"
[7] "pre_panas_6_v1" "pre_panas_7_v1" "pre_panas_8_v1" "pre_panas_9_v1" "pre_panas_10_v1" "pre_panas_11_v1"
[13] "pre_panas_12_v1" "pre_panas_13_v1" "pre_panas_14_v1" "pre_panas_15_v1" "pre_panas_16_v1" "pre_panas_17_v1"
[19] "pre_panas_18_v1" "pre_panas_19_v1" "pre_panas_20_v1" "pre_stai_1_v1" "pre_stai_2_v1" "pre_stai_3_v1"
[25] "pre_stai_4_v1" "pre_stai_5_v1" "pre_stai_6_v1" "pre_stai_7_v1" "pre_stai_8_v1" "pre_stai_9_v1"
[31] "pre_stai_10_v1" "pre_stai_11_v1" "pre_stai_12_v1" "pre_stai_13_v1" "pre_stai_14_v1" "pre_stai_15_v1"
[37] "pre_stai_16_v1" "pre_stai_17_v1" "pre_stai_18_v1" "pre_stai_19_v1" "pre_stai_20_v1" "tot_pre_panas_pa_v1"
[43] "tot_pre_panas_na_v1" "pre_stai_1r_v1" "pre_stai_2r_v1" "pre_stai_5r_v1" "pre_stai_8r_v1" "pre_stai_10r_v1"
[49] "pre_stai_11r_v1" "pre_stai_15r_v1" "pre_stai_16r_v1" "pre_stai_19r_v1" "pre_stai_20r_v1" "tot_pre_stai_v1"
[55] "pre_panas_1_v2" "pre_panas_2_v2" "pre_panas_3_v2" "pre_panas_4_v2" "pre_panas_5_v2" "pre_panas_6_v2"
[61] "pre_panas_7_v2" "pre_panas_8_v2" "pre_panas_9_v2" "pre_panas_10_v2" "pre_panas_11_v2" "pre_panas_12_v2"
[67] "pre_panas_13_v2" "pre_panas_14_v2" "pre_panas_15_v2" "pre_panas_16_v2" "pre_panas_17_v2" "pre_panas_18_v2"
[73] "pre_panas_19_v2" "pre_panas_20_v2" "pre_stai_1_v2" "pre_stai_2_v2" "pre_stai_3_v2" "pre_stai_4_v2"
[79] "pre_stai_5_v2" "pre_stai_6_v2" "pre_stai_7_v2" "pre_stai_8_v2" "pre_stai_9_v2" "pre_stai_10_v2"
[85] "pre_stai_11_v2" "pre_stai_12_v2" "pre_stai_13_v2" "pre_stai_14_v2" "pre_stai_15_v2" "pre_stai_16_v2"
[91] "pre_stai_17_v2" "pre_stai_18_v2" "pre_stai_19_v2" "pre_stai_20_v2" "tot_pre_panas_pa_v2" "tot_pre_panas_na_v2"
[97] "pre_stai_1r_v2" "pre_stai_2r_v2" "pre_stai_5r_v2" "pre_stai_8r_v2" "pre_stai_10r_v2" "pre_stai_11r_v2"
[103] "pre_stai_15r_v2" "pre_stai_16r_v2" "pre_stai_19r_v2" "pre_stai_20r_v2" "tot_pre_stai_v2" "post_panas_1_v1"
[109] "post_panas_2_v1" "post_panas_3_v1" "post_panas_4_v1" "post_panas_5_v1" "post_panas_6_v1" "post_panas_7_v1"
[115] "post_panas_8_v1" "post_panas_9_v1" "post_panas_10_v1" "post_panas_11_v1" "post_panas_12_v1" "post_panas_13_v1"
[121] "post_panas_14_v1" "post_panas_15_v1" "post_panas_16_v1" "post_panas_17_v1" "post_panas_18_v1" "post_panas_19_v1"
[127] "post_panas_20_v1" "post_stai_1_v1" "post_stai_2_v1" "post_stai_3_v1" "post_stai_4_v1" "post_stai_5_v1"
[133] "post_stai_6_v1" "post_stai_7_v1" "post_stai_8_v1" "post_stai_9_v1" "post_stai_10_v1" "post_stai_11_v1"
[139] "post_stai_12_v1" "post_stai_13_v1" "post_stai_14_v1" "post_stai_15_v1" "post_stai_16_v1" "post_stai_17_v1"
[145] "post_stai_18_v1" "post_stai_19_v1" "post_stai_20_v1" "post_sroe_1_v1" "post_sroe_2_v1" "post_sroe_3_v1"
[151] "tot_post_panas_pa_v1" "tot_post_panas_na_v1" "post_stai_1r_v1" "post_stai_2r_v1" "post_stai_5r_v1" "post_stai_8r_v1"
[157] "post_stai_10r_v1" "post_stai_11r_v1" "post_stai_15r_v1" "post_stai_16r_v1" "post_stai_19r_v1" "post_stai_20r_v1"
[163] "tot_post_stai_v1" "post_panas_1_v2" "post_panas_2_v2" "post_panas_3_v2" "post_panas_4_v2" "post_panas_5_v2"
[169] "post_panas_6_v2" "post_panas_7_v2" "post_panas_8_v2" "post_panas_9_v2" "post_panas_10_v2" "post_panas_11_v2"
[175] "post_panas_12_v2" "post_panas_13_v2" "post_panas_14_v2" "post_panas_15_v2" "post_panas_16_v2" "post_panas_17_v2"
[181] "post_panas_18_v2" "post_panas_19_v2" "post_panas_20_v2" "post_stai_1_v2" "post_stai_2_v2" "post_stai_3_v2"
[187] "post_stai_4_v2" "post_stai_5_v2" "post_stai_6_v2" "post_stai_7_v2" "post_stai_8_v2" "post_stai_9_v2"
[193] "post_stai_10_v2" "post_stai_11_v2" "post_stai_12_v2" "post_stai_13_v2" "post_stai_14_v2" "post_stai_15_v2"
[199] "post_stai_16_v2" "post_stai_17_v2" "post_stai_18_v2" "post_stai_19_v2" "post_stai_20_v2" "tot_post_panas_pa_v2"
[205] "tot_post_panas_na_v2" "post_stai_1r_v2" "post_stai_2r_v2" "post_stai_5r_v2" "post_stai_8r_v2" "post_stai_10r_v2"
[211] "post_stai_11r_v2" "post_stai_15r_v2" "post_stai_16r_v2" "post_stai_19r_v2" "post_stai_20r_v2" "tot_post_stai_v2"
[217] "post_sroe_1_v2" "post_sroe_2_v2" "post_sroe_3_v2"
pre_post_fmri <- filter(pre_post_fmri, !grepl("D108|D109|D111|D124",ID)) # remove D108, D109, D111, D124
# 40 observations of 219 variables
# save it
saveRDS(pre_post_fmri, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/pre-post_fmri.rds")
And finally, merging all self-report measures together (baseline, baseline_post, pre_post_fmri):
baseline_all <- readRDS("~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/baseline_with_post-baseline.rds") # 40 observations of 457 variables
selfreports <- left_join(baseline_all, pre_post_fmri, by="ID") # 40 observations of 675 variables
saveRDS(selfreports, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/selfreports.rds")
# selfreports <- readRDS("~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/selfreports.rds")
This yields 40 observations of 675 variables.
# Create a subset of only scale total scores (i.e., variables that start with "tot" or the task difficulty rating)
scales_fmri <- pre_post_fmri[, grep('^tot|post_sroe_3', names(pre_post_fmri))]
# Plot the variables:
for(i in 1:length(scales_fmri)) boxplot(scales_fmri[,i], xlab=NULL, main=names(scales_fmri[i]))
for(i in 1:length(scales_fmri)) hist(scales_fmri[,i], xlab=NULL, main=names(scales_fmri[i]))
# View descriptives for each scale
## stargazer makes nice-looking summary tables (https://cran.r-project.org/web/packages/stargazer/vignettes/stargazer.pdf)
library(stargazer) # install.packages("stargazer") if this is the first time using the package on this machine
stargazer(scales_fmri, type="text")
===============================================
Statistic N Mean St. Dev. Min Max
-----------------------------------------------
tot_pre_panas_pa_v1 40 32.550 6.251 21 48
tot_pre_panas_na_v1 40 12.925 3.269 10 23
tot_pre_stai_v1 40 32.700 9.233 20 63
tot_pre_panas_pa_v2 40 34.600 7.295 14 50
tot_pre_panas_na_v2 40 12.600 3.650 10 27
tot_pre_stai_v2 40 31.375 9.665 20 58
post_sroe_3_v1 40 2.075 0.764 1 3
tot_post_panas_pa_v1 40 31.900 7.564 17 48
tot_post_panas_na_v1 40 11.600 2.216 10 19
tot_post_stai_v1 40 31.450 9.640 20 61
tot_post_panas_pa_v2 40 35.200 7.240 19 50
tot_post_panas_na_v2 40 11.000 1.432 10 15
tot_post_stai_v2 40 28.650 6.716 20 44
post_sroe_3_v2 39 1.846 0.812 1 4
-----------------------------------------------
### Pre-fMRI measures
names(scales_fmri)
[1] "tot_pre_panas_pa_v1" "tot_pre_panas_na_v1" "tot_pre_stai_v1" "tot_pre_panas_pa_v2" "tot_pre_panas_na_v2" "tot_pre_stai_v2"
[7] "post_sroe_3_v1" "tot_post_panas_pa_v1" "tot_post_panas_na_v1" "tot_post_stai_v1" "tot_post_panas_pa_v2" "tot_post_panas_na_v2"
[13] "tot_post_stai_v2" "post_sroe_3_v2"
t.test(scales_fmri$tot_pre_panas_pa_v1, scales_fmri$tot_pre_panas_pa_v2,
alternative = "two.sided", paired = TRUE, var.equal = FALSE) # sig diff
Paired t-test
data: scales_fmri$tot_pre_panas_pa_v1 and scales_fmri$tot_pre_panas_pa_v2
t = -2.2038, df = 39, p-value = 0.03351
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-3.9315598 -0.1684402
sample estimates:
mean of the differences
-2.05
t.test(scales_fmri$tot_pre_panas_na_v1, scales_fmri$tot_pre_panas_na_v2,
alternative = "two.sided", paired = TRUE, var.equal = FALSE) # ns
Paired t-test
data: scales_fmri$tot_pre_panas_na_v1 and scales_fmri$tot_pre_panas_na_v2
t = 0.68734, df = 39, p-value = 0.4959
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.6314007 1.2814007
sample estimates:
mean of the differences
0.325
t.test(scales_fmri$tot_pre_stai_v1, scales_fmri$tot_pre_stai_v2,
alternative = "two.sided", paired = TRUE, var.equal = FALSE) # ns
Paired t-test
data: scales_fmri$tot_pre_stai_v1 and scales_fmri$tot_pre_stai_v2
t = 1.3816, df = 39, p-value = 0.175
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.6148097 3.2648097
sample estimates:
mean of the differences
1.325
### Post-fMRI measures
t.test(scales_fmri$tot_post_panas_pa_v1, scales_fmri$tot_post_panas_pa_v2,
alternative = "two.sided", paired = TRUE, var.equal = FALSE) # sig diff
Paired t-test
data: scales_fmri$tot_post_panas_pa_v1 and scales_fmri$tot_post_panas_pa_v2
t = -3.8164, df = 39, p-value = 0.0004722
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-5.049005 -1.550995
sample estimates:
mean of the differences
-3.3
t.test(scales_fmri$tot_post_panas_na_v1, scales_fmri$tot_post_panas_na_v2,
alternative = "two.sided", paired = TRUE, var.equal = FALSE) # ns
Paired t-test
data: scales_fmri$tot_post_panas_na_v1 and scales_fmri$tot_post_panas_na_v2
t = 1.506, df = 39, p-value = 0.1401
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.2058284 1.4058284
sample estimates:
mean of the differences
0.6
t.test(scales_fmri$tot_post_stai_v1, scales_fmri$tot_post_stai_v2,
alternative = "two.sided", paired = TRUE, var.equal = FALSE) # sig diff
Paired t-test
data: scales_fmri$tot_post_stai_v1 and scales_fmri$tot_post_stai_v2
t = 2.1441, df = 39, p-value = 0.03831
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
0.1585603 5.4414397
sample estimates:
mean of the differences
2.8
t.test(scales_fmri$post_sroe_3_v1, scales_fmri$post_sroe_3_v2,
alternative = "two.sided", paired = TRUE, var.equal = FALSE) # sig diff
Paired t-test
data: scales_fmri$post_sroe_3_v1 and scales_fmri$post_sroe_3_v2
t = 2.132, df = 38, p-value = 0.03953
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
0.0129423 0.4998782
sample estimates:
mean of the differences
0.2564103
From the t-tests, we see that:
pre_post_fmri %>%
select_if(function(x) any(is.na(x))) %>%
summarise_all(funs(mean(is.na(.)))) -> pre_post_fmri_NA # use sum() to find n missing values
gather(pre_post_fmri_NA) -> pre_post_fmri_NA_long # create long data that lists variables with any NAs, and % of data missing
pre_post_fmri_NA_long
We have 9 variables missing data, where one response was missed on a number of PANAS items at visit one. One person is also missing SROE data (this is D115, who erroneously was administered the pre-fMRI survey after exiting the scanner.)
# The 'alpha' function is helpful because it will alert you if your reverse coding went awry somehow.
## Note that Emily Butler says it's not always correct - if it flags an issues and you've double- and triple-checked your reverse coding, ignore it.
# Primarily, we use/report the standard alpha.
library(psych)
psych::alpha(tot_pre_panas_na) # because tidyverse is loaded, the alpha function from ggplot2 is masking psych::alpha so we have to specify
Reliability analysis
Call: psych::alpha(x = tot_pre_panas_na)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.76 0.73 0.81 0.21 2.7 0.034 1.3 0.35 0.12
lower alpha upper 95% confidence boundaries
0.69 0.76 0.82
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
pre_panas_2 0.72 0.69 0.77 0.20 2.2 0.039 0.069 0.094
pre_panas_4 0.74 0.71 0.79 0.21 2.5 0.035 0.080 0.057
pre_panas_6 0.79 0.75 0.82 0.25 3.1 0.029 0.074 0.210
pre_panas_7 0.70 0.67 0.76 0.18 2.0 0.042 0.062 0.063
pre_panas_8 0.76 0.73 0.81 0.24 2.8 0.035 0.078 0.135
pre_panas_11 0.78 0.76 0.83 0.26 3.2 0.031 0.073 0.210
pre_panas_13 0.77 0.75 0.82 0.25 3.0 0.032 0.073 0.193
pre_panas_15 0.67 0.66 0.74 0.17 1.9 0.049 0.057 0.057
pre_panas_18 0.68 0.66 0.73 0.18 1.9 0.046 0.057 0.062
pre_panas_20 0.69 0.65 0.73 0.17 1.8 0.044 0.052 0.063
Item statistics
n raw.r std.r r.cor r.drop mean sd
pre_panas_2 85 0.64 0.64 0.606 0.527 1.3 0.57
pre_panas_4 85 0.50 0.52 0.442 0.355 1.2 0.61
pre_panas_6 85 0.27 0.25 0.117 0.077 1.4 0.68
pre_panas_7 85 0.75 0.74 0.743 0.651 1.3 0.64
pre_panas_8 85 0.30 0.38 0.260 0.215 1.0 0.30
pre_panas_11 85 0.17 0.21 0.035 0.032 1.1 0.50
pre_panas_13 85 0.20 0.26 0.127 0.078 1.1 0.45
pre_panas_15 85 0.84 0.78 0.819 0.732 1.8 0.92
pre_panas_18 85 0.82 0.78 0.814 0.718 1.5 0.77
pre_panas_20 85 0.83 0.83 0.876 0.773 1.2 0.56
Non missing response frequency for each item
1 2 3 4 5 miss
pre_panas_2 0.75 0.21 0.02 0.01 0.00 0
pre_panas_4 0.82 0.14 0.02 0.00 0.01 0
pre_panas_6 0.75 0.15 0.08 0.01 0.00 0
pre_panas_7 0.78 0.15 0.06 0.01 0.00 0
pre_panas_8 0.98 0.00 0.02 0.00 0.00 0
pre_panas_11 0.92 0.07 0.00 0.00 0.01 0
pre_panas_13 0.98 0.01 0.00 0.00 0.01 0
pre_panas_15 0.52 0.26 0.19 0.02 0.01 0
pre_panas_18 0.67 0.21 0.09 0.02 0.00 0
pre_panas_20 0.84 0.12 0.04 0.01 0.00 0
psych::alpha(tot_pre_panas_pa)
Reliability analysis
Call: psych::alpha(x = tot_pre_panas_pa)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.89 0.89 0.9 0.44 7.9 0.018 3.4 0.67 0.45
lower alpha upper 95% confidence boundaries
0.85 0.89 0.92
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
pre_panas_1 0.88 0.88 0.89 0.46 7.7 0.019 0.0088 0.45
pre_panas_3 0.87 0.87 0.89 0.43 6.8 0.021 0.0133 0.44
pre_panas_5 0.87 0.87 0.88 0.43 6.8 0.021 0.0116 0.44
pre_panas_9 0.86 0.87 0.88 0.42 6.6 0.022 0.0109 0.45
pre_panas_10 0.88 0.88 0.89 0.45 7.2 0.020 0.0115 0.45
pre_panas_12 0.88 0.88 0.89 0.45 7.3 0.020 0.0119 0.45
pre_panas_14 0.88 0.88 0.89 0.45 7.5 0.019 0.0108 0.46
pre_panas_16 0.87 0.88 0.89 0.44 7.0 0.020 0.0148 0.46
pre_panas_17 0.87 0.87 0.88 0.43 6.8 0.020 0.0117 0.44
pre_panas_19 0.88 0.88 0.89 0.44 7.2 0.020 0.0139 0.45
Item statistics
n raw.r std.r r.cor r.drop mean sd
pre_panas_1 85 0.58 0.60 0.55 0.49 4.1 0.78
pre_panas_3 85 0.76 0.76 0.73 0.68 2.6 1.06
pre_panas_5 84 0.75 0.75 0.73 0.68 3.3 0.96
pre_panas_9 85 0.80 0.80 0.79 0.73 3.4 1.04
pre_panas_10 84 0.70 0.67 0.63 0.60 2.8 1.08
pre_panas_12 85 0.65 0.67 0.63 0.57 3.9 0.85
pre_panas_14 84 0.66 0.64 0.59 0.56 2.8 1.07
pre_panas_16 85 0.72 0.71 0.66 0.63 3.5 1.04
pre_panas_17 85 0.73 0.76 0.74 0.67 4.0 0.74
pre_panas_19 84 0.68 0.68 0.63 0.59 3.3 0.94
Non missing response frequency for each item
1 2 3 4 5 miss
pre_panas_1 0.01 0.02 0.13 0.55 0.28 0.00
pre_panas_3 0.18 0.27 0.36 0.15 0.04 0.00
pre_panas_5 0.05 0.10 0.50 0.24 0.12 0.01
pre_panas_9 0.05 0.11 0.41 0.27 0.16 0.00
pre_panas_10 0.15 0.18 0.42 0.20 0.05 0.01
pre_panas_12 0.02 0.02 0.20 0.54 0.21 0.00
pre_panas_14 0.14 0.23 0.42 0.15 0.06 0.01
pre_panas_16 0.04 0.12 0.32 0.34 0.19 0.00
pre_panas_17 0.00 0.02 0.21 0.53 0.24 0.00
pre_panas_19 0.04 0.14 0.42 0.32 0.08 0.01
psych::alpha(tot_pre_stai)
Reliability analysis
Call: psych::alpha(x = tot_pre_stai)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.93 0.93 0.96 0.39 13 0.011 1.6 0.47 0.38
lower alpha upper 95% confidence boundaries
0.91 0.93 0.95
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
pre_stai_1r 0.92 0.92 0.96 0.39 12 0.012 0.026 0.38
pre_stai_2r 0.92 0.92 0.96 0.39 12 0.012 0.025 0.38
pre_stai_3 0.92 0.92 0.96 0.39 12 0.011 0.028 0.38
pre_stai_4 0.93 0.93 0.96 0.41 13 0.011 0.025 0.39
pre_stai_5r 0.92 0.92 0.96 0.39 12 0.012 0.027 0.38
pre_stai_6 0.93 0.93 0.96 0.40 13 0.011 0.027 0.38
pre_stai_7 0.93 0.93 0.96 0.40 13 0.011 0.026 0.39
pre_stai_8r 0.92 0.92 0.96 0.39 12 0.012 0.026 0.38
pre_stai_9 0.92 0.92 0.96 0.39 12 0.011 0.028 0.38
pre_stai_10r 0.92 0.92 0.96 0.39 12 0.012 0.027 0.37
pre_stai_11r 0.92 0.92 0.96 0.39 12 0.012 0.026 0.38
pre_stai_12 0.92 0.92 0.95 0.39 12 0.012 0.027 0.37
pre_stai_13 0.93 0.93 0.96 0.40 13 0.011 0.026 0.39
pre_stai_14 0.93 0.93 0.96 0.42 14 0.010 0.023 0.39
pre_stai_15r 0.92 0.92 0.95 0.38 12 0.012 0.025 0.38
pre_stai_16r 0.92 0.92 0.95 0.38 12 0.012 0.025 0.37
pre_stai_17 0.93 0.93 0.96 0.40 12 0.011 0.028 0.39
pre_stai_18 0.93 0.93 0.96 0.40 13 0.011 0.027 0.39
pre_stai_19r 0.92 0.92 0.96 0.39 12 0.012 0.026 0.38
pre_stai_20r 0.92 0.92 0.96 0.39 12 0.012 0.026 0.38
Item statistics
n raw.r std.r r.cor r.drop mean sd
pre_stai_1r 85 0.70 0.69 0.68 0.65 1.9 0.77
pre_stai_2r 85 0.74 0.72 0.72 0.71 1.6 0.64
pre_stai_3 85 0.69 0.71 0.70 0.65 1.6 0.63
pre_stai_4 85 0.43 0.45 0.41 0.38 1.2 0.57
pre_stai_5r 85 0.68 0.67 0.65 0.63 1.9 0.83
pre_stai_6 85 0.58 0.60 0.58 0.55 1.2 0.44
pre_stai_7 85 0.51 0.52 0.50 0.44 1.5 0.88
pre_stai_8r 85 0.71 0.70 0.68 0.67 2.1 0.83
pre_stai_9 85 0.67 0.69 0.69 0.63 1.2 0.55
pre_stai_10r 85 0.76 0.76 0.74 0.72 1.8 0.81
pre_stai_11r 85 0.72 0.71 0.69 0.68 1.7 0.76
pre_stai_12 85 0.71 0.73 0.73 0.67 1.5 0.70
pre_stai_13 85 0.55 0.57 0.56 0.51 1.2 0.48
pre_stai_14 85 0.37 0.37 0.33 0.29 1.4 0.76
pre_stai_15r 85 0.82 0.80 0.80 0.78 2.0 0.91
pre_stai_16r 85 0.83 0.81 0.81 0.79 2.1 0.90
pre_stai_17 85 0.61 0.62 0.61 0.56 1.4 0.70
pre_stai_18 85 0.54 0.55 0.53 0.49 1.2 0.56
pre_stai_19r 85 0.72 0.70 0.69 0.68 1.9 0.74
pre_stai_20r 85 0.68 0.67 0.66 0.64 1.8 0.76
Non missing response frequency for each item
1 2 3 4 miss
pre_stai_1r 0.35 0.44 0.20 0.01 0
pre_stai_2r 0.51 0.41 0.08 0.00 0
pre_stai_3 0.49 0.46 0.04 0.01 0
pre_stai_4 0.82 0.13 0.04 0.01 0
pre_stai_5r 0.34 0.46 0.15 0.05 0
pre_stai_6 0.85 0.13 0.02 0.00 0
pre_stai_7 0.71 0.20 0.01 0.08 0
pre_stai_8r 0.22 0.48 0.24 0.06 0
pre_stai_9 0.86 0.09 0.04 0.01 0
pre_stai_10r 0.36 0.49 0.08 0.06 0
pre_stai_11r 0.44 0.40 0.15 0.01 0
pre_stai_12 0.61 0.32 0.05 0.02 0
pre_stai_13 0.79 0.19 0.02 0.00 0
pre_stai_14 0.72 0.19 0.06 0.04 0
pre_stai_15r 0.33 0.36 0.25 0.06 0
pre_stai_16r 0.26 0.44 0.22 0.08 0
pre_stai_17 0.68 0.22 0.08 0.01 0
pre_stai_18 0.89 0.05 0.05 0.01 0
pre_stai_19r 0.32 0.48 0.19 0.01 0
pre_stai_20r 0.39 0.46 0.13 0.02 0
psych::alpha(tot_post_panas_na)
Some items were negatively correlated with the total scale and probably
should be reversed.
To do this, run the function again with the 'check.keys=TRUE' option
Some items ( post_panas_13 ) were negatively correlated with the total scale and
probably should be reversed.
To do this, run the function again with the 'check.keys=TRUE' option
Reliability analysis
Call: psych::alpha(x = tot_post_panas_na)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.56 0.56 0.66 0.11 1.3 0.068 1.1 0.19 0.077
lower alpha upper 95% confidence boundaries
0.43 0.56 0.7
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
post_panas_2 0.46 0.44 0.52 0.082 0.80 0.085 0.023 0.039
post_panas_4 0.52 0.53 0.60 0.111 1.13 0.076 0.027 0.078
post_panas_6 0.61 0.59 0.67 0.136 1.42 0.059 0.031 0.123
post_panas_7 0.54 0.54 0.63 0.114 1.16 0.073 0.030 0.078
post_panas_8 0.56 0.56 0.64 0.125 1.28 0.070 0.028 0.092
post_panas_11 0.52 0.51 0.60 0.103 1.04 0.076 0.028 0.060
post_panas_13 0.61 0.62 0.70 0.152 1.61 0.062 0.027 0.135
post_panas_15 0.52 0.52 0.60 0.107 1.07 0.075 0.027 0.062
post_panas_18 0.47 0.50 0.57 0.098 0.98 0.084 0.023 0.059
post_panas_20 0.53 0.52 0.63 0.109 1.10 0.073 0.032 0.045
Item statistics
n raw.r std.r r.cor r.drop mean sd
post_panas_2 81 0.674 0.71 0.750 0.493 1.2 0.48
post_panas_4 81 0.535 0.47 0.421 0.319 1.1 0.47
post_panas_6 81 0.298 0.27 0.085 0.025 1.2 0.51
post_panas_7 81 0.397 0.45 0.349 0.279 1.1 0.24
post_panas_8 81 0.221 0.36 0.260 0.164 1.0 0.11
post_panas_11 81 0.525 0.53 0.472 0.328 1.1 0.43
post_panas_13 81 0.097 0.14 -0.090 -0.088 1.1 0.35
post_panas_15 81 0.558 0.51 0.458 0.316 1.3 0.52
post_panas_18 81 0.652 0.57 0.561 0.443 1.2 0.52
post_panas_20 81 0.448 0.49 0.375 0.312 1.1 0.29
Non missing response frequency for each item
1 2 3 4 miss
post_panas_2 0.85 0.11 0.04 0.00 0
post_panas_4 0.91 0.04 0.05 0.00 0
post_panas_6 0.85 0.10 0.05 0.00 0
post_panas_7 0.94 0.06 0.00 0.00 0
post_panas_8 0.99 0.01 0.00 0.00 0
post_panas_11 0.91 0.05 0.04 0.00 0
post_panas_13 0.95 0.02 0.02 0.00 0
post_panas_15 0.77 0.20 0.04 0.00 0
post_panas_18 0.83 0.15 0.01 0.01 0
post_panas_20 0.95 0.04 0.01 0.00 0
psych::alpha(tot_post_panas_pa)
Reliability analysis
Call: psych::alpha(x = tot_post_panas_pa)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.9 0.9 0.92 0.49 9.4 0.016 3.4 0.74 0.49
lower alpha upper 95% confidence boundaries
0.87 0.9 0.93
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
post_panas_1 0.90 0.90 0.90 0.50 8.8 0.017 0.0099 0.50
post_panas_3 0.90 0.90 0.90 0.49 8.6 0.017 0.0099 0.50
post_panas_5 0.90 0.90 0.91 0.49 8.7 0.017 0.0095 0.50
post_panas_9 0.89 0.89 0.90 0.47 7.8 0.018 0.0106 0.47
post_panas_10 0.89 0.90 0.91 0.49 8.5 0.017 0.0109 0.51
post_panas_12 0.90 0.89 0.90 0.49 8.5 0.017 0.0113 0.49
post_panas_14 0.89 0.89 0.90 0.47 8.0 0.018 0.0093 0.48
post_panas_16 0.89 0.89 0.91 0.48 8.5 0.017 0.0114 0.50
post_panas_17 0.90 0.90 0.91 0.51 9.3 0.016 0.0076 0.51
post_panas_19 0.89 0.89 0.90 0.48 8.2 0.018 0.0117 0.48
Item statistics
n raw.r std.r r.cor r.drop mean sd
post_panas_1 81 0.67 0.68 0.65 0.60 4.0 0.86
post_panas_3 81 0.73 0.72 0.69 0.65 2.5 1.19
post_panas_5 80 0.71 0.70 0.67 0.63 3.4 1.06
post_panas_9 81 0.83 0.83 0.82 0.78 3.4 1.04
post_panas_10 80 0.73 0.73 0.69 0.66 3.3 1.06
post_panas_12 81 0.72 0.73 0.70 0.65 3.7 0.92
post_panas_14 81 0.82 0.80 0.79 0.76 3.0 1.16
post_panas_16 81 0.73 0.74 0.70 0.67 3.5 0.95
post_panas_17 81 0.59 0.61 0.56 0.51 3.7 0.83
post_panas_19 81 0.77 0.77 0.74 0.70 3.1 0.96
Non missing response frequency for each item
1 2 3 4 5 miss
post_panas_1 0.00 0.04 0.26 0.38 0.32 0.00
post_panas_3 0.27 0.20 0.32 0.16 0.05 0.00
post_panas_5 0.08 0.10 0.30 0.41 0.11 0.01
post_panas_9 0.01 0.23 0.27 0.33 0.15 0.00
post_panas_10 0.08 0.14 0.34 0.35 0.10 0.01
post_panas_12 0.02 0.04 0.33 0.40 0.21 0.00
post_panas_14 0.15 0.14 0.37 0.26 0.09 0.00
post_panas_16 0.02 0.07 0.41 0.32 0.17 0.00
post_panas_17 0.00 0.06 0.35 0.42 0.17 0.00
post_panas_19 0.09 0.05 0.58 0.20 0.09 0.00
psych::alpha(tot_post_stai)
Reliability analysis
Call: psych::alpha(x = tot_post_stai)
raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
0.92 0.93 0.96 0.38 12 0.011 1.5 0.42 0.37
lower alpha upper 95% confidence boundaries
0.9 0.92 0.95
Reliability if an item is dropped:
raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
post_stai_1r 0.92 0.92 0.95 0.38 11 0.012 0.039 0.35
post_stai_2r 0.92 0.92 0.95 0.38 11 0.012 0.038 0.35
post_stai_3 0.92 0.92 0.95 0.38 12 0.011 0.040 0.36
post_stai_4 0.93 0.93 0.96 0.41 13 0.010 0.036 0.39
post_stai_5r 0.92 0.92 0.95 0.38 11 0.012 0.039 0.35
post_stai_6 0.92 0.92 0.95 0.39 12 0.011 0.040 0.38
post_stai_7 0.93 0.93 0.95 0.40 13 0.010 0.038 0.39
post_stai_8r 0.92 0.92 0.95 0.38 11 0.012 0.038 0.36
post_stai_9 0.92 0.92 0.95 0.38 12 0.011 0.041 0.36
post_stai_10r 0.92 0.92 0.95 0.37 11 0.012 0.038 0.35
post_stai_11r 0.92 0.92 0.95 0.37 11 0.012 0.037 0.35
post_stai_12 0.92 0.92 0.95 0.38 12 0.011 0.041 0.36
post_stai_13 0.92 0.92 0.95 0.38 12 0.011 0.040 0.35
post_stai_14 0.93 0.93 0.96 0.40 13 0.010 0.038 0.40
post_stai_15r 0.92 0.92 0.95 0.37 11 0.012 0.037 0.35
post_stai_16r 0.92 0.92 0.95 0.37 11 0.012 0.037 0.36
post_stai_17 0.92 0.93 0.95 0.40 12 0.011 0.039 0.39
post_stai_18 0.93 0.93 0.96 0.41 13 0.011 0.036 0.40
post_stai_19r 0.92 0.92 0.95 0.38 11 0.012 0.038 0.36
post_stai_20r 0.92 0.92 0.95 0.38 12 0.012 0.037 0.37
Item statistics
n raw.r std.r r.cor r.drop mean sd
post_stai_1r 81 0.78 0.76 0.75 0.74 1.8 0.78
post_stai_2r 81 0.79 0.77 0.76 0.75 1.5 0.69
post_stai_3 81 0.64 0.69 0.68 0.60 1.3 0.52
post_stai_4 81 0.35 0.36 0.32 0.27 1.4 0.71
post_stai_5r 81 0.77 0.75 0.74 0.72 1.7 0.82
post_stai_6 81 0.53 0.57 0.56 0.50 1.1 0.29
post_stai_7 81 0.42 0.44 0.42 0.35 1.3 0.69
post_stai_8r 81 0.77 0.75 0.74 0.72 1.9 0.75
post_stai_9 81 0.63 0.69 0.68 0.60 1.1 0.28
post_stai_10r 81 0.79 0.77 0.77 0.76 1.8 0.74
post_stai_11r 81 0.81 0.78 0.78 0.77 1.8 0.72
post_stai_12 81 0.64 0.69 0.68 0.61 1.2 0.48
post_stai_13 81 0.64 0.69 0.69 0.61 1.2 0.40
post_stai_14 81 0.35 0.37 0.32 0.28 1.3 0.63
post_stai_15r 81 0.85 0.81 0.82 0.81 1.8 0.81
post_stai_16r 81 0.82 0.78 0.78 0.79 1.9 0.84
post_stai_17 81 0.47 0.48 0.46 0.41 1.3 0.52
post_stai_18 81 0.28 0.31 0.26 0.23 1.1 0.43
post_stai_19r 81 0.78 0.75 0.74 0.74 1.9 0.74
post_stai_20r 81 0.72 0.68 0.67 0.68 1.7 0.72
Non missing response frequency for each item
1 2 3 4 miss
post_stai_1r 0.43 0.38 0.17 0.01 0
post_stai_2r 0.58 0.31 0.11 0.00 0
post_stai_3 0.77 0.20 0.04 0.00 0
post_stai_4 0.75 0.16 0.06 0.02 0
post_stai_5r 0.46 0.38 0.12 0.04 0
post_stai_6 0.95 0.04 0.01 0.00 0
post_stai_7 0.75 0.17 0.05 0.02 0
post_stai_8r 0.28 0.52 0.17 0.02 0
post_stai_9 0.91 0.09 0.00 0.00 0
post_stai_10r 0.40 0.44 0.15 0.01 0
post_stai_11r 0.40 0.47 0.12 0.01 0
post_stai_12 0.79 0.19 0.02 0.00 0
post_stai_13 0.85 0.14 0.01 0.00 0
post_stai_14 0.73 0.23 0.01 0.02 0
post_stai_15r 0.41 0.40 0.17 0.02 0
post_stai_16r 0.37 0.41 0.19 0.04 0
post_stai_17 0.77 0.20 0.04 0.00 0
post_stai_18 0.90 0.09 0.00 0.01 0
post_stai_19r 0.33 0.48 0.17 0.01 0
post_stai_20r 0.47 0.41 0.11 0.01 0
This section of the script deals with the genotype data that was collected via buccal cell swab at the end of participants’ second experimental session.
What has been done up to this point: (1) codebook created, (2) data provided by MFO as Excel file.
Task: Import only rows 2:42 of the first 4 columns.
# run install.packages("tidyverse") if this is the first time using dplyr on your local machine
library(tidyverse)
filter <- dplyr::filter
select <- dplyr::select
library(readxl)
SNPs <- read_excel("~/Dropbox/GLASS Lab/OT Study/data/raw-data/OConnor_SNP_results.xlsx", sheet = "012518_OXTR_SNPs")[c(2:41), c(1:4) ] # remember that R uses the first row as column names, so what we are calling "row 2" here is equivalent to row 3 in the excel file
View(SNPs)
write.csv(SNPs, file = "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/oxtr_SNPs.csv") # 40 observations of 4 variables
# SNPs <- read.csv(file = "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/oxtr_SNPs.csv") # 40 observations of 4 variables
# SNPs$X <- NULL
names(SNPs)
[1] "Sample ID" "OXTR_rs2254298" "OXTR_rs2268498" "OXTR_rs53576"
SNPs <- rename(SNPs, ID = "Sample ID",
rs2254298 = OXTR_rs2254298,
rs2268498 = OXTR_rs2268498,
rs53576 = OXTR_rs53576)
names(SNPs)
[1] "ID" "rs2254298" "rs2268498" "rs53576"
For each of the SNPs, we need to create factors for each of the three genotypes (below). We also need to create factors that indicate presence of minor alleles (A allele for rs2254298 and rs53576; C allele for rs2268498).
| rs2254298 | rs2268498 | rs53576 |
|---|---|---|
| AA | CC | AA |
| AG | TT | GG |
| A/G | C/T | A/G |
rs2254298 only has three levels (A/G, GG, UnD) because no one has the AA genotype (but we’ll replace UnD with NA instead).
rs53576 only has two levels (A/G, GG) because no one has the AA genotype.
OXTR53576 and OXTR2254298 are the same as rs53576 and rs2254298, but variable names and values have been changed to match the SPSS dataset with genotype data from the GOA sample in order to make any future merging easier.
SNPs_1 <- SNPs %>% mutate(rs2254298 = recode_factor(rs2254298, "GG" = "GG", "A/G" = "A/G", "UnD" = NA_character_, .ordered = FALSE),
rs2254298_A.carrier = recode_factor(rs2254298, "GG" = 0, "A/G" = 1, .ordered = TRUE),
rs2268498_C.carrier = recode_factor(rs2268498, "TT" = 0, "C/T" = 1, "CC" = 1, .ordered = TRUE),
rs53576_A.carrier = recode_factor(rs53576, "GG" = 0, "A/G" = 1, .ordered = TRUE),
OXTR2254298 = as.numeric(recode(rs2254298, "GG" = 0, "A/G" = 1, "AA" = 2)),
OXTR53576 = as.numeric(recode(rs53576, "GG" = 0, "A/G" = 1, "AA" = 2)))
str(SNPs_1)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 40 obs. of 9 variables:
$ ID : chr "D101" "D102" "D103" "D104" ...
$ rs2254298 : Factor w/ 2 levels "GG","A/G": 1 1 1 1 1 1 2 1 2 1 ...
$ rs2268498 : chr "C/T" "C/T" "TT" "CC" ...
$ rs53576 : chr "A/G" "A/G" "GG" "A/G" ...
$ rs2254298_A.carrier: Ord.factor w/ 2 levels "0"<"1": 1 1 1 1 1 1 2 1 2 1 ...
$ rs2268498_C.carrier: Ord.factor w/ 2 levels "0"<"1": 2 2 1 2 2 1 2 2 2 1 ...
$ rs53576_A.carrier : Ord.factor w/ 2 levels "0"<"1": 2 2 1 2 1 1 1 2 2 1 ...
$ OXTR2254298 : num 0 0 0 0 0 0 1 0 1 0 ...
$ OXTR53576 : num 1 1 0 1 0 0 0 1 1 0 ...
View(SNPs_1)
# make ID chr rather than factor
SNPs_1$ID <- as.character(SNPs$ID)
saveRDS(SNPs_1, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/oxtr_SNPs.rds")
selfreports_oxtr <- left_join(selfreports, SNPs_1, by="ID")
# save it
saveRDS(selfreports_oxtr, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/selfreports_oxtr.rds")
This section of the script deals with the cortisol data that were collected via salivette 3x during each experimental session: | “baseline” | “pre” | “post” | |:-:|:-:|:-:| |Upon arrival|Just before entering MRI| Just after exiting MRI|
What has been done up to this point: (1) codebook created, (2) data provided by MFO as Excel file.
Task: Import only rows 2:42 of the first 4 columns.
# run install.packages("tidyverse") if this is the first time using dplyr on your local machine
library(tidyverse)
filter <- dplyr::filter
select <- dplyr::select
library(readxl)
cortisol <- read_excel("~/Dropbox/GLASS Lab/OT Study/data/raw-data/OT cortisol output 18.12.17.xlsx", sheet = "Study 1 OT", skip=6)[c(1:251), c(1:2) ] # remember that R uses the first row as column names, so what we are calling "row 2" here is equivalent to row 3 in the excel file
View(cortisol)
names(cortisol)
[1] "Sample #" "Cortisol nmol/l"
cortisol_0 <- rename(cortisol, sample = "Sample #",
cortisol = "Cortisol nmol/l")
names(cortisol_0)
[1] "sample" "cortisol"
write.csv(cortisol_0, file = "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/cortisol_0.csv") # 251 observations of 2 variables
saveRDS(cortisol_0, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/cortisol_0.rds")
According to the box map…
cortisol_1 <- cortisol_0 %>% mutate(ID = as.character(recode(sample, "1" = "D101_PO2",
"2" = "D101_PR2",
"3" = "D101_BL2",
"4" = "D101_PO1",
"5" = "D101_PR1",
"6" = "D101_BL1",
"7" = "D102_PO2",
"8" = "D102_PR2",
"9" = "D102_BL2",
"10" = "D102_PO1",
"11" = "D102_PR1",
"12" = "D102_BL1",
"13" = "D103_PO2",
"14" = "D103_PR2",
"15" = "D103_BL2",
"16" = "D103_PO1",
"17" = "D103_PR1",
"18" = "D103_BL1",
"19" = "D104_PO2",
"20" = "D104_PR2",
"21" = "D104_BL2",
"22" = "D104_PO1",
"23" = "D104_PR1",
"24" = "D104_BL1",
"25" = "D105_PO2",
"26" = "D105_PR2",
"27" = "D105_BL2",
"28" = "D105_PO1",
"29" = "D105_PR1",
"30" = "D105_BL1",
"31" = "D107_PO2",
"32" = "D107_PR2",
"33" = "D107_BL2",
"34" = "D107_PO1",
"35" = "D107_PR1",
"36" = "D107_BL1",
"37" = "D108_PO1",
"38" = "D108_PR1",
"39" = "D108_BL1",
"40" = "D110_PO2",
"41" = "D110_PR2",
"42" = "D110_BL2",
"43" = "D110_PO1",
"44" = "D110_PR1",
"45" = "D110_BL1",
"46" = "D111_PO1",
"47" = "D111_PR1",
"48" = "D111_BL1",
"49" = "D113_PO2",
"50" = "D113_PR2",
"51" = "D113_BL2",
"52" = "D113_PO1",
"53" = "D113_PR1",
"54" = "D113_BL1",
"55" = "D114_PO2",
"56" = "D114_PR2",
"57" = "D114_BL2",
"58" = "D114_PO1",
"59" = "D114_PR1",
"60" = "D114_BL1",
"61" = "D115_PO2",
"62" = "D115_PR2",
"63" = "D115_BL2",
"64" = "D115_PO1",
"65" = "D115_PR1",
"66" = "D115_BL1",
"67" = "D117_PO3",
"68" = "D117_PR3",
"69" = "D117_BL3",
"70" = "D117_PO2",
"71" = "D117_PR2",
"72" = "D117_BL2",
"73" = "D117_PO1",
"74" = "D117_PR1",
"75" = "D117_BL1",
"76" = "D118_PO2",
"77" = "D118_PR2",
"78" = "D118_BL2",
"79" = "D118_PO1",
"80" = "D118_PR1",
"81" = "D118_BL1",
"82" = "D119_PO2",
"83" = "D119_PR2",
"84" = "D119_BL2",
"85" = "D119_PO1",
"86" = "D119_PR1",
"87" = "D119_BL1",
"88" = "D120_PO2",
"89" = "D120_PR2",
"90" = "D120_BL2",
"91" = "D120_PO1",
"92" = "D120_PR1",
"93" = "D120_BL1",
"94" = "D121_PO2",
"95" = "D121_PR2",
"96" = "D121_BL2",
"97" = "D121_PO1",
"98" = "D121_PR1",
"99" = "D121_BL1",
"100" = "D122_PO2",
"101" = "D122_PR2",
"102" = "D122_BL2",
"103" = "D122_PO1",
"104" = "D122_PR1",
"105" = "D122_BL1",
"106" = "D123_PO2",
"107" = "D123_PR2",
"108" = "D123_BL2",
"109" = "D123_PO1",
"110" = "D123_PR1",
"111" = "D123_BL1",
"112" = "D125_PO2",
"113" = "D125_PR2",
"114" = "D125_BL2",
"115" = "D125_PO1",
"116" = "D125_PR1",
"117" = "D125_BL1",
"118" = "D126_PO2",
"119" = "D126_PR2",
"120" = "D126_BL2",
"121" = "D126_PO1",
"122" = "D126_PR1",
"123" = "D126_BL1",
"124" = "D127_PO2",
"125" = "D127_PR2",
"126" = "D127_BL2",
"127" = "D127_PO1",
"128" = "D127_PR1",
"129" = "D127_BL1",
"130" = "D128_PO2",
"131" = "D128_PR2",
"132" = "D128_BL2",
"133" = "D128_PO1",
"134" = "D128_PR1",
"135" = "D128_BL1",
"136" = "D129_PO2",
"137" = "D129_PR2",
"138" = "D129_BL2",
"139" = "D129_PO1",
"140" = "D129_PR1",
"141" = "D129_BL1",
"142" = "D130_PO2",
"143" = "D130_PR2",
"144" = "D130_BL2",
"145" = "D130_PO1",
"146" = "D130_PR1",
"147" = "D130_BL1",
"148" = "D131_PO2",
"149" = "D131_PR2",
"150" = "D131_BL2",
"151" = "D131_PO1",
"152" = "D131_PR1",
"153" = "D131_BL1",
"154" = "D132_PO2",
"155" = "D132_PR2",
"156" = "D132_BL2",
"157" = "D132_PO1",
"158" = "D132_PR1",
"159" = "D132_BL1",
"160" = "D133_PO2",
"161" = "D133_PR2",
"162" = "D133_BL2",
"163" = "D133_PO1",
"164" = "D133_PR1",
"165" = "D133_BL1",
"166" = "D134_PO2",
"167" = "D134_PR2",
"168" = "D134_BL2",
"169" = "D134_P01",
"170" = "D134_PR1",
"171" = "D134_BL1",
"172" = "D135_PO2",
"173" = "D135_PR2",
"174" = "D135_BL2",
"175" = "D135_PO1",
"176" = "D135_PR1",
"177" = "D135_BL1",
"178" = "D137_PO2",
"179" = "D137_PR2",
"180" = "D137_BL2",
"181" = "D137_PO1",
"182" = "D137_PR1",
"183" = "D137_BL1",
"184" = "D138_PO2",
"185" = "D138_PR2",
"186" = "D138_BL2",
"187" = "D138_PO1",
"188" = "D138_PR1",
"189" = "D138_BL1",
"190" = "D139_PO2",
"191" = "D139_PR2",
"192" = "D139_BL2",
"193" = "D139_PO1",
"194" = "D139_PR1",
"195" = "D139_BL1",
"196" = "D140_PO2",
"197" = "D140_PR2",
"198" = "D140_BL2",
"199" = "D140_PO1",
"200" = "D140_PR1",
"201" = "D140_BL1",
"202" = "D141_P02",
"203" = "D141_PR2",
"204" = "D141_BL2",
"205" = "D141_PO1",
"206" = "D141_PR1",
"207" = "D141_BL1",
"208" = "D142_PO2",
"209" = "D142_PR2",
"210" = "D142_BL2",
"211" = "D142_PO1",
"212" = "D142_PR1",
"213" = "D142_BL1",
"214" = "D143_PO1",
"215" = "D143_PR1",
"216" = "D143_BL1",
"217" = "D144_PO2",
"218" = "D144_BL2",
"219" = "D144_PO1",
"220" = "D144_PR1",
"221" = "D144_BL1",
"222" = "D145_PO2",
"223" = "D145_PR2",
"224" = "D145_BL2",
"225" = "D145_PO1",
"226" = "D145_PR1",
"227" = "D145_BL1",
"228" = "D146_PO2",
"229" = "D146_PR2",
"230" = "D146_BL2",
"231" = "D146_PO1",
"232" = "D146_PR1",
"233" = "D146_BL1",
"234" = "D147_PO2",
"235" = "D147_PR2",
"236" = "D147_BL2",
"237" = "D147_PO1",
"238" = "D147_PR1",
"239" = "D147_BL1",
"240" = "D148_PO2",
"241" = "D148_PR2",
"242" = "D148_BL2",
"243" = "D148_PO1",
"244" = "D148_PR1",
"245" = "D148_BL1",
"246" = "D149_PO2",
"247" = "D149_PR2",
"248" = "D149_BL2",
"249" = "D149_PO1",
"250" = "D149_PR1",
"251" = "D149_BL1")))
View(cortisol_1)
# make ID chr rather than factor
cortisol_1$ID <- as.character(cortisol_1$ID)
saveRDS(cortisol_1, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/cortisol_1.rds")
Now we need to create six subsets (3 samples x 2 visits):
# Use D117's second and third visits, and drop 1st visit (fMRI data lost):
cortisol_2 <- cortisol_1 %>% mutate(ID = as.character(recode(ID, "D117_BL1" = NA_character_,
"D117_PR1" = NA_character_,
"D117_PO1" = NA_character_,
"D117_BL2" = "D117_BL1",
"D117_PR2" = "D117_PR1",
"D117_PO2" = "D117_PO1",
"D117_BL3" = "D117_BL2",
"D117_PR3" = "D117_PR2",
"D117_PO3" = "D117_PO2"
)))
# baseline sample, first visit:
BL_v1 <- filter(cortisol_2[ , 2:3], grepl("BL1",ID)) # dropping 'sample' column
View(BL_v1)
# baseline sample, second visit:
BL_v2 <- filter(cortisol_2[ , 2:3], grepl("BL2",ID))
View(BL_v2)
# pre-fMRI sample, first visit:
PR_v1 <- filter(cortisol_2[ , 2:3], grepl("PR1",ID))
View(PR_v1)
# pre-fMRI sample, second visit:
PR_v2 <- filter(cortisol_2[ , 2:3], grepl("PR2",ID))
View(PR_v2)
# post-fMRI sample, first visit:
PO_v1 <- filter(cortisol_2[ , 2:3], grepl("PO1",ID))
View(PO_v1)
# post-fMRI sample, second visit:
PO_v2 <- filter(cortisol_2[ , 2:3], grepl("PO2",ID))
View(PO_v2)
Now, adding a suffix to the end of ‘cortisol’ (will go into wide format dataset):
BL_v1 <- BL_v1 %>%
rename_at(vars(cortisol),function(x) paste0(x,"_BL_v1"))
BL_v2 <- BL_v2 %>%
rename_at(vars(cortisol),function(x) paste0(x,"_BL_v2"))
PR_v1 <- PR_v1 %>%
rename_at(vars(cortisol),function(x) paste0(x,"_PR_v1"))
PR_v2 <- PR_v2 %>%
rename_at(vars(cortisol),function(x) paste0(x,"_PR_v2"))
PO_v1 <- PO_v1 %>%
rename_at(vars(cortisol),function(x) paste0(x,"_PO_v1"))
PO_v2 <- PO_v2 %>%
rename_at(vars(cortisol),function(x) paste0(x,"_PO_v2"))
# Remove "_XXn" from ID (will go into wide format dataset):
BL_v1 <- BL_v1 %>%
mutate(ID = str_replace(ID, "_BL1", ""))
BL_v2 <- BL_v2 %>%
mutate(ID = str_replace(ID, "_BL2", ""))
PR_v1 <- PR_v1 %>%
mutate(ID = str_replace(ID, "_PR1", ""))
PR_v2 <- PR_v2 %>%
mutate(ID = str_replace(ID, "_PR2", ""))
PO_v1 <- PO_v1 %>%
mutate(ID = str_replace(ID, "_PO1", ""))
PO_v2 <- PO_v2 %>%
mutate(ID = str_replace(ID, "_PO2", ""))
join1 <- left_join(selfreports_oxtr, BL_v1, by="ID")
join2 <- left_join(join1, BL_v2, by="ID")
join3 <- left_join(join2, PR_v1, by="ID")
join4 <- left_join(join3, PR_v2, by="ID")
join5 <- left_join(join4, PO_v1, by="ID")
join6 <- left_join(join5, PO_v2, by="ID")
# making a cortisol wide dataset:
cortisol_wide <- join6[ , c(2,684:689)]
names(cortisol_wide)
[1] "ID" "cortisol_BL_v1" "cortisol_BL_v2" "cortisol_PR_v1" "cortisol_PR_v2" "cortisol_PO_v1" "cortisol_PO_v2"
saveRDS(cortisol_wide, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/cortisol_wide.rds")
# adding to the overall dataset
selfreports_oxtr_cortisol <- join6
names(selfreports_oxtr_cortisol) # 40 observations of 689 variables
[1] "startdate" "ID" "dob" "sex_m" "dateofdeath"
[6] "knowbefore_y" "caretaker_y" "education" "highestdegree" "education_other"
[11] "employment" "householdsize" "householdsize_adult" "householdsize_income" "ethnicity_hisp"
[16] "race" "race_other" "learnaboutstudy" "meds_y" "meds_which"
[21] "meds_dx" "meds_dose" "majorhealthprobs_y" "majorhealthprobs_what" "past2wks_injuryinfect_y"
[26] "past2wks_dentist_y" "currenttx_y" "postmenopausal_y" "lastperiod" "n_pregnancies"
[31] "n_livebirths" "n_nursed" "allergies" "surgeries_past6mos" "alcohol"
[36] "smoking_y" "smoking_howlong" "smoking_perday" "caffeine_perday" "exercise"
[41] "pss_1" "pss_2" "pss_3" "pss_4" "pss_5"
[46] "pss_6" "pss_7" "pss_8" "pss_9" "pss_10"
[51] "ysl_1" "ysl_2" "ysl_3" "ysl_4" "ysl_5"
[56] "ysl_6" "ysl_7" "ysl_8" "ysl_9" "ysl_10"
[61] "ysl_11" "ysl_12" "ysl_13" "ysl_14" "ysl_15"
[66] "ysl_16" "ysl_17" "ysl_18" "ysl_19" "ysl_20"
[71] "ysl_21" "icg_1" "icg_2" "icg_3" "icg_4"
[76] "icg_5" "icg_6" "icg_7" "icg_8" "icg_9"
[81] "icg_10" "icg_11" "icg_12" "icg_13" "icg_14"
[86] "icg_15" "icg_16" "icg_17" "icg_18" "icg_19"
[91] "bdi_1" "bdi_2" "bdi_3" "bdi_4" "bdi_5"
[96] "bdi_6" "bdi_7" "bdi_8" "bdi_9" "bdi_10"
[101] "bdi_11" "bdi_12" "bdi_13" "bdi_14" "bdi_15"
[106] "bdi_16" "bdi_17" "bdi_18" "bdi_19" "bdi_20"
[111] "bdi_21" "hand_1" "hand_2" "hand_3" "hand_4"
[116] "hand_5" "hand_6" "hand_7" "hand_8" "hand_9"
[121] "hand_10" "hand_11" "hand_12" "hand_bat_1" "bisbas_1"
[126] "bisbas_2" "bisbas_3" "bisbas_4" "bisbas_5" "bisbas_6"
[131] "bisbas_7" "bisbas_8" "bisbas_9" "bisbas_10" "bisbas_11"
[136] "bisbas_12" "bisbas_13" "bisbas_14" "bisbas_15" "bisbas_16"
[141] "bisbas_17" "bisbas_18" "bisbas_19" "bisbas_20" "bisbas_21"
[146] "bisbas_22" "bisbas_23" "bisbas_24" "bgq_1" "bgq_2"
[151] "bgq_3" "bgq_4" "bgq_5" "ecrrs_global_1" "ecrrs_global_2"
[156] "ecrrs_global_3" "ecrrs_global_4" "ecrrs_global_5" "ecrrs_global_6" "ecrrs_global_7"
[161] "ecrrs_global_8" "ecrrs_global_9" "ecrrs_spouse_1" "ecrrs_spouse_2" "ecrrs_spouse_3"
[166] "ecrrs_spouse_4" "ecrrs_spouse_5" "ecrrs_spouse_6" "ecrrs_spouse_7" "ecrrs_spouse_8"
[171] "ecrrs_spouse_9" "timesincedeath" "age" "age_yrs" "pss_4r"
[176] "pss_5r" "pss_7r" "pss_8r" "tot_pss" "tot_ysl"
[181] "tot_icg" "bdi_1c" "bdi_2c" "bdi_3c" "bdi_4c"
[186] "bdi_5c" "bdi_6c" "bdi_7c" "bdi_8c" "bdi_9c"
[191] "bdi_10c" "bdi_11c" "bdi_12c" "bdi_13c" "bdi_14c"
[196] "bdi_15c" "bdi_16c" "bdi_17c" "bdi_18c" "bdi_19c"
[201] "bdi_20c" "bdi_21c" "tot_bdi" "hand_1c" "hand_2c"
[206] "hand_3c" "hand_4c" "hand_5c" "hand_6c" "hand_7c"
[211] "hand_8c" "hand_9c" "hand_10c" "hand_11c" "hand_12c"
[216] "hand_bat_1c" "tot_handedness" "bisbas_1r" "bisbas_3r" "bisbas_4r"
[221] "bisbas_5r" "bisbas_6r" "bisbas_7r" "bisbas_8r" "bisbas_9r"
[226] "bisbas_10r" "bisbas_11r" "bisbas_12r" "bisbas_13r" "bisbas_14r"
[231] "bisbas_15r" "bisbas_16r" "bisbas_17r" "bisbas_18r" "bisbas_19r"
[236] "bisbas_20r" "bisbas_21r" "bisbas_23r" "bisbas_24r" "tot_bisbas_basdr"
[241] "tot_bisbas_basfun" "tot_bisbas_basrr" "tot_bisbas_bis" "tot_bgq" "ecrrs_global_1c"
[246] "ecrrs_global_2c" "ecrrs_global_3c" "ecrrs_global_4c" "ecrrs_global_5c" "ecrrs_global_6c"
[251] "ecrrs_global_7c" "ecrrs_global_8c" "ecrrs_global_9c" "ecrrs_global_1r" "ecrrs_global_2r"
[256] "ecrrs_global_3r" "ecrrs_global_4r" "tot_ecrrs_global_avoid" "tot_ecrrs_global_anx" "ecrrs_spouse_1c"
[261] "ecrrs_spouse_2c" "ecrrs_spouse_3c" "ecrrs_spouse_4c" "ecrrs_spouse_5c" "ecrrs_spouse_6c"
[266] "ecrrs_spouse_7c" "ecrrs_spouse_8c" "ecrrs_spouse_9c" "ecrrs_spouse_1r" "ecrrs_spouse_2r"
[271] "ecrrs_spouse_3r" "ecrrs_spouse_4r" "tot_ecrrs_spouse_avoid" "tot_ecrrs_spouse_anx" "ucla_loneliness_1"
[276] "ucla_loneliness_2" "ucla_loneliness_3" "ucla_loneliness_4" "ucla_loneliness_5" "ucla_loneliness_6"
[281] "ucla_loneliness_7" "ucla_loneliness_8" "ucla_loneliness_9" "ucla_loneliness_10" "ucla_loneliness_11"
[286] "ucla_loneliness_12" "ucla_loneliness_13" "ucla_loneliness_14" "ucla_loneliness_15" "ucla_loneliness_16"
[291] "ucla_loneliness_17" "ucla_loneliness_18" "ucla_loneliness_19" "ucla_loneliness_20" "gcq_1"
[296] "gcq_2" "gcq_3" "gcq_4" "gcq_5" "gcq_6"
[301] "gcq_7" "gcq_8" "gcq_9" "gcq_10" "gcq_11"
[306] "gcq_12" "gcq_13" "gcq_14" "gcq_15" "gcq_16"
[311] "gcq_17" "gcq_18" "gcq_19" "gcq_20" "gcq_21"
[316] "gcq_22" "gcq_23" "gcq_24" "gcq_25" "gcq_26"
[321] "gcq_27" "gcq_28" "gcq_29" "gcq_30" "gcq_31"
[326] "gcq_32" "gcq_33" "gcq_34" "gcq_35" "gcq_36"
[331] "gcq_37" "gcq_38" "srrs_1" "srrs_2" "srrs_3"
[336] "srrs_4" "srrs_5" "srrs_6" "srrs_7" "srrs_8"
[341] "srrs_9" "srrs_10" "srrs_11" "srrs_12" "srrs_13"
[346] "srrs_14" "srrs_15" "srrs_16" "srrs_17" "srrs_18"
[351] "srrs_19" "srrs_20" "srrs_21" "srrs_22" "srrs_23"
[356] "srrs_24" "srrs_25" "srrs_26" "srrs_27" "srrs_28"
[361] "srrs_29" "srrs_30" "srrs_31" "srrs_32" "srrs_33"
[366] "srrs_34" "srrs_35" "srrs_36" "srrs_37" "srrs_38"
[371] "srrs_39" "srrs_40" "srrs_41" "srrs_42" "srrs_43"
[376] "srrs_44" "srrs_45" "srrs_46" "srrs_47" "srrs_48"
[381] "srrs_49" "srrs_50" "srrs_51" "ppss_fr_1" "ppss_fr_2"
[386] "ppss_fr_3" "ppss_fr_4" "ppss_fr_5" "ppss_fr_6" "ppss_fr_7"
[391] "ppss_fr_8" "ppss_fr_9" "ppss_fr_10" "ppss_fr_11" "ppss_fr_12"
[396] "ppss_fr_13" "ppss_fr_14" "ppss_fr_15" "ppss_fr_16" "ppss_fr_17"
[401] "ppss_fr_18" "ppss_fr_19" "ppss_fr_20" "ppss_fa_1" "ppss_fa_2"
[406] "ppss_fa_3" "ppss_fa_4" "ppss_fa_5" "ppss_fa_6" "ppss_fa_7"
[411] "ppss_fa_8" "ppss_fa_9" "ppss_fa_10" "ppss_fa_11" "ppss_fa_12"
[416] "ppss_fa_13" "ppss_fa_14" "ppss_fa_15" "ppss_fa_16" "ppss_fa_17"
[421] "ppss_fa_18" "ppss_fa_19" "ppss_fa_20" "tot_srrs_n" "tot_srrs"
[426] "ucla_loneliness_1r" "ucla_loneliness_5r" "ucla_loneliness_6r" "ucla_loneliness_9r" "ucla_loneliness_10r"
[431] "ucla_loneliness_15r" "ucla_loneliness_16r" "ucla_loneliness_19r" "ucla_loneliness_20r" "tot_ucla_loneliness"
[436] "tot_gcq_self" "tot_gcq_world" "tot_gcq_life" "tot_gcq_future" "tot_gcq_blame"
[441] "tot_gcq_others" "tot_gcq_approp" "tot_gcq_cherish" "tot_gcq_threat" "ppss_fr_2r"
[446] "ppss_fr_6r" "ppss_fr_7r" "ppss_fr_15r" "ppss_fr_18r" "ppss_fr_20r"
[451] "tot_ppss_fr" "ppss_fa_3r" "ppss_fa_4r" "ppss_fa_16r" "ppss_fa_19r"
[456] "ppss_fa_20r" "tot_ppss_fa" "pre_panas_1_v1" "pre_panas_2_v1" "pre_panas_3_v1"
[461] "pre_panas_4_v1" "pre_panas_5_v1" "pre_panas_6_v1" "pre_panas_7_v1" "pre_panas_8_v1"
[466] "pre_panas_9_v1" "pre_panas_10_v1" "pre_panas_11_v1" "pre_panas_12_v1" "pre_panas_13_v1"
[471] "pre_panas_14_v1" "pre_panas_15_v1" "pre_panas_16_v1" "pre_panas_17_v1" "pre_panas_18_v1"
[476] "pre_panas_19_v1" "pre_panas_20_v1" "pre_stai_1_v1" "pre_stai_2_v1" "pre_stai_3_v1"
[481] "pre_stai_4_v1" "pre_stai_5_v1" "pre_stai_6_v1" "pre_stai_7_v1" "pre_stai_8_v1"
[486] "pre_stai_9_v1" "pre_stai_10_v1" "pre_stai_11_v1" "pre_stai_12_v1" "pre_stai_13_v1"
[491] "pre_stai_14_v1" "pre_stai_15_v1" "pre_stai_16_v1" "pre_stai_17_v1" "pre_stai_18_v1"
[496] "pre_stai_19_v1" "pre_stai_20_v1" "tot_pre_panas_pa_v1" "tot_pre_panas_na_v1" "pre_stai_1r_v1"
[501] "pre_stai_2r_v1" "pre_stai_5r_v1" "pre_stai_8r_v1" "pre_stai_10r_v1" "pre_stai_11r_v1"
[506] "pre_stai_15r_v1" "pre_stai_16r_v1" "pre_stai_19r_v1" "pre_stai_20r_v1" "tot_pre_stai_v1"
[511] "pre_panas_1_v2" "pre_panas_2_v2" "pre_panas_3_v2" "pre_panas_4_v2" "pre_panas_5_v2"
[516] "pre_panas_6_v2" "pre_panas_7_v2" "pre_panas_8_v2" "pre_panas_9_v2" "pre_panas_10_v2"
[521] "pre_panas_11_v2" "pre_panas_12_v2" "pre_panas_13_v2" "pre_panas_14_v2" "pre_panas_15_v2"
[526] "pre_panas_16_v2" "pre_panas_17_v2" "pre_panas_18_v2" "pre_panas_19_v2" "pre_panas_20_v2"
[531] "pre_stai_1_v2" "pre_stai_2_v2" "pre_stai_3_v2" "pre_stai_4_v2" "pre_stai_5_v2"
[536] "pre_stai_6_v2" "pre_stai_7_v2" "pre_stai_8_v2" "pre_stai_9_v2" "pre_stai_10_v2"
[541] "pre_stai_11_v2" "pre_stai_12_v2" "pre_stai_13_v2" "pre_stai_14_v2" "pre_stai_15_v2"
[546] "pre_stai_16_v2" "pre_stai_17_v2" "pre_stai_18_v2" "pre_stai_19_v2" "pre_stai_20_v2"
[551] "tot_pre_panas_pa_v2" "tot_pre_panas_na_v2" "pre_stai_1r_v2" "pre_stai_2r_v2" "pre_stai_5r_v2"
[556] "pre_stai_8r_v2" "pre_stai_10r_v2" "pre_stai_11r_v2" "pre_stai_15r_v2" "pre_stai_16r_v2"
[561] "pre_stai_19r_v2" "pre_stai_20r_v2" "tot_pre_stai_v2" "post_panas_1_v1" "post_panas_2_v1"
[566] "post_panas_3_v1" "post_panas_4_v1" "post_panas_5_v1" "post_panas_6_v1" "post_panas_7_v1"
[571] "post_panas_8_v1" "post_panas_9_v1" "post_panas_10_v1" "post_panas_11_v1" "post_panas_12_v1"
[576] "post_panas_13_v1" "post_panas_14_v1" "post_panas_15_v1" "post_panas_16_v1" "post_panas_17_v1"
[581] "post_panas_18_v1" "post_panas_19_v1" "post_panas_20_v1" "post_stai_1_v1" "post_stai_2_v1"
[586] "post_stai_3_v1" "post_stai_4_v1" "post_stai_5_v1" "post_stai_6_v1" "post_stai_7_v1"
[591] "post_stai_8_v1" "post_stai_9_v1" "post_stai_10_v1" "post_stai_11_v1" "post_stai_12_v1"
[596] "post_stai_13_v1" "post_stai_14_v1" "post_stai_15_v1" "post_stai_16_v1" "post_stai_17_v1"
[601] "post_stai_18_v1" "post_stai_19_v1" "post_stai_20_v1" "post_sroe_1_v1" "post_sroe_2_v1"
[606] "post_sroe_3_v1" "tot_post_panas_pa_v1" "tot_post_panas_na_v1" "post_stai_1r_v1" "post_stai_2r_v1"
[611] "post_stai_5r_v1" "post_stai_8r_v1" "post_stai_10r_v1" "post_stai_11r_v1" "post_stai_15r_v1"
[616] "post_stai_16r_v1" "post_stai_19r_v1" "post_stai_20r_v1" "tot_post_stai_v1" "post_panas_1_v2"
[621] "post_panas_2_v2" "post_panas_3_v2" "post_panas_4_v2" "post_panas_5_v2" "post_panas_6_v2"
[626] "post_panas_7_v2" "post_panas_8_v2" "post_panas_9_v2" "post_panas_10_v2" "post_panas_11_v2"
[631] "post_panas_12_v2" "post_panas_13_v2" "post_panas_14_v2" "post_panas_15_v2" "post_panas_16_v2"
[636] "post_panas_17_v2" "post_panas_18_v2" "post_panas_19_v2" "post_panas_20_v2" "post_stai_1_v2"
[641] "post_stai_2_v2" "post_stai_3_v2" "post_stai_4_v2" "post_stai_5_v2" "post_stai_6_v2"
[646] "post_stai_7_v2" "post_stai_8_v2" "post_stai_9_v2" "post_stai_10_v2" "post_stai_11_v2"
[651] "post_stai_12_v2" "post_stai_13_v2" "post_stai_14_v2" "post_stai_15_v2" "post_stai_16_v2"
[656] "post_stai_17_v2" "post_stai_18_v2" "post_stai_19_v2" "post_stai_20_v2" "tot_post_panas_pa_v2"
[661] "tot_post_panas_na_v2" "post_stai_1r_v2" "post_stai_2r_v2" "post_stai_5r_v2" "post_stai_8r_v2"
[666] "post_stai_10r_v2" "post_stai_11r_v2" "post_stai_15r_v2" "post_stai_16r_v2" "post_stai_19r_v2"
[671] "post_stai_20r_v2" "tot_post_stai_v2" "post_sroe_1_v2" "post_sroe_2_v2" "post_sroe_3_v2"
[676] "rs2254298" "rs2268498" "rs53576" "rs2254298_A.carrier" "rs2268498_C.carrier"
[681] "rs53576_A.carrier" "OXTR2254298" "OXTR53576" "cortisol_BL_v1" "cortisol_BL_v2"
[686] "cortisol_PR_v1" "cortisol_PR_v2" "cortisol_PO_v1" "cortisol_PO_v2"
saveRDS(selfreports_oxtr_cortisol, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/selfreports_oxtr_cortisol.rds")
# Using the subset we created for the wide dataset...
cortisol_plots <- cortisol_wide[, grep('^c', names(cortisol_wide))]
# Plot the variables:
for(i in 1:length(cortisol_plots)) boxplot(cortisol_plots[,i], xlab=NULL, main=names(cortisol_plots[i]))
for(i in 1:length(cortisol_plots)) hist(cortisol_plots[,i], xlab=NULL, main=names(cortisol_plots[i]))
# View descriptives for each scale
## stargazer makes nice-looking summary tables (https://cran.r-project.org/web/packages/stargazer/vignettes/stargazer.pdf)
library(stargazer) # install.packages("stargazer") if this is the first time using the package on this machine
stargazer(cortisol_plots, type="text")
=============================================
Statistic N Mean St. Dev. Min Max
---------------------------------------------
cortisol_BL_v1 22 4.700 2.881 1.020 13.640
cortisol_BL_v2 27 5.271 3.232 1.000 13.780
cortisol_PR_v1 27 5.349 6.819 1.420 35.210
cortisol_PR_v2 29 4.867 3.258 1.440 14.420
cortisol_PO_v1 29 5.368 8.457 0.860 47.780
cortisol_PO_v2 29 4.440 3.127 1.170 14.630
---------------------------------------------
cortisol_wide %>%
select_if(function(x) any(is.na(x))) %>%
summarise_at(vars(starts_with("c")),funs(sum(is.na(.)))) -> cortisol_NA
gather(cortisol_NA) -> cortisol_NA_long # create long data that lists variables with any NAs, and % of data missing
cortisol_NA_long
At the first visit, we are missing cortisol data from n=18 (45%) at baseline, n=13 (33%) at pre-fMRI, n=11 (28%) at post-fMRI. At the second visit, we are missing cortisol data from n=13 (33%) at baseline, n=11 (28%) at pre-fMRI, n=11 (28%) at post-fMRI.
t.test(cortisol_wide$cortisol_BL_v1, cortisol_wide$cortisol_BL_v2,
alternative = "two.sided", paired = TRUE, var.equal = FALSE) # ns
Paired t-test
data: cortisol_wide$cortisol_BL_v1 and cortisol_wide$cortisol_BL_v2
t = -0.61776, df = 20, p-value = 0.5437
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-2.154994 1.170232
sample estimates:
mean of the differences
-0.492381
t.test(cortisol_wide$cortisol_PR_v1, cortisol_wide$cortisol_PR_v2,
alternative = "two.sided", paired = TRUE, var.equal = FALSE) # ns
Paired t-test
data: cortisol_wide$cortisol_PR_v1 and cortisol_wide$cortisol_PR_v2
t = 0.17856, df = 25, p-value = 0.8597
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-2.430900 2.892438
sample estimates:
mean of the differences
0.2307692
t.test(cortisol_wide$cortisol_PO_v1, cortisol_wide$cortisol_PO_v2,
alternative = "two.sided", paired = TRUE, var.equal = FALSE) # ns
Paired t-test
data: cortisol_wide$cortisol_PO_v1 and cortisol_wide$cortisol_PO_v2
t = 0.75867, df = 22, p-value = 0.4561
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-2.569444 5.533792
sample estimates:
mean of the differences
1.482174
No significant effect of visit at any of the three timepoints.
This section of the script deals with how participants were randomized (1) to receive Treatment A (OT/PL) or Treatment B (OT/PL) at their first visit, and (2) whether they were randomized to receive AAT task instructions to “push blue” or “push yellow” at their first visit.
library(readxl)
random <- read_excel("~/Dropbox/GLASS Lab/OT Study/data/raw-data/OT_Randomization_FINAL.xlsx", sheet = "D101-D149", skip=1)[, c(1:5) ]
View(random)
# take out D117 since we need to use her 2nd and 3rd visits...
random <- filter(random, !grepl("D117",ID))
random_D117 <- read_excel("~/Dropbox/GLASS Lab/OT Study/OT_Randomization_FINAL.xlsx", sheet = "D101-D149", skip=1)[17, c(1,4:7) ]
# just get her visit 2 and 3 data and clean it up
names(random_D117)
random_D117 %>% rename("tx_v1" = Vial__1, "AATpush1_v1" = Push__1, "tx_v2" = X__1, "AATpush1_v2" = X__2) %>%
mutate(tx_v1 = recode(tx_v1, "A" = "A", "B" = "B"), tx_v2 = recode(tx_v2, "A" = "A", "B" = "B"), AATpush1_v1 = recode(AATpush1_v1, "Push blue" = "BLUE", "Push yellow" = "YELLOW"), AATpush1_v2 = recode(AATpush1_v2, "Push blue" = "BLUE", "Push yellow" = "YELLOW")) -> random_D117
View(random_D117)
# do the same for the rest of the sample
random %>% rename("tx_v1" = Vial, "AATpush1_v1" = Push, "tx_v2" = Vial__1, "AATpush1_v2" = Push__1) %>%
mutate(tx_v1 = recode(tx_v1, "A" = "A", "B" = "B"), tx_v2 = recode(tx_v2, "A" = "A", "B" = "B"), AATpush1_v1 = recode(AATpush1_v1, "Push blue" = "BLUE", "Push yellow" = "YELLOW", "YELLOW" = "YELLOW", "BLUE" = "BLUE"), AATpush1_v2 = recode(AATpush1_v2, "Push blue" = "BLUE", "Push yellow" = "YELLOW", "YELLOW" = "YELLOW", "BLUE" = "BLUE")) -> random
View(random)
# merge
random <- bind_rows(random, random_D117)
random$tx_v1 <- as.factor(random$tx_v1)
random$tx_v2 <- as.factor(random$tx_v2)
random$AATpush1_v1 <- as.factor(random$AATpush1_v1)
random$AATpush1_v2 <- as.factor(random$AATpush1_v2)
saveRDS(random, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/randomization.rds")
# merge
selfreports_oxtr_cortisol_random <- left_join(selfreports_oxtr_cortisol, random, BY="ID")
View(selfreports_oxtr_cortisol_random) # 40 obs of 688 vars
saveRDS(selfreports_oxtr_cortisol_random, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/selfreports_oxtr_cortisol_random.rds")
write.csv(selfreports_oxtr_cortisol_random, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/selfreports_oxtr_cortisol_random.csv")
# to print variable names one per row:
cat(names(selfreports_oxtr_cortisol_random),sep="\n")
selfreports_oxtr_cortisol_random <- readRDS("~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/selfreports_oxtr_cortisol_random.rds")
# Participants who got treatment A at visit 1:
selfreports_oxtr_cortisol_random %>%
select(ID, tot_pre_panas_pa_v1,
tot_pre_panas_na_v1,
tot_pre_stai_v1,
tot_pre_panas_pa_v2,
tot_pre_panas_na_v2,
tot_pre_stai_v2,
tot_post_panas_pa_v1,
tot_post_panas_na_v1,
tot_post_stai_v1,
tot_post_panas_pa_v2,
tot_post_panas_na_v2,
tot_post_stai_v2,
post_sroe_1_v1,
post_sroe_2_v1,
post_sroe_3_v1,
post_sroe_1_v2,
post_sroe_2_v2,
post_sroe_3_v2,
cortisol_BL_v1,
cortisol_BL_v2,
cortisol_PR_v1,
cortisol_PR_v2,
cortisol_PO_v1,
cortisol_PO_v2,
tx_v1) %>% filter(tx_v1 == "A") -> v1_tx_A
View(v1_tx_A) # 21 obs of 26 vars
# then split up by _v1/_v2:
v1_tx_A <- v1_tx_A[, grep('ID|_v1', names(v1_tx_A))] # 21 obs of 14 vars
# then strip out the "_v1" from column names
v1_tx_A %>%
rename_all(.funs = funs(sub("\\_v1", "", names(v1_tx_A)))) -> v1_tx_A
head(v1_tx_A)
# Participants who got treatment A at visit 2:
selfreports_oxtr_cortisol_random %>%
select(ID, tot_pre_panas_pa_v1,
tot_pre_panas_na_v1,
tot_pre_stai_v1,
tot_pre_panas_pa_v2,
tot_pre_panas_na_v2,
tot_pre_stai_v2,
tot_post_panas_pa_v1,
tot_post_panas_na_v1,
tot_post_stai_v1,
tot_post_panas_pa_v2,
tot_post_panas_na_v2,
tot_post_stai_v2,
post_sroe_1_v1,
post_sroe_2_v1,
post_sroe_3_v1,
post_sroe_1_v2,
post_sroe_2_v2,
post_sroe_3_v2,
cortisol_BL_v1,
cortisol_BL_v2,
cortisol_PR_v1,
cortisol_PR_v2,
cortisol_PO_v1,
cortisol_PO_v2,
tx_v2) %>% filter(tx_v2 == "A") -> v2_tx_A
View(v2_tx_A) # 21 obs of 26 vars
# then split up by _v1/_v2
v2_tx_A <- v2_tx_A[, grep('ID|_v2', names(v2_tx_A))] # 19 obs of 14 vars
# then strip out the "_v2" from column names
v2_tx_A %>%
rename_all(.funs = funs(sub("\\_v2", "", names(v2_tx_A)))) -> v2_tx_A
head(v2_tx_A)
# merge both A's:
A <- bind_rows(v1_tx_A, v2_tx_A)
View(A)
# Participants who got treatment B at visit 1:
selfreports_oxtr_cortisol_random %>%
select(ID, tot_pre_panas_pa_v1,
tot_pre_panas_na_v1,
tot_pre_stai_v1,
tot_pre_panas_pa_v2,
tot_pre_panas_na_v2,
tot_pre_stai_v2,
tot_post_panas_pa_v1,
tot_post_panas_na_v1,
tot_post_stai_v1,
tot_post_panas_pa_v2,
tot_post_panas_na_v2,
tot_post_stai_v2,
post_sroe_1_v1,
post_sroe_2_v1,
post_sroe_3_v1,
post_sroe_1_v2,
post_sroe_2_v2,
post_sroe_3_v2,
cortisol_BL_v1,
cortisol_BL_v2,
cortisol_PR_v1,
cortisol_PR_v2,
cortisol_PO_v1,
cortisol_PO_v2,
tx_v1) %>% filter(tx_v1 == "B") -> v1_tx_B
View(v1_tx_B) # 21 obs of 26 vars
# then split up by _v1/_v2:
v1_tx_B <- v1_tx_B[, grep('ID|_v1', names(v1_tx_B))] # 21 obs of 14 vars
# then strip out the "_v1" from column names
v1_tx_B %>%
rename_all(.funs = funs(sub("\\_v1", "", names(v1_tx_B)))) -> v1_tx_B
head(v1_tx_B)
# Participants who got treatment B at visit 2:
selfreports_oxtr_cortisol_random %>%
select(ID, tot_pre_panas_pa_v1,
tot_pre_panas_na_v1,
tot_pre_stai_v1,
tot_pre_panas_pa_v2,
tot_pre_panas_na_v2,
tot_pre_stai_v2,
tot_post_panas_pa_v1,
tot_post_panas_na_v1,
tot_post_stai_v1,
tot_post_panas_pa_v2,
tot_post_panas_na_v2,
tot_post_stai_v2,
post_sroe_1_v1,
post_sroe_2_v1,
post_sroe_3_v1,
post_sroe_1_v2,
post_sroe_2_v2,
post_sroe_3_v2,
cortisol_BL_v1,
cortisol_BL_v2,
cortisol_PR_v1,
cortisol_PR_v2,
cortisol_PO_v1,
cortisol_PO_v2,
tx_v2) %>% filter(tx_v2 == "B") -> v2_tx_B
View(v2_tx_B) # 21 obs of 26 vars
# then split up by _v1/_v2
v2_tx_B <- v2_tx_B[, grep('ID|_v2', names(v2_tx_B))] # 19 obs of 14 vars
# then strip out the "_v2" from column names
v2_tx_B %>%
rename_all(.funs = funs(sub("\\_v2", "", names(v2_tx_B)))) -> v2_tx_B
head(v2_tx_B)
# merge both B's:
B <- bind_rows(v1_tx_B, v2_tx_B)
View(B)
## rename:
A %>%
rename_at(vars(-ID),function(x) paste0(x,"_A")) -> A
head(A)
B %>%
rename_at(vars(-ID),function(x) paste0(x,"_B")) -> B
head(B)
# merge:
AB <- left_join(A, B, BY="ID") # 40 obs of 27 variables
Joining, by = "ID"
selfreports_oxtr_cortisol_random_AB <- left_join(selfreports_oxtr_cortisol_random, AB, BY="ID") # 40 obs of 719 variables
Joining, by = "ID"
saveRDS(selfreports_oxtr_cortisol_random_AB, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/selfreports_oxtr_cortisol_random_AB.rds")
# Create a subset of only numeric variables (i.e., not ID and qualitative SROE items) and order them alphabetically so they're easier to compare
select_if(AB, is.numeric) %>% select(order(colnames(.))) -> AB_viz
# Plot the variables:
for(i in 1:length(AB_viz)) boxplot(AB_viz[,i], xlab=NULL, main=names(AB_viz[i]))
for(i in 1:length(AB_viz)) hist(AB_viz[,i], xlab=NULL, main=names(AB_viz[i]))
stargazer(AB_viz, type="text")
===================================================
Statistic N Mean St. Dev. Min Max
---------------------------------------------------
cortisol_BL_A 25 4.530 2.524 1.000 9.900
cortisol_BL_B 24 5.520 3.519 1.360 13.780
cortisol_PO_A 29 5.642 8.498 0.860 47.780
cortisol_PO_B 29 4.166 2.899 1.170 14.630
cortisol_PR_A 29 5.377 6.569 1.420 35.210
cortisol_PR_B 27 4.801 3.378 1.440 14.420
post_sroe_3_A 40 1.950 0.783 1 3
post_sroe_3_B 39 1.974 0.811 1 4
tot_post_panas_na_A 40 11.400 2.085 10 19
tot_post_panas_na_B 40 11.200 1.667 10 16
tot_post_panas_pa_A 40 34.025 7.966 17 48
tot_post_panas_pa_B 40 33.075 7.163 21 50
tot_post_stai_A 40 30.425 8.950 20 61
tot_post_stai_B 40 29.675 7.852 20 54
tot_pre_panas_na_A 40 12.625 3.303 10 22
tot_pre_panas_na_B 40 12.900 3.622 10 27
tot_pre_panas_pa_A 40 34.250 6.679 14 48
tot_pre_panas_pa_B 40 32.900 6.994 21 50
tot_pre_stai_A 40 30.800 8.948 20 56
tot_pre_stai_B 40 33.275 9.816 20 63
---------------------------------------------------
# baseline
t.test(AB_viz$cortisol_BL_A, AB_viz$cortisol_BL_B,
alternative = "two.sided", paired = TRUE, var.equal = FALSE)
Paired t-test
data: AB_viz$cortisol_BL_A and AB_viz$cortisol_BL_B
t = -0.79093, df = 20, p-value = 0.4383
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-2.279418 1.026085
sample estimates:
mean of the differences
-0.6266667
# pre
t.test(AB_viz$cortisol_PR_A, AB_viz$cortisol_PR_B,
alternative = "two.sided", paired = TRUE, var.equal = FALSE)
Paired t-test
data: AB_viz$cortisol_PR_A and AB_viz$cortisol_PR_B
t = 0.56328, df = 25, p-value = 0.5783
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-1.922778 3.370470
sample estimates:
mean of the differences
0.7238462
# post
t.test(AB_viz$cortisol_PO_A, AB_viz$cortisol_PO_B,
alternative = "two.sided", paired = TRUE, var.equal = FALSE)
Paired t-test
data: AB_viz$cortisol_PO_A and AB_viz$cortisol_PO_B
t = 0.7701, df = 22, p-value = 0.4494
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-2.546138 5.553964
sample estimates:
mean of the differences
1.503913
Cortisol under tx A is not significantly different from cortisol under tx B, at any timepoint.
t.test(AB_viz$post_sroe_3_A, AB_viz$post_sroe_3_B,
alternative = "two.sided", paired = TRUE, var.equal = FALSE)
Paired t-test
data: AB_viz$post_sroe_3_A and AB_viz$post_sroe_3_B
t = 0, df = 38, p-value = 1
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.2576182 0.2576182
sample estimates:
mean of the differences
0
t.test(AB_viz$tot_pre_panas_na_A, AB_viz$tot_pre_panas_na_B,
alternative = "two.sided", paired = TRUE, var.equal = FALSE)
Paired t-test
data: AB_viz$tot_pre_panas_na_A and AB_viz$tot_pre_panas_na_B
t = -0.5806, df = 39, p-value = 0.5649
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-1.2330446 0.6830446
sample estimates:
mean of the differences
-0.275
t.test(AB_viz$tot_post_panas_na_A, AB_viz$tot_post_panas_na_B,
alternative = "two.sided", paired = TRUE, var.equal = FALSE)
Paired t-test
data: AB_viz$tot_post_panas_na_A and AB_viz$tot_post_panas_na_B
t = 0.48952, df = 39, p-value = 0.6272
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.6263951 1.0263951
sample estimates:
mean of the differences
0.2
t.test(AB_viz$tot_pre_panas_pa_A, AB_viz$tot_pre_panas_pa_B,
alternative = "two.sided", paired = TRUE, var.equal = FALSE)
Paired t-test
data: AB_viz$tot_pre_panas_pa_A and AB_viz$tot_pre_panas_pa_B
t = 1.4026, df = 39, p-value = 0.1686
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.5967769 3.2967769
sample estimates:
mean of the differences
1.35
t.test(AB_viz$tot_post_panas_pa_A, AB_viz$tot_post_panas_pa_B,
alternative = "two.sided", paired = TRUE, var.equal = FALSE)
Paired t-test
data: AB_viz$tot_post_panas_pa_A and AB_viz$tot_post_panas_pa_B
t = 0.94821, df = 39, p-value = 0.3489
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-1.076512 2.976512
sample estimates:
mean of the differences
0.95
t.test(AB_viz$tot_pre_stai_A, AB_viz$tot_pre_stai_B,
alternative = "two.sided", paired = TRUE, var.equal = FALSE)
Paired t-test
data: AB_viz$tot_pre_stai_A and AB_viz$tot_pre_stai_B
t = -2.754, df = 39, p-value = 0.008897
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-4.2928088 -0.6571912
sample estimates:
mean of the differences
-2.475
t.test(AB_viz$tot_post_stai_A, AB_viz$tot_post_stai_B,
alternative = "two.sided", paired = TRUE, var.equal = FALSE)
Paired t-test
data: AB_viz$tot_post_stai_A and AB_viz$tot_post_stai_B
t = 0.54526, df = 39, p-value = 0.5887
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-2.032202 3.532202
sample estimates:
mean of the differences
0.75
None of the self-report scores significantly differ under tx A vs. tx B, except for the pre-fMRI STAI, as shown below:
=========================================
Statistic N Mean St. Dev. Min Max
-----------------------------------------
tot_pre_stai_A 40 30.800 8.948 20 56
tot_pre_stai_B 40 33.275 9.816 20 63
-----------------------------------------
cat(sort(names), sep="\n")
Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) :
'x' must be atomic
Participants were asked to repeat the ICG 20-24 months after their participation in the study, either via mail or online.
library(tidyverse)
library(psych)
filter <- dplyr::filter
select <- dplyr::select
# Import CSV from Qualtrics
fu <- read.csv("~/Dropbox/GLASS Lab/OT Study/data/raw-data/OT+fMRI+Inventory+of+Complicated+Grief+-+20-mo.+Follow+Up_January+16%2C+2019_13.45.csv", stringsAsFactors = FALSE, na.strings="")[ ,-c(2:17)] %>%
filter(grepl("^D1", Consent, ignore.case = TRUE)) # remove rows that aren't IDs
# NOTE: D114 only completed the first page of the ICG (items 1-10). Her date of completion was input as 2 weeks post-sent date.
# Rename variables
fu <- rename(fu, date_followup = StartDate,
ID = Consent,
fu_icg_1 = ICG.R1.19_1,
fu_icg_2 = ICG.R1.19_2,
fu_icg_3 = ICG.R1.19_3,
fu_icg_4 = ICG.R1.19_4,
fu_icg_5 = ICG.R1.19_5,
fu_icg_6 = ICG.R1.19_6,
fu_icg_7 = ICG.R1.19_7,
fu_icg_8 = ICG.R1.19_8,
fu_icg_9 = ICG.R1.19_9,
fu_icg_10 = ICG.R1.19_10,
fu_icg_11 = ICG.R1.19_11,
fu_icg_12 = ICG.R1.19_12,
fu_icg_13 = ICG.R1.19_13,
fu_icg_14 = ICG.R1.19_14,
fu_icg_15 = ICG.R1.19_15,
fu_icg_16 = ICG.R1.19_16,
fu_icg_17 = ICG.R1.19_17,
fu_icg_18 = ICG.R1.19_18,
fu_icg_19 = ICG.R1.19_19)
# Make all of the ICG variables numeric and make date_followup into POSIXct (date format):
fu <- fu %>% mutate_at(vars(-c(ID,date_followup)), funs(as.numeric)) %>% mutate(date_followup = ymd_hm(date_followup))
fu <- fu %>% filter(!grepl("2018-01-08 15:32", date_followup)) # remove D125's response from 1-08-2018 (she has a duplicate)
# Scoring
##################
### Inventory of Complicated Grief
# Citation: Prigerson, H. G., Maciejewski, P. K., Reynolds, C. F., Bierhals, A. J., Newsom, J. T., Fasiczka, A., ... & Miller, M. (1995). Inventory of Complicated Grief: a scale to measure maladaptive symptoms of loss. Psychiatry Research, 59(1), 65-79.
# Answer choices range from 0 (Never) – 4 (Always).
# NO reverse scored items.
# Sum all items (possible range: 0 – 76; clinical cut-off = 25). [tot_icg]
tot_icg_20mFU <- subset(fu, select=c(fu_icg_1:fu_icg_19))
fu$tot_icg_20mFU <- rowSums(tot_icg_20mFU, na.rm=TRUE)
describe(fu$tot_icg_20mFU)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 33 15.52 10.25 13 14.59 11.86 2 45 43 0.75 0.19 1.78
qqnorm(fu$tot_icg_20mFU)
# Merge these variables into the master
data <- readRDS("~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/selfreports_oxtr_cortisol_random_AB.rds")
data <- left_join(data,fu, by="ID") # merge by ID
saveRDS(data, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/selfreports_oxtr_cortisol_random_AB_20mfu.rds")
# How correlated are the ICG measurements?
corr.test(data$tot_icg, data$tot_icg_20mFU)
Call:corr.test(x = data$tot_icg, y = data$tot_icg_20mFU)
Correlation matrix
[1] 0.82
Sample Size
[1] 33
Probability values adjusted for multiple tests.
[1] 0
To see confidence intervals of the correlations, print with the short=FALSE option
plot(data$tot_icg, data$tot_icg_20mFU)
t.test(data$tot_icg, data$tot_icg_20mFU, paired=TRUE)
Paired t-test
data: data$tot_icg and data$tot_icg_20mFU
t = 4.8321, df = 32, p-value = 3.236e-05
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
3.225330 7.926185
sample estimates:
mean of the differences
5.575758
# Descriptive stats and distributions (only participants with FU data)
ttest <- data %>% filter(tot_icg_20mFU != "NA")
describe(ttest$tot_icg)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 33 21.09 11.59 19 20.52 13.34 4 51 47 0.44 -0.5 2.02
describe(ttest$tot_icg_20mFU)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 33 15.52 10.25 13 14.59 11.86 2 45 43 0.75 0.19 1.78
boxplot(ttest$tot_icg,ttest$tot_icg_20mFU)
# Create a change variable
## question for down the line: if we use the change score, do we want to use difference scores or standardized residuals?
data <- data %>% mutate(change_icg = tot_icg_20mFU - tot_icg)
describe(data$change_icg)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 33 -5.58 6.63 -5 -5.37 5.93 -19 7 26 -0.33 -0.68 1.15
hist(data$change_icg)
boxplot(data$change_icg)
qqnorm(data$change_icg)
# Transform data to long format, for visualizing change over time
icg <- subset(data, select=c(ID, tot_icg)) %>% mutate(time = rep("1"))
icg_fu <- subset(data, select=c(ID, tot_icg_20mFU)) %>% rename(tot_icg = tot_icg_20mFU) %>% mutate(time = rep("2"))
change <- bind_rows(icg, icg_fu) %>% mutate(ID=as.factor(ID))
# Plot trajectories
p <- ggplot(data = change, aes(x = time, y = tot_icg, group = ID, colour=factor(ID))) +
geom_point(show.legend = FALSE) +
geom_line(show.legend = FALSE) +
geom_hline(yintercept=25)
p # I can label these with participant IDs but didn't for now so that I don't see who's in which group
# Is time since the death associated with ICG at either timepoint, or change in ICG?
corr.test(data$timesincedeath, data$tot_icg)
Call:corr.test(x = data$timesincedeath, y = data$tot_icg)
Correlation matrix
[1] 0.01
Sample Size
[1] 40
Probability values adjusted for multiple tests.
[1] 0.97
To see confidence intervals of the correlations, print with the short=FALSE option
plot(data$timesincedeath, data$tot_icg)
corr.test(data$timesincedeath, data$tot_icg_20mFU)
Call:corr.test(x = data$timesincedeath, y = data$tot_icg_20mFU)
Correlation matrix
[1] -0.04
Sample Size
[1] 33
Probability values adjusted for multiple tests.
[1] 0.82
To see confidence intervals of the correlations, print with the short=FALSE option
plot(data$timesincedeath, data$tot_icg_20mFU)
corr.test(data$timesincedeath, data$change_icg)
Call:corr.test(x = data$timesincedeath, y = data$change_icg)
Correlation matrix
[1] -0.06
Sample Size
[1] 33
Probability values adjusted for multiple tests.
[1] 0.74
To see confidence intervals of the correlations, print with the short=FALSE option
plot(data$timesincedeath, data$change_icg)
### CAN'T TEST THE FOLLOWING TIL YOU CREATE yrs_together VARIABLE IN THE NEXT CHUNK
# How about years together?
corr.test(data$yrs_together, data$tot_icg)
Error in cor(x, y, use = use, method = method) : 'x' must be numeric
Adding variables for group (CG vs. NCG), length of relationship, time from study to follow-up, …
library(tidyverse)
library(psych)
# RELATIONSHIP LENGTH
data <- readRDS("~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/selfreports_oxtr_cortisol_random_AB_20mfu.rds")
rel <- read.csv("~/Dropbox/GLASS Lab/OT Study/data/raw-data/relationship-length-from-screen.csv")
data <- left_join(data,rel, by="ID") # merge by ID
Column `ID` joining character vector and factor, coercing into character vector
data %>% select(ID, yrs_together) # double-check these are correct
# TIME FROM STUDY TO FOLLOW-UP
# First, we only care about the date they completed the follow-up survey, not the time
# so we'll split 'date_followup' into two variables, then remove the 'time' varialble.
data <- tidyr::separate(data, date_followup, c("date_followup", "time"), sep = " ")
data$time <- NULL
class(data$date_followup)
[1] "character"
# 'date_followup' need to be converted from character to date using lubridate's ymd function (ymd to match 'start_date' [when they were enrolled])
# Use the mdy function from lubridate to convert 'dob' and 'dateofdeath' from character to date.
data <- data %>%
mutate(date_followup = ymd(date_followup))
# Now we need to calculate time between study and follow-up
data <- data %>% mutate(timeto20mFU = date_followup - startdate) %>% mutate_at(vars(timeto20mFU), funs(as.numeric)) %>% mutate(timeto20mFU_mos = timeto20mFU/30.417)
# have to convert the new timesincedeath variable to numeric (vs. difftime) object, because there are a limited number of functions that can operate on difftime objects, then created a variable for time from study to FU in months (instead of days)
describe(data$timeto20mFU_mos)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 33 21.74 0.68 21.67 21.75 0.44 20.02 23.05 3.02 -0.22 -0.13 0.12
corr.test(data$tot_icg_20mFU, data$timeto20mFU_mos)
Call:corr.test(x = data$tot_icg_20mFU, y = data$timeto20mFU_mos)
Correlation matrix
[1] -0.32
Sample Size
[1] 33
Probability values adjusted for multiple tests.
[1] 0.07
To see confidence intervals of the correlations, print with the short=FALSE option
plot(data$tot_icg_20mFU, data$timeto20mFU_mos) # time between study participation and follow-up is weakly negatively correlated with ICG score at follow-up, r = -.32, p = .07. However, note the potential outlier in the lower right corner of the scatterplot.
# CG vs. NCG GROUP
data <- data %>% mutate(group = as.factor(ifelse(tot_icg > 25, "CG", "NCG"))) # at study
data$group <- relevel(data$group, ref="NCG") # make NCG the reference group
data <- data %>% mutate(group_20mFU = as.factor(ifelse(tot_icg_20mFU > 25, "CG", "NCG"))) # at follow-up
data$group_20mFU <- relevel(data$group_20mFU, ref="NCG") # make NCG the reference group
# How many in each group?
data %>% group_by(group) %>% count() # n = 23 NCG, n = 17 CG
data %>% group_by(group,group_20mFU) %>% count() # n = 28 NCG, n = 5 CG, 7 missing (2 NCG, 5 CG)
saveRDS(data, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/selfreports_oxtr_cortisol_random_AB_20mfu_addvars.rds")
# Resting state timing descriptives
library(tidyverse)
library(psych)
library(car)
Loading required package: carData
Attaching package: ‘car’
The following object is masked from ‘package:psych’:
logit
The following object is masked from ‘package:dplyr’:
recode
The following object is masked from ‘package:purrr’:
some
data <- readRDS("~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/selfreports_oxtr_cortisol_random_AB_20mfu_addvars.rds")
rs <- read.csv("~/Dropbox/GLASS Lab/OT Study/MRI protocols/Resting State Timing for R.csv")
rs <- subset(rs, select = c(ID, Visit, Vial, Mins))
rs$tx <- factor(rs$Vial, levels=c("A","B"), labels=c("A","B"))
rs$visit <- factor(rs$Visit, levels=c(1,2), labels=c("v1","v2"))
rs_v1A <- rs %>% filter(Vial == "A" & Visit == 1) %>% mutate(tx_v1 = "A")
rs_v1B <- rs %>% filter(Vial == "B" & Visit == 1) %>% mutate(tx_v1 = "B")
rs_v2A <- rs %>% filter(Vial == "A" & Visit == 2) %>% mutate(tx_v2 = "A")
rs_v2B <- rs %>% filter(Vial == "B" & Visit == 2) %>% mutate(tx_v2 = "B")
rsA <- bind_rows(rs_v1A,rs_v2A) %>% rename("timetorest_A" = Mins)
rsB <- bind_rows(rs_v1B,rs_v2B) %>% rename("timetorest_B" = Mins)
rest <- left_join(rsA, rsB, by="ID") %>% select(ID,timetorest_A, timetorest_B)
data <- left_join(data, rest, by="ID")
Column `ID` joining character vector and factor, coercing into character vector
describe(rest$timetorest_A)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 66.84 12.61 64.54 65.35 6.28 49.92 108.85 58.93 1.27 1.7 1.99
describe(rest$timetorest_B)
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 40 69.73 15.8 70.59 69.32 18.62 42.3 101.47 59.17 0.24 -0.75 2.5
t.test(rest$timetorest_A, rest$timetorest_B) # A and B not significantly different
Welch Two Sample t-test
data: rest$timetorest_A and rest$timetorest_B
t = -0.90548, df = 74.328, p-value = 0.3681
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-9.261919 3.473919
sample estimates:
mean of x mean of y
66.83725 69.73125
# do some spot-checking against the 'rs' item to make sure that the IDs, treatment, and times match up like they should
subset(data, select = c(ID, tx_A, timetorest_A))
saveRDS(data, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/selfreports_oxtr_cortisol_random_AB_20mfu_addvars_rest.rds")
Pre-R steps:
In Terminal, within each of the folders in turn…
find . -iname "*.iqdat" -exec bash -c 'mv "$0" "${0%\.iqdat}.tsv"' {} \;cat *.tsv > OT_gAAT_run-1.tsv (or OT_gAAT_run-2.tsv) mlr --tsvlite cat *.tsv > OT_gAAT_run-1.tsv (or OT_gAAT_run-2.tsv)
mlr --tsvlite drops the header from all but the first file, so column names are not repeated throughout the dataset.
# Behavioral data (gAAT)
library(tidyverse)
filter <- dplyr::filter
select <- dplyr::select
# read in the data (only importing a subset of columns)
raw_r1 <- data.frame(read_tsv("~/Dropbox/GLASS Lab/OT Study/data/raw-data/OT-gAAT-behavioral-data/Run1_tsv/OT_gAAT_run-1.tsv", col_types=cols_only(
date = col_integer(),
time = col_character(),
subject = col_character(),
blockcode = col_character(),
blocknum = col_character(),
trialcode = col_character(),
values.trialcode = col_character(),
values.stimulus = col_character(),
values.initialresponse = col_character(),
values.RT = col_number()
)))
number of columns of result is not a multiple of vector length (arg 1)154 parsing failures.
row [38;5;246m# A tibble: 5 x 5[39m col row col expected actual file expected [3m[38;5;246m<int>[39m[23m [3m[38;5;246m<chr>[39m[23m [3m[38;5;246m<chr>[39m[23m [3m[38;5;246m<chr>[39m[23m [3m[38;5;246m<chr>[39m[23m actual [38;5;250m1[39m 327 date an integer date '~/Dropbox/GLASS Lab/OT Study/data/raw-data/OT-gAAT-behavioral-data/Run1_tsv/OT_gAAT_run-1.tsv' file [38;5;250m2[39m 327 values.RT a number . '~/Dropbox/GLASS Lab/OT Study/data/raw-data/OT-gAAT-behavioral-data/Run1_tsv/OT_gAAT_run-1.tsv' row [38;5;250m3[39m 653 date an integer date '~/Dropbox/GLASS Lab/OT Study/data/raw-data/OT-gAAT-behavioral-data/Run1_tsv/OT_gAAT_run-1.tsv' col [38;5;250m4[39m 653 values.RT a number . '~/Dropbox/GLASS Lab/OT Study/data/raw-data/OT-gAAT-behavioral-data/Run1_tsv/OT_gAAT_run-1.tsv' expected [38;5;250m5[39m 974 date an integer date '~/Dropbox/GLASS Lab/OT Study/data/raw-data/OT-gAAT-behavioral-data/Run1_tsv/OT_gAAT_run-1.tsv'
... ................................. ... ................................................................................................................................... ........ ................................................................................................................................................................................................................................................................ ...... ................................................................................................................................................... .... ................................................................................................................................................... ... ................................................................................................................................................... ... ................................................................................................................................................... ........ ...................................................................................................................................................
See problems(...) for more details.
raw_r2 <- data.frame(read_tsv("~/Dropbox/GLASS Lab/OT Study/data/raw-data/OT-gAAT-behavioral-data/Run2_tsv/OT_gAAT_run-2.tsv", col_types=cols_only(
date = col_integer(),
time = col_character(),
subject = col_character(),
blockcode = col_character(),
blocknum = col_character(),
trialcode = col_character(),
values.trialcode = col_character(),
values.stimulus = col_character(),
values.initialresponse = col_character(),
values.RT = col_number()
)))
number of columns of result is not a multiple of vector length (arg 1)154 parsing failures.
row [38;5;246m# A tibble: 5 x 5[39m col row col expected actual file expected [3m[38;5;246m<int>[39m[23m [3m[38;5;246m<chr>[39m[23m [3m[38;5;246m<chr>[39m[23m [3m[38;5;246m<chr>[39m[23m [3m[38;5;246m<chr>[39m[23m actual [38;5;250m1[39m 324 date an integer date '~/Dropbox/GLASS Lab/OT Study/data/raw-data/OT-gAAT-behavioral-data/Run2_tsv/OT_gAAT_run-2.tsv' file [38;5;250m2[39m 324 values.RT a number . '~/Dropbox/GLASS Lab/OT Study/data/raw-data/OT-gAAT-behavioral-data/Run2_tsv/OT_gAAT_run-2.tsv' row [38;5;250m3[39m 643 date an integer date '~/Dropbox/GLASS Lab/OT Study/data/raw-data/OT-gAAT-behavioral-data/Run2_tsv/OT_gAAT_run-2.tsv' col [38;5;250m4[39m 643 values.RT a number . '~/Dropbox/GLASS Lab/OT Study/data/raw-data/OT-gAAT-behavioral-data/Run2_tsv/OT_gAAT_run-2.tsv' expected [38;5;250m5[39m 954 date an integer date '~/Dropbox/GLASS Lab/OT Study/data/raw-data/OT-gAAT-behavioral-data/Run2_tsv/OT_gAAT_run-2.tsv'
... ................................. ... ................................................................................................................................... ........ ................................................................................................................................................................................................................................................................ ...... ................................................................................................................................................... .... ................................................................................................................................................... ... ................................................................................................................................................... ... ................................................................................................................................................... ........ ...................................................................................................................................................
See problems(...) for more details.
# header line repeats when I used cat to merge, so get those out of there
raw_r1 <- raw_r1 %>% filter(!is.na(date))
raw_r2 <- raw_r2 %>% filter(!is.na(date))
unique(raw_r1$subject)
[1] "D101" "D101_2" "D102" "D102_B" "D103" "D103_b" "D104" "D104_b" "D105" "D105_b" "D107" "D107_b" "D110" "D110_b" "D113" "D113_b" "D114"
[18] "D114_b" "D115" "D115_b" "D117_b" "D117_c" "test" "D118_b" "D119" "D119_b" "D120" "D120_b" "D121" "D121_b" "D122" "D122_b" "D123" "D123_b"
[35] "D125" "D125_b" "D126" "D126_b" "D127" "D127_b" "D128" "D128_b" "D129" "D129_b" "D130" "D131" "D131_b" "D132" "D132_b" "D133" "D133_b"
[52] "D134" "D134_b" "D135" "D135_c" "D137" "D137_b" "D138" "D138_b" "D139" "D139_b" "D140" "D140_b" "D141" "D141_b" "D142" "D144" "D144_b"
[69] "D145" "D145_b" "D146" "D146_b" "D147" "D147_b" "D148" "D148_b"
# D118 is showing up as "test" for some reason (checked against the .iqdat file), and D130_b is missing
# both of D130's and D142's visits were entered as "D130"/"D142", so change the subject ID for the visit on 052416 to D130_b and on
raw_r1$subject[raw_r1$date == 020916] <- "D118"
raw_r1$subject[raw_r1$date == 052416] <- "D130_b"
raw_r1$subject[raw_r1$date == 111516] <- "D142_b"
# fixing some other stuff in a similar vein
raw_r1$subject[raw_r1$subject == "D101_2"] <- "D101_b"
raw_r1$subject[raw_r1$subject == "D102_B"] <- "D102_b"
raw_r1$subject[raw_r1$subject == "D117_b"] <- "D117"
raw_r1$subject[raw_r1$subject == "D117_c"] <- "D117_b"
raw_r1$subject[raw_r1$subject == "D135_c"] <- "D135_b"
u <- unique(raw_r1$subject)
length(u) # 78 unique - that is correct
[1] 78
unique(raw_r2$subject)
[1] "D101" "D101_2Y" "D102" "D102_B" "D103" "D103_b" "D104" "D104_b" "D105" "D105_b" "D107" "D107_B_2" "D110"
[14] "D110_b" "D113" "D113_b" "D114" "D114_b" "D115" "D115_b" "D117_b" "D117_c" "D118" "D118_b" "D119" "D119_b"
[27] "D120" "D120_b" "D121" "D121_b" "D122" "D122_b" "D123" "D123_b" "D125" "D125_b" "D126" "D126_B" "D127"
[40] "D127_b" "D128" "D128_b" "D129" "D129_b" "D130" "D130_b" "D131" "D131_b" "D132" "D132_b" "D133" "D133_b"
[53] "D134" "D134_b" "D135" "D135_c" "D137" "D137_b" "D138" "D138_b" "D139" "D139_b" "D140" "D140_b" "D141"
[66] "D141_b" "D142" "D144" "D144_b" "D145" "D145_b" "D146" "D146_b" "D147" "D147_b" "D148" "D148_b"
# some similar issues to fix
raw_r2$subject[raw_r2$subject == "D101_2Y"] <- "D101_b"
raw_r2$subject[raw_r2$subject == "D102_B"] <- "D102_b"
raw_r2$subject[raw_r2$subject == "D107_B_2"] <- "D107_b"
raw_r2$subject[raw_r2$subject == "D117_b"] <- "D117"
raw_r2$subject[raw_r2$subject == "D117_c"] <- "D117_b"
raw_r2$subject[raw_r2$subject == "D126_B"] <- "D126_b"
raw_r2$subject[raw_r2$subject == "D135_c"] <- "D135_b"
raw_r2$subject[raw_r2$date == 111516] <- "D142_b"
u <- unique(raw_r2$subject)
length(u) # 78 unique - that is correct
[1] 78
str(raw_r1)
'data.frame': 25746 obs. of 10 variables:
$ date : int 101515 101515 101515 101515 101515 101515 101515 101515 101515 101515 ...
$ time : chr "15:38:09" "15:38:09" "15:38:09" "15:38:09" ...
$ subject : chr "D101" "D101" "D101" "D101" ...
$ blockcode : chr "AATpracticeB" "AATpracticeB" "AATpracticeB" "AATpracticeB" ...
$ blocknum : chr "2" "2" "2" "2" ...
$ trialcode : chr "practicetrial_B" "practiceincrease" "practiceincrease" "practiceincrease" ...
$ values.trialcode : chr "practicetrial_B" "practicetrial_B" "practicetrial_B" "practicetrial_B" ...
$ values.stimulus : chr "grayrectangle_Y.jpg" "grayrectangle_Y.jpg" "grayrectangle_Y.jpg" "grayrectangle_Y.jpg" ...
$ values.initialresponse: chr "PULL" "PULL" "PULL" "PULL" ...
$ values.RT : num 1411 1411 1411 1411 1411 ...
str(raw_r2)
'data.frame': 25457 obs. of 10 variables:
$ date : int 101515 101515 101515 101515 101515 101515 101515 101515 101515 101515 ...
$ time : chr "15:48:12" "15:48:12" "15:48:12" "15:48:12" ...
$ subject : chr "D101" "D101" "D101" "D101" ...
$ blockcode : chr "AATpracticeA" "AATpracticeA" "AATpracticeA" "AATpracticeA" ...
$ blocknum : chr "2" "2" "2" "2" ...
$ trialcode : chr "practicetrial_A" "practicedecrease" "practicedecrease" "practicedecrease" ...
$ values.trialcode : chr "practicetrial_A" "practicetrial_A" "practicetrial_A" "practicetrial_A" ...
$ values.stimulus : chr "grayrectangle_B.jpg" "grayrectangle_B.jpg" "grayrectangle_B.jpg" "grayrectangle_B.jpg" ...
$ values.initialresponse: chr "PUSH" "PUSH" "PUSH" "PUSH" ...
$ values.RT : num 1472 1472 1472 1472 1472 ...
# take out ITIs (inter-trial intervals)
unique(raw_r1$trialcode)
r1 <- filter(raw_r1, grepl("^A",trialcode))
unique(r1$trialcode)
unique(raw_r2$trialcode)
r2 <- filter(raw_r2, grepl("^A",trialcode))
unique(r2$trialcode)
# add a "trialnum" variable, grouped by ID
r1 <- r1 %>% group_by(subject) %>% mutate(trialnum = row_number())
View(r2)
r2 <- r2 %>% group_by(subject) %>% mutate(trialnum = row_number())
View(r2)
r1 %>% group_by(trialnum) %>% count(trialnum) # everyone has 144 trials, hooray! (look at n for each trialnum, should = 78)
r2 %>% group_by(trialnum) %>% count(trialnum) # everyone has 144 trials, one person has 177
r2 %>% filter(trialnum >144)
I do recall one scan session where Inquisit had some kind of hiccup and the task kept going beyond the end of the fMRI sequence so we had to force-quit it. D122 has complete data from the first 144 trials, so we can just drop the extra ones.
r2 <- filter(r2, trialnum <=144) # remove trials 145-177 for D122_b
r2 %>% filter(trialnum >144)
# now everyone has 144 trials
# add a column for "run"
r1$run <- "1"
r2$run <- "2"
# add a column for "visit"
r1$visit <- as.factor(ifelse(grepl("*_b", r1$subject), "2", "1"))
r2$visit <- as.factor(ifelse(grepl("*_b", r2$subject), "2", "1"))
r1 %>% group_by(subject) %>% count(visit) # all looks good
r2 %>% group_by(subject) %>% count(visit) # all looks good
# now remove the "_b" from visit 2 IDs
r1 <- r1 %>% ungroup() %>%
mutate(subject = str_replace(subject, "_b", ""))
unique(r1$subject)
[1] "D101" "D102" "D103" "D104" "D105" "D107" "D110" "D113" "D114" "D115" "D117" "D118" "D119" "D120" "D121" "D122" "D123" "D125" "D126" "D127" "D128"
[22] "D129" "D130" "D131" "D132" "D133" "D134" "D135" "D137" "D138" "D139" "D140" "D141" "D142" "D144" "D145" "D146" "D147" "D148"
r2 <- r2 %>% ungroup() %>%
mutate(subject = str_replace(subject, "_b", ""))
unique(r2$subject)
[1] "D101" "D102" "D103" "D104" "D105" "D107" "D110" "D113" "D114" "D115" "D117" "D118" "D119" "D120" "D121" "D122" "D123" "D125" "D126" "D127" "D128"
[22] "D129" "D130" "D131" "D132" "D133" "D134" "D135" "D137" "D138" "D139" "D140" "D141" "D142" "D144" "D145" "D146" "D147" "D148"
# merge data from the 2 runs
bx <- bind_rows(r1, r2)
# split up by visit
v1 <- bx %>% filter(visit == "1")
v2 <- bx %>% filter(visit == "2")
# check that everyone has 144 trials
v1 %>% filter(trialnum >144)
v2 %>% filter(trialnum >144)
# add columns for "tx" at visit 1 and visit 2 [treatment: A or B]
# load in the randomization data
randomize <- readRDS("~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/randomization.rds")
head(randomize)
v1 <- v1 %>%
rename("ID" = subject)
v2 <- v2 %>%
rename("ID" = subject)
# get the IDs for everyone who got treatment A at visit 1
IDs_v1_txA <- randomize %>% filter(tx_v1 == "A")
IDs_v1_txA
# ifelse statement: if ID = any of those listed in IDs_v1_txA, make tx_v1 = "A", else make it "B"
v1 <- v1 %>%
mutate(tx_v1 = as.factor(ifelse(ID == "D101" | ID == "D105" | ID == "D109" | ID == "D110" | ID == "D114" | ID == "D115" | ID == "D116" | ID == "D118" | ID == "D119" | ID == "D120" | ID == "D123" | ID == "D124" | ID == "D126" | ID == "D128" | ID == "D132" | ID == "D135" | ID == "D136" | ID == "D137" | ID == "D138" | ID == "D140" | ID == "D141" | ID == "D145" | ID == "D148" | ID == "D149" | ID == "D117", "A", "B")), tx_v2 = as.factor(ifelse(ID == "D101" | ID == "D105" | ID == "D109" | ID == "D110" | ID == "D114" | ID == "D115" | ID == "D116" | ID == "D118" | ID == "D119" | ID == "D120" | ID == "D123" | ID == "D124" | ID == "D126" | ID == "D128" | ID == "D132" | ID == "D135" | ID == "D136" | ID == "D137" | ID == "D138" | ID == "D140" | ID == "D141" | ID == "D145" | ID == "D148" | ID == "D149" | ID == "D117", "B", "A")))
head(v1)
# ifelse statement: if ID = any of those listed in IDs_v1_txA, make tx_v2 = "B", else make it "A" (people who were A at visit 1 should be B for visit 2, and vice versa)
v2 <- v2 %>%
mutate(tx_v2 = as.factor(ifelse(ID == "D101" | ID == "D105" | ID == "D109" | ID == "D110" | ID == "D114" | ID == "D115" | ID == "D116" | ID == "D118" | ID == "D119" | ID == "D120" | ID == "D123" | ID == "D124" | ID == "D126" | ID == "D128" | ID == "D132" | ID == "D135" | ID == "D136" | ID == "D137" | ID == "D138" | ID == "D140" | ID == "D141" | ID == "D145" | ID == "D148" | ID == "D149" | ID == "D117", "B", "A")), tx_v1 = as.factor(ifelse(ID == "D101" | ID == "D105" | ID == "D109" | ID == "D110" | ID == "D114" | ID == "D115" | ID == "D116" | ID == "D118" | ID == "D119" | ID == "D120" | ID == "D123" | ID == "D124" | ID == "D126" | ID == "D128" | ID == "D132" | ID == "D135" | ID == "D136" | ID == "D137" | ID == "D138" | ID == "D140" | ID == "D141" | ID == "D145" | ID == "D148" | ID == "D149" | ID == "D117", "A", "B")))
levels(v1$tx_v1)
[1] "A" "B"
levels(v2$tx_v2)
[1] "A" "B"
head(v1)
IDs_v1_txA$ID
[1] "D101" "D105" "D109" "D110" "D114" "D115" "D116" "D118" "D119" "D120" "D123" "D124" "D126" "D128" "D132" "D135" "D136" "D137" "D138" "D140" "D141"
[22] "D145" "D148" "D149" "D117"
v1 %>% group_by(tx_v1) %>% count(ID) # IDs and tx match txA_list
v2 %>% group_by(tx_v2) %>% count(ID) # IDs and tx match txA_list
bx <- bind_rows(v1,v2)
View(bx)
# rename some variables
colnames(bx)
[1] "date" "time" "ID" "blockcode" "blocknum" "trialcode"
[7] "values.trialcode" "values.stimulus" "values.initialresponse" "values.RT" "trialnum" "run"
[13] "visit" "tx_v1" "tx_v2"
bx <- bx %>% rename("push_pull" = values.initialresponse,
"gAAT_RT" = values.RT) %>% mutate(push_pull = as.factor(push_pull))
head(bx)
# add a new variable for treatment
bx1 <- bx %>% mutate(tx = as.factor(ifelse(tx_v1 == "A" & visit == "1", "A",
ifelse(tx_v2 == "A" & visit == "2", "A",
ifelse(tx_v1 == "B" & visit == "1", "B",
ifelse(tx_v2 == "B" & visit == "2", "B", NA))))))
# check that it coded the 'tx' column correctly
bx1 %>% filter(ID == "D101" & visit == "1") # 'tx' should be A
bx1 %>% filter(ID == "D101" & visit == "2") # 'tx' should be B
# add a new variable for stimulus category
# in values.stimulus:
# 1 = spouse, 2 = living loved one/WHOTO, 3 = stranger, 4 = nomothetic death-related, 5 = neutral images
sort(unique(bx1$values.stimulus))
[1] "1B_1.jpg" "1B_2.jpg" "1B_3.jpg" "1Y_1.jpg" "1Y_2.jpg" "1Y_3.jpg" "2B_1.jpg" "2B_2.jpg" "2B_3.jpg" "2Y_1.jpg" "2Y_2.jpg" "2Y_3.jpg" "3B_1.jpg"
[14] "3B_2.jpg" "3B_3.jpg" "3Y_1.jpg" "3Y_2.jpg" "3Y_3.jpg" "4B_1.jpg" "4B_2.jpg" "4B_3.jpg" "4Y_1.jpg" "4Y_2.jpg" "4Y_3.jpg" "5B_1.jpg" "5B_2.jpg"
[27] "5B_3.jpg" "5Y_1.jpg" "5Y_2.jpg" "5Y_3.jpg"
bx2 <- bx1 %>%
mutate(stim = as.factor(ifelse(values.stimulus == "1B_1.jpg"|values.stimulus == "1B_2.jpg"|values.stimulus == "1B_3.jpg"|values.stimulus == "1Y_1.jpg"|values.stimulus == "1Y_2.jpg"|values.stimulus == "1Y_3.jpg", "spouse",
ifelse(values.stimulus == "2B_1.jpg"|values.stimulus == "2B_2.jpg"|values.stimulus == "2B_3.jpg"|values.stimulus == "2Y_1.jpg"|values.stimulus == "2Y_2.jpg"|values.stimulus == "2Y_3.jpg", "living",
ifelse(values.stimulus == "3B_1.jpg"|values.stimulus == "3B_2.jpg"|values.stimulus == "3B_3.jpg"|values.stimulus == "3Y_1.jpg"|values.stimulus == "3Y_2.jpg"|values.stimulus == "3Y_3.jpg", "stranger",
ifelse(values.stimulus == "4B_1.jpg"|values.stimulus == "4B_2.jpg"|values.stimulus == "4B_3.jpg"|values.stimulus == "4Y_1.jpg"|values.stimulus == "4Y_2.jpg"|values.stimulus == "4Y_3.jpg", "death",
ifelse(values.stimulus == "5B_1.jpg"|values.stimulus == "5B_2.jpg"|values.stimulus == "5B_3.jpg"|values.stimulus == "5Y_1.jpg"|values.stimulus == "5Y_2.jpg"|values.stimulus == "5Y_3.jpg", "neutral", NA)))))))
levels(bx2$stim)
[1] "death" "living" "neutral" "spouse" "stranger"
bx2$stim <- relevel(bx2$stim, ref = "neutral") # make neutral the reference level
The top and bottom 1% of RTs will be removed as part of conventional data cleaning for this task.
p99 <- quantile(bx2$gAAT_RT, 0.99)
p01 <- quantile(bx2$gAAT_RT, 0.01)
# drop top and bottom 1% of RTs and remove outliers from data
bx2 <- bx2 %>% mutate(outlier_RT = as.factor(ifelse(gAAT_RT <= p01 | gAAT_RT >= p99, 1, 0))) %>% filter(outlier_RT == "0")
Assuming a 10% threshold for missed trials, find out if anyone’s missing more than this.
288-(288*.10) # based on the 10% cutoff, people should have at least 259 trials
[1] 259.2
n <- bx2 %>% group_by(ID) %>% group_by(tx) %>% count(ID)
n %>% filter(n < 259) # does anyone have fewer than 259? yes, D107 has only 248
Save the long dataset.
# save it
saveRDS(bx2, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/gAAT_long.rds")
write.csv(bx2, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/gAAT_long.csv")
Next step: subsetting and taking data from long to wide.
# Subset by stimulus category and treatment
## image filenames ('values.stimulus') starting with 1 = spouse, 2 = WHOTO, 3 = stranger, 4 = nomothetic death, 5 = neutral images
spouse_push_A <- filter(bx2, grepl("1B_|1Y_",values.stimulus) & grepl("PUSH",push_pull) & grepl("A",tx))
spouse_push_B <- filter(bx2, grepl("1B_|1Y_",values.stimulus) & grepl("PUSH",push_pull) & grepl("B",tx))
spouse_pull_A <- filter(bx2, grepl("1B_|1Y_",values.stimulus) & grepl("PULL",push_pull) & grepl("A",tx))
spouse_pull_B <- filter(bx2, grepl("1B_|1Y_",values.stimulus) & grepl("PULL",push_pull) & grepl("B",tx))
whoto_push_A <- filter(bx2, grepl("2B_|1Y_",values.stimulus) & grepl("PUSH",push_pull) & grepl("A",tx))
whoto_push_B <- filter(bx2, grepl("2B_|1Y_",values.stimulus) & grepl("PUSH",push_pull) & grepl("B",tx))
whoto_pull_A <- filter(bx2, grepl("2B_|1Y_",values.stimulus) & grepl("PULL",push_pull) & grepl("A",tx))
whoto_pull_B <- filter(bx2, grepl("2B_|1Y_",values.stimulus) & grepl("PULL",push_pull) & grepl("B",tx))
stranger_push_A <- filter(bx2, grepl("3B_|1Y_",values.stimulus) & grepl("PUSH",push_pull) & grepl("A",tx))
stranger_push_B <- filter(bx2, grepl("3B_|1Y_",values.stimulus) & grepl("PUSH",push_pull) & grepl("B",tx))
stranger_pull_A <- filter(bx2, grepl("3B_|1Y_",values.stimulus) & grepl("PULL",push_pull) & grepl("A",tx))
stranger_pull_B <- filter(bx2, grepl("3B_|1Y_",values.stimulus) & grepl("PULL",push_pull) & grepl("B",tx))
death_push_A <- filter(bx2, grepl("4B_|1Y_",values.stimulus) & grepl("PUSH",push_pull) & grepl("A",tx))
death_push_B <- filter(bx2, grepl("4B_|1Y_",values.stimulus) & grepl("PUSH",push_pull) & grepl("B",tx))
death_pull_A <- filter(bx2, grepl("4B_|1Y_",values.stimulus) & grepl("PULL",push_pull) & grepl("A",tx))
death_pull_B <- filter(bx2, grepl("4B_|1Y_",values.stimulus) & grepl("PULL",push_pull) & grepl("B",tx))
neutral_push_A <- filter(bx2, grepl("5B_|1Y_",values.stimulus) & grepl("PUSH",push_pull) & grepl("A",tx))
neutral_push_B <- filter(bx2, grepl("5B_|1Y_",values.stimulus) & grepl("PUSH",push_pull) & grepl("B",tx))
neutral_pull_A <- filter(bx2, grepl("5B_|1Y_",values.stimulus) & grepl("PULL",push_pull) & grepl("A",tx))
neutral_pull_B <- filter(bx2, grepl("5B_|1Y_",values.stimulus) & grepl("PULL",push_pull) & grepl("B",tx))
# Summarize RTs
spouse_push_A %>% group_by(ID) %>% summarise_at(vars(gAAT_RT), median, na.rm = FALSE) -> spouse_push_A.1
spouse_push_B %>% group_by(ID) %>% summarise_at(vars(gAAT_RT), median, na.rm = FALSE) -> spouse_push_B.1
spouse_pull_A %>% group_by(ID) %>% summarise_at(vars(gAAT_RT), median, na.rm = FALSE) -> spouse_pull_A.1
spouse_pull_B %>% group_by(ID) %>% summarise_at(vars(gAAT_RT), median, na.rm = FALSE) -> spouse_pull_B.1
whoto_push_A %>% group_by(ID) %>% summarise_at(vars(gAAT_RT), median, na.rm = FALSE) -> whoto_push_A.1
whoto_push_B %>% group_by(ID) %>% summarise_at(vars(gAAT_RT), median, na.rm = FALSE) -> whoto_push_B.1
whoto_pull_A %>% group_by(ID) %>% summarise_at(vars(gAAT_RT), median, na.rm = FALSE) -> whoto_pull_A.1
whoto_pull_B %>% group_by(ID) %>% summarise_at(vars(gAAT_RT), median, na.rm = FALSE) -> whoto_pull_B.1
stranger_push_A %>% group_by(ID) %>% summarise_at(vars(gAAT_RT), median, na.rm = FALSE) -> stranger_push_A.1
stranger_push_B %>% group_by(ID) %>% summarise_at(vars(gAAT_RT), median, na.rm = FALSE) -> stranger_push_B.1
stranger_pull_A %>% group_by(ID) %>% summarise_at(vars(gAAT_RT), median, na.rm = FALSE) -> stranger_pull_A.1
stranger_pull_B %>% group_by(ID) %>% summarise_at(vars(gAAT_RT), median, na.rm = FALSE) -> stranger_pull_B.1
death_push_A %>% group_by(ID) %>% summarise_at(vars(gAAT_RT), median, na.rm = FALSE) -> death_push_A.1
death_push_B %>% group_by(ID) %>% summarise_at(vars(gAAT_RT), median, na.rm = FALSE) -> death_push_B.1
death_pull_A %>% group_by(ID) %>% summarise_at(vars(gAAT_RT), median, na.rm = FALSE) -> death_pull_A.1
death_pull_B %>% group_by(ID) %>% summarise_at(vars(gAAT_RT), median, na.rm = FALSE) -> death_pull_B.1
neutral_push_A %>% group_by(ID) %>% summarise_at(vars(gAAT_RT), median, na.rm = FALSE) -> neutral_push_A.1
neutral_push_B %>% group_by(ID) %>% summarise_at(vars(gAAT_RT), median, na.rm = FALSE) -> neutral_push_B.1
neutral_pull_A %>% group_by(ID) %>% summarise_at(vars(gAAT_RT), median, na.rm = FALSE) -> neutral_pull_A.1
neutral_pull_B %>% group_by(ID) %>% summarise_at(vars(gAAT_RT), median, na.rm = FALSE) -> neutral_pull_B.1
# add a suffix (for the wide dataset)
spouse_push_A.2 <- spouse_push_A.1 %>%
rename_at(vars(gAAT_RT),function(x) paste0(x,"_spouse_push_A"))
spouse_push_B.2 <- spouse_push_B.1 %>%
rename_at(vars(gAAT_RT),function(x) paste0(x,"_spouse_push_B"))
spouse_pull_A.2 <- spouse_pull_A.1 %>%
rename_at(vars(gAAT_RT),function(x) paste0(x,"_spouse_pull_A"))
spouse_pull_B.2 <- spouse_pull_B.1 %>%
rename_at(vars(gAAT_RT),function(x) paste0(x,"_spouse_pull_B"))
whoto_push_A.2 <- whoto_push_A.1 %>%
rename_at(vars(gAAT_RT),function(x) paste0(x,"_whoto_push_A"))
whoto_push_B.2 <- whoto_push_B.1 %>%
rename_at(vars(gAAT_RT),function(x) paste0(x,"_whoto_push_B"))
whoto_pull_A.2 <- whoto_pull_A.1 %>%
rename_at(vars(gAAT_RT),function(x) paste0(x,"_whoto_pull_A"))
whoto_pull_B.2 <- whoto_pull_B.1 %>%
rename_at(vars(gAAT_RT),function(x) paste0(x,"_whoto_pull_B"))
stranger_push_A.2 <- stranger_push_A.1 %>%
rename_at(vars(gAAT_RT),function(x) paste0(x,"_stranger_push_A"))
stranger_push_B.2 <- stranger_push_B.1 %>%
rename_at(vars(gAAT_RT),function(x) paste0(x,"_stranger_push_B"))
stranger_pull_A.2 <- stranger_pull_A.1 %>%
rename_at(vars(gAAT_RT),function(x) paste0(x,"_stranger_pull_A"))
stranger_pull_B.2 <- stranger_pull_B.1 %>%
rename_at(vars(gAAT_RT),function(x) paste0(x,"_stranger_pull_B"))
death_push_A.2 <- death_push_A.1 %>%
rename_at(vars(gAAT_RT),function(x) paste0(x,"_death_push_A"))
death_push_B.2 <- death_push_B.1 %>%
rename_at(vars(gAAT_RT),function(x) paste0(x,"_death_push_B"))
death_pull_A.2 <- death_pull_A.1 %>%
rename_at(vars(gAAT_RT),function(x) paste0(x,"_death_pull_A"))
death_pull_B.2 <- death_pull_B.1 %>%
rename_at(vars(gAAT_RT),function(x) paste0(x,"_death_pull_B"))
neutral_push_A.2 <- neutral_push_A.1 %>%
rename_at(vars(gAAT_RT),function(x) paste0(x,"_neutral_push_A"))
neutral_push_B.2 <- neutral_push_B.1 %>%
rename_at(vars(gAAT_RT),function(x) paste0(x,"_neutral_push_B"))
neutral_pull_A.2 <- neutral_pull_A.1 %>%
rename_at(vars(gAAT_RT),function(x) paste0(x,"_neutral_pull_A"))
neutral_pull_B.2 <- neutral_pull_B.1 %>%
rename_at(vars(gAAT_RT),function(x) paste0(x,"_neutral_pull_B"))
# merge
data <- readRDS("~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/selfreports_oxtr_cortisol_random_AB_20mfu_addvars_rest.rds")
IDs <- data.frame(data$ID)
IDs <- IDs %>% rename(ID = data.ID)
join1bx <- left_join(data, spouse_pull_A.2, by="ID")
join2bx <- left_join(join1bx, spouse_pull_B.2, by="ID")
join3bx <- left_join(join2bx, spouse_push_A.2, by="ID")
join4bx <- left_join(join3bx, spouse_push_B.2, by="ID")
join5bx <- left_join(join4bx, stranger_pull_A.2, by="ID")
join6bx <- left_join(join5bx, stranger_pull_B.2, by="ID")
join7bx <- left_join(join6bx, stranger_push_A.2, by="ID")
join8bx <- left_join(join7bx, stranger_push_B.2, by="ID")
join9bx <- left_join(join8bx, whoto_pull_A.2, by="ID")
join10bx <- left_join(join9bx, whoto_pull_B.2, by="ID")
join11bx <- left_join(join10bx, whoto_push_A.2, by="ID")
join12bx <- left_join(join11bx, whoto_push_B.2, by="ID")
join13bx <- left_join(join12bx, neutral_pull_A.2, by="ID")
join14bx <- left_join(join13bx, neutral_pull_B.2, by="ID")
join15bx <- left_join(join14bx, neutral_push_A.2, by="ID")
join16bx <- left_join(join15bx, neutral_push_B.2, by="ID")
join17bx <- left_join(join16bx, death_pull_A.2, by="ID")
join18bx <- left_join(join17bx, death_pull_B.2, by="ID")
join19bx <- left_join(join18bx, death_push_A.2, by="ID")
join20bx <- left_join(join19bx, death_push_B.2, by="ID")
data <- join20bx
saveRDS(data, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/selfreports_oxtr_cortisol_random_AB_20mfu_addvars_rest_gAAT.rds")
gAAT_wide <- join20bx[, grep('^ID|gAAT', names(data))]
saveRDS(gAAT_wide, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/gAAT_wide.rds")
write.csv(gAAT_wide, "~/Dropbox/GLASS Lab/OT Study/data/cleaned-data/gAAT_wide.csv")
# make a variable for total number of Rx meds
data_meds <- data_meds %>%
separate_rows(meds_rxonly) %>%
filter(meds_rxonly != '') %>%
group_by(ID) %>%
summarise(meds_total = n_distinct(meds_rxonly)) %>% left_join(data_meds, .)
Joining, by = "ID"
Removing/renaming variables that don’t need to be in there:
data$AATpush1_v1
[1] YELLOW YELLOW BLUE YELLOW YELLOW YELLOW BLUE BLUE BLUE BLUE YELLOW YELLOW BLUE YELLOW YELLOW YELLOW BLUE YELLOW BLUE YELLOW YELLOW BLUE BLUE BLUE
[25] BLUE BLUE YELLOW BLUE YELLOW YELLOW YELLOW YELLOW YELLOW YELLOW YELLOW BLUE YELLOW BLUE BLUE BLUE
Levels: BLUE YELLOW
names <- names(data)
cat(sort(names), sep="\n")
age
age_yrs
alcohol
allergies
bdi_1
bdi_10
bdi_10c
bdi_11
bdi_11c
bdi_12
bdi_12c
bdi_13
bdi_13c
bdi_14
bdi_14c
bdi_15
bdi_15c
bdi_16
bdi_16c
bdi_17
bdi_17c
bdi_18
bdi_18c
bdi_19
bdi_19c
bdi_1c
bdi_2
bdi_20
bdi_20c
bdi_21
bdi_21c
bdi_2c
bdi_3
bdi_3c
bdi_4
bdi_4c
bdi_5
bdi_5c
bdi_6
bdi_6c
bdi_7
bdi_7c
bdi_8
bdi_8c
bdi_9
bdi_9c
bgq_1
bgq_2
bgq_3
bgq_4
bgq_5
bisbas_1
bisbas_10
bisbas_10r
bisbas_11
bisbas_11r
bisbas_12
bisbas_12r
bisbas_13
bisbas_13r
bisbas_14
bisbas_14r
bisbas_15
bisbas_15r
bisbas_16
bisbas_16r
bisbas_17
bisbas_17r
bisbas_18
bisbas_18r
bisbas_19
bisbas_19r
bisbas_1r
bisbas_2
bisbas_20
bisbas_20r
bisbas_21
bisbas_21r
bisbas_22
bisbas_23
bisbas_23r
bisbas_24
bisbas_24r
bisbas_3
bisbas_3r
bisbas_4
bisbas_4r
bisbas_5
bisbas_5r
bisbas_6
bisbas_6r
bisbas_7
bisbas_7r
bisbas_8
bisbas_8r
bisbas_9
bisbas_9r
caffeine_perday
caretaker_y
cortisol_BL_A
cortisol_BL_B
cortisol_BL_v1
cortisol_BL_v2
cortisol_PO_A
cortisol_PO_B
cortisol_PO_v1
cortisol_PO_v2
cortisol_PR_A
cortisol_PR_B
cortisol_PR_v1
cortisol_PR_v2
currenttx_y
date_followup
dateofdeath
dob
ecrrs_global_1
ecrrs_global_1c
ecrrs_global_1r
ecrrs_global_2
ecrrs_global_2c
ecrrs_global_2r
ecrrs_global_3
ecrrs_global_3c
ecrrs_global_3r
ecrrs_global_4
ecrrs_global_4c
ecrrs_global_4r
ecrrs_global_5
ecrrs_global_5c
ecrrs_global_6
ecrrs_global_6c
ecrrs_global_7
ecrrs_global_7c
ecrrs_global_8
ecrrs_global_8c
ecrrs_global_9
ecrrs_global_9c
ecrrs_spouse_1
ecrrs_spouse_1c
ecrrs_spouse_1r
ecrrs_spouse_2
ecrrs_spouse_2c
ecrrs_spouse_2r
ecrrs_spouse_3
ecrrs_spouse_3c
ecrrs_spouse_3r
ecrrs_spouse_4
ecrrs_spouse_4c
ecrrs_spouse_4r
ecrrs_spouse_5
ecrrs_spouse_5c
ecrrs_spouse_6
ecrrs_spouse_6c
ecrrs_spouse_7
ecrrs_spouse_7c
ecrrs_spouse_8
ecrrs_spouse_8c
ecrrs_spouse_9
ecrrs_spouse_9c
education
education_other
employment
ethnicity_hisp
exercise
fu_icg_1
fu_icg_10
fu_icg_11
fu_icg_12
fu_icg_13
fu_icg_14
fu_icg_15
fu_icg_16
fu_icg_17
fu_icg_18
fu_icg_19
fu_icg_2
fu_icg_3
fu_icg_4
fu_icg_5
fu_icg_6
fu_icg_7
fu_icg_8
fu_icg_9
gAAT_push_v1
gAAT_push_v2
gAAT_RT_death_pull_A
gAAT_RT_death_pull_B
gAAT_RT_death_push_A
gAAT_RT_death_push_B
gAAT_RT_neutral_pull_A
gAAT_RT_neutral_pull_B
gAAT_RT_neutral_push_A
gAAT_RT_neutral_push_B
gAAT_RT_spouse_pull_A
gAAT_RT_spouse_pull_B
gAAT_RT_spouse_push_A
gAAT_RT_spouse_push_B
gAAT_RT_stranger_pull_A
gAAT_RT_stranger_pull_B
gAAT_RT_stranger_push_A
gAAT_RT_stranger_push_B
gAAT_RT_whoto_pull_A
gAAT_RT_whoto_pull_B
gAAT_RT_whoto_push_A
gAAT_RT_whoto_push_B
gcq_1
gcq_10
gcq_11
gcq_12
gcq_13
gcq_14
gcq_15
gcq_16
gcq_17
gcq_18
gcq_19
gcq_2
gcq_20
gcq_21
gcq_22
gcq_23
gcq_24
gcq_25
gcq_26
gcq_27
gcq_28
gcq_29
gcq_3
gcq_30
gcq_31
gcq_32
gcq_33
gcq_34
gcq_35
gcq_36
gcq_37
gcq_38
gcq_4
gcq_5
gcq_6
gcq_7
gcq_8
gcq_9
group
group_20mFU
hand_1
hand_10
hand_10c
hand_11
hand_11c
hand_12
hand_12c
hand_1c
hand_2
hand_2c
hand_3
hand_3c
hand_4
hand_4c
hand_5
hand_5c
hand_6
hand_6c
hand_7
hand_7c
hand_8
hand_8c
hand_9
hand_9c
hand_bat_1
hand_bat_1c
highestdegree
householdsize
householdsize_adult
householdsize_income
icg_1
icg_10
icg_11
icg_12
icg_13
icg_14
icg_15
icg_16
icg_17
icg_18
icg_19
icg_2
icg_3
icg_4
icg_5
icg_6
icg_7
icg_8
icg_9
ID
knowbefore_y
lastperiod
learnaboutstudy
majorhealthprobs_what
majorhealthprobs_y
meds_dose
meds_dx
meds_hormone_opiate
meds_hrt
meds_psychoactive
meds_rxonly
meds_total
meds_which
meds_y
n_livebirths
n_nursed
n_pregnancies
OXTR2254298
OXTR53576
past2wks_dentist_y
past2wks_injuryinfect_y
post_panas_1_v1
post_panas_1_v2
post_panas_10_v1
post_panas_10_v2
post_panas_11_v1
post_panas_11_v2
post_panas_12_v1
post_panas_12_v2
post_panas_13_v1
post_panas_13_v2
post_panas_14_v1
post_panas_14_v2
post_panas_15_v1
post_panas_15_v2
post_panas_16_v1
post_panas_16_v2
post_panas_17_v1
post_panas_17_v2
post_panas_18_v1
post_panas_18_v2
post_panas_19_v1
post_panas_19_v2
post_panas_2_v1
post_panas_2_v2
post_panas_20_v1
post_panas_20_v2
post_panas_3_v1
post_panas_3_v2
post_panas_4_v1
post_panas_4_v2
post_panas_5_v1
post_panas_5_v2
post_panas_6_v1
post_panas_6_v2
post_panas_7_v1
post_panas_7_v2
post_panas_8_v1
post_panas_8_v2
post_panas_9_v1
post_panas_9_v2
post_sroe_1_A
post_sroe_1_B
post_sroe_1_v1
post_sroe_1_v2
post_sroe_2_A
post_sroe_2_B
post_sroe_2_v1
post_sroe_2_v2
post_sroe_3_A
post_sroe_3_B
post_sroe_3_v1
post_sroe_3_v2
post_stai_1_v1
post_stai_1_v2
post_stai_10_v1
post_stai_10_v2
post_stai_10r_v1
post_stai_10r_v2
post_stai_11_v1
post_stai_11_v2
post_stai_11r_v1
post_stai_11r_v2
post_stai_12_v1
post_stai_12_v2
post_stai_13_v1
post_stai_13_v2
post_stai_14_v1
post_stai_14_v2
post_stai_15_v1
post_stai_15_v2
post_stai_15r_v1
post_stai_15r_v2
post_stai_16_v1
post_stai_16_v2
post_stai_16r_v1
post_stai_16r_v2
post_stai_17_v1
post_stai_17_v2
post_stai_18_v1
post_stai_18_v2
post_stai_19_v1
post_stai_19_v2
post_stai_19r_v1
post_stai_19r_v2
post_stai_1r_v1
post_stai_1r_v2
post_stai_2_v1
post_stai_2_v2
post_stai_20_v1
post_stai_20_v2
post_stai_20r_v1
post_stai_20r_v2
post_stai_2r_v1
post_stai_2r_v2
post_stai_3_v1
post_stai_3_v2
post_stai_4_v1
post_stai_4_v2
post_stai_5_v1
post_stai_5_v2
post_stai_5r_v1
post_stai_5r_v2
post_stai_6_v1
post_stai_6_v2
post_stai_7_v1
post_stai_7_v2
post_stai_8_v1
post_stai_8_v2
post_stai_8r_v1
post_stai_8r_v2
post_stai_9_v1
post_stai_9_v2
postmenopausal_y
ppss_fa_1
ppss_fa_10
ppss_fa_11
ppss_fa_12
ppss_fa_13
ppss_fa_14
ppss_fa_15
ppss_fa_16
ppss_fa_16r
ppss_fa_17
ppss_fa_18
ppss_fa_19
ppss_fa_19r
ppss_fa_2
ppss_fa_20
ppss_fa_20r
ppss_fa_3
ppss_fa_3r
ppss_fa_4
ppss_fa_4r
ppss_fa_5
ppss_fa_6
ppss_fa_7
ppss_fa_8
ppss_fa_9
ppss_fr_1
ppss_fr_10
ppss_fr_11
ppss_fr_12
ppss_fr_13
ppss_fr_14
ppss_fr_15
ppss_fr_15r
ppss_fr_16
ppss_fr_17
ppss_fr_18
ppss_fr_18r
ppss_fr_19
ppss_fr_2
ppss_fr_20
ppss_fr_20r
ppss_fr_2r
ppss_fr_3
ppss_fr_4
ppss_fr_5
ppss_fr_6
ppss_fr_6r
ppss_fr_7
ppss_fr_7r
ppss_fr_8
ppss_fr_9
pre_panas_1_v1
pre_panas_1_v2
pre_panas_10_v1
pre_panas_10_v2
pre_panas_11_v1
pre_panas_11_v2
pre_panas_12_v1
pre_panas_12_v2
pre_panas_13_v1
pre_panas_13_v2
pre_panas_14_v1
pre_panas_14_v2
pre_panas_15_v1
pre_panas_15_v2
pre_panas_16_v1
pre_panas_16_v2
pre_panas_17_v1
pre_panas_17_v2
pre_panas_18_v1
pre_panas_18_v2
pre_panas_19_v1
pre_panas_19_v2
pre_panas_2_v1
pre_panas_2_v2
pre_panas_20_v1
pre_panas_20_v2
pre_panas_3_v1
pre_panas_3_v2
pre_panas_4_v1
pre_panas_4_v2
pre_panas_5_v1
pre_panas_5_v2
pre_panas_6_v1
pre_panas_6_v2
pre_panas_7_v1
pre_panas_7_v2
pre_panas_8_v1
pre_panas_8_v2
pre_panas_9_v1
pre_panas_9_v2
pre_stai_1_v1
pre_stai_1_v2
pre_stai_10_v1
pre_stai_10_v2
pre_stai_10r_v1
pre_stai_10r_v2
pre_stai_11_v1
pre_stai_11_v2
pre_stai_11r_v1
pre_stai_11r_v2
pre_stai_12_v1
pre_stai_12_v2
pre_stai_13_v1
pre_stai_13_v2
pre_stai_14_v1
pre_stai_14_v2
pre_stai_15_v1
pre_stai_15_v2
pre_stai_15r_v1
pre_stai_15r_v2
pre_stai_16_v1
pre_stai_16_v2
pre_stai_16r_v1
pre_stai_16r_v2
pre_stai_17_v1
pre_stai_17_v2
pre_stai_18_v1
pre_stai_18_v2
pre_stai_19_v1
pre_stai_19_v2
pre_stai_19r_v1
pre_stai_19r_v2
pre_stai_1r_v1
pre_stai_1r_v2
pre_stai_2_v1
pre_stai_2_v2
pre_stai_20_v1
pre_stai_20_v2
pre_stai_20r_v1
pre_stai_20r_v2
pre_stai_2r_v1
pre_stai_2r_v2
pre_stai_3_v1
pre_stai_3_v2
pre_stai_4_v1
pre_stai_4_v2
pre_stai_5_v1
pre_stai_5_v2
pre_stai_5r_v1
pre_stai_5r_v2
pre_stai_6_v1
pre_stai_6_v2
pre_stai_7_v1
pre_stai_7_v2
pre_stai_8_v1
pre_stai_8_v2
pre_stai_8r_v1
pre_stai_8r_v2
pre_stai_9_v1
pre_stai_9_v2
pss_1
pss_10
pss_2
pss_3
pss_4
pss_4r
pss_5
pss_5r
pss_6
pss_7
pss_7r
pss_8
pss_8r
pss_9
race
race_other
rs2254298
rs2254298_A.carrier
rs2268498
rs2268498_C.carrier
rs53576
rs53576_A.carrier
sex_m
smoking_howlong
smoking_perday
smoking_y
srrs_1
srrs_10
srrs_11
srrs_12
srrs_13
srrs_14
srrs_15
srrs_16
srrs_17
srrs_18
srrs_19
srrs_2
srrs_20
srrs_21
srrs_22
srrs_23
srrs_24
srrs_25
srrs_26
srrs_27
srrs_28
srrs_29
srrs_3
srrs_30
srrs_31
srrs_32
srrs_33
srrs_34
srrs_35
srrs_36
srrs_37
srrs_38
srrs_39
srrs_4
srrs_40
srrs_41
srrs_42
srrs_43
srrs_44
srrs_45
srrs_46
srrs_47
srrs_48
srrs_49
srrs_5
srrs_50
srrs_51
srrs_6
srrs_7
srrs_8
srrs_9
startdate
surgeries_past6mos
timesincedeath
timeto20mFU
timeto20mFU_mos
timetorest_A
timetorest_B
tot_bdi
tot_bgq
tot_bisbas_basdr
tot_bisbas_basfun
tot_bisbas_basrr
tot_bisbas_bis
tot_ecrrs_global_anx
tot_ecrrs_global_avoid
tot_ecrrs_spouse_anx
tot_ecrrs_spouse_avoid
tot_gcq_approp
tot_gcq_blame
tot_gcq_cherish
tot_gcq_future
tot_gcq_life
tot_gcq_others
tot_gcq_self
tot_gcq_threat
tot_gcq_world
tot_handedness
tot_icg
tot_icg_20mFU
tot_post_panas_na_A
tot_post_panas_na_B
tot_post_panas_na_v1
tot_post_panas_na_v2
tot_post_panas_pa_A
tot_post_panas_pa_B
tot_post_panas_pa_v1
tot_post_panas_pa_v2
tot_post_stai_A
tot_post_stai_B
tot_post_stai_v1
tot_post_stai_v2
tot_ppss_fa
tot_ppss_fr
tot_pre_panas_na_A
tot_pre_panas_na_B
tot_pre_panas_na_v1
tot_pre_panas_na_v2
tot_pre_panas_pa_A
tot_pre_panas_pa_B
tot_pre_panas_pa_v1
tot_pre_panas_pa_v2
tot_pre_stai_A
tot_pre_stai_B
tot_pre_stai_v1
tot_pre_stai_v2
tot_pss
tot_srrs
tot_srrs_n
tot_ucla_loneliness
tot_ysl
tx_v1
tx_v2
ucla_loneliness_1
ucla_loneliness_10
ucla_loneliness_10r
ucla_loneliness_11
ucla_loneliness_12
ucla_loneliness_13
ucla_loneliness_14
ucla_loneliness_15
ucla_loneliness_15r
ucla_loneliness_16
ucla_loneliness_16r
ucla_loneliness_17
ucla_loneliness_18
ucla_loneliness_19
ucla_loneliness_19r
ucla_loneliness_1r
ucla_loneliness_2
ucla_loneliness_20
ucla_loneliness_20r
ucla_loneliness_3
ucla_loneliness_4
ucla_loneliness_5
ucla_loneliness_5r
ucla_loneliness_6
ucla_loneliness_6r
ucla_loneliness_7
ucla_loneliness_8
ucla_loneliness_9
ucla_loneliness_9r
yrs_together
ysl_1
ysl_10
ysl_11
ysl_12
ysl_13
ysl_14
ysl_15
ysl_16
ysl_17
ysl_18
ysl_19
ysl_2
ysl_20
ysl_21
ysl_3
ysl_4
ysl_5
ysl_6
ysl_7
ysl_8
ysl_9