This document contains the code for analyses conducted in a manuscript in preparation.
Repetitive negative thinking (RNT) reflects a transdiagnostic process underlying disorder-specific vulnerability factors such as worry, rumination, and post-event processing. Though RNT predicts various forms of psychopathology, the underlying mechanisms, such as decision-making styles, remain understudied. Moreover, the influence of RNT on acute stress reactivity has not been tested using experimental stress manipulations.
In the current study, we tested the influence of RNT on negative affect, cortisol, and decision-making in response to acute social stress, which was induced using the Trier Social Stress Test. We recruited a sample of 90 young adults, over-sampling for high-RNT individuals to increase variability in this construct of interest. RNT was measured using the Perseverative Thinking Questionnaire (PTQ). At a second visit, participants (n = 64) completed 3 blocks of a neuroeconomic gambling task under neutral and affective conditions; each trial presented a choice between a certain outcome or a gamble for potential losses or gains. After a baseline non-stress block, participants were informed they would give a speech at the conclusion of the second block (i.e., stress anticipation condition). After completing the 5-minute Trier Social Stress Test, participants performed a third task block (i.e., stress recovery condition). Mood was measured throughout to determine the efficacy of the stress manipulation.
Packages Used: stargazer, sjPlot, sjmisc, ggplot2, lmerTest, lme4, reshape2, tidyr, doBy, psych, dplyr, nlme, summarytools, plyr, knitr, pander, DT, shiny **Data:** 3 data files (cortisol data from external lab; Matlab data from experimental gambling task; self-reported mood) were combined using dplyr and tidyr; the resultant data file is used for simplicity throughout this document.
datatable(df, extensions = c('FixedColumns','FixedHeader'), options = list(pageLength=10,lengthMenu = c(5, 10, 15, 20, 50, 100), dom = 'Blfrtip', scrollX = TRUE, scrollY=TRUE, fixedHeader=TRUE, fixedColumns = list(leftColumns = 2),
initComplete = JS("
function(settings, json) {
$(this.api().table().header()).css({
'background-color': '#000',
'color': '#fff'
});
}")
))
old_cols <- df[c(12:20)]
col.names <- colnames(df[c(12:20)])
df[34:42] <- NA
df[34:42] <- old_cols
cols <- df[c(34:42)]
colnames(df)[34:42] <- paste("log", colnames(old_cols), sep = "_")
df[34:42] <- log(df[34:42] + 1)
For the cortisol data, we’ll select each individual’s lowest baseline value, highest stress peak value, and lowest recovery value. This will help us to account for individual differences in cortisol response latency after the stress period.
#Baseline: select lower value between cort0 and cort1, the 2 baseline measures
df$cortBL <- ifelse(df$Cort0 < df$Cort1, df$Cort0, df$Cort1)
#Stress: select higher value between cort2 and cort3, the 2 stress measures
df$cortStress <- ifelse(df$Cort2 > df$Cort3, df$Cort2, df$Cort3)
#Recovery: select lower value between cort4 and cort5, the 2 recovery measures
df$cortRec <- ifelse(df$Cort4 < df$Cort5, df$Cort4, df$Cort5)
Now we’ll plot individual trajectories in cortisol response using multilevel modeling.
cortdata2 <- df[c("ID","cortBL","cortStress","cortRec")]
colnames(cortdata2)[c(2:4)] <- c("cortisol0", "cortisol1", "cortisol2")
cort.long <- reshape(as.data.frame(cortdata2), varying = c("cortisol0","cortisol1","cortisol2"), idvar = "ID", direction="long", sep = "")
p <- ggplot(data = cort.long, aes(x = time, y = cortisol, group = ID))
p + geom_line()
It would also be helpful to see average cortisol values across the session, so we’ll plot that next. First, we neeed to find the standard errors for these values to use in plots. This function will be used to compute SEs (and 95% CIs).
summarySE <- function(data=NULL, measurevar, groupvars=NULL, na.rm=FALSE, conf.interval=.95, .drop=TRUE) {
library(plyr)
length2 <- function (x, na.rm=FALSE) {
if (na.rm) sum(!is.na(x))
else length(x)
}
datac <- ddply(data, groupvars, .drop=.drop, .fun = function(xx, col) {
c(N=length2(xx[[col]], na.rm=na.rm),
mean=mean(xx[[col]], na.rm=na.rm),
sd=sd(xx[[col]], na.rm=na.rm))
}, measurevar)
datac <- rename(datac, c("mean" = measurevar))
datac$se <- datac$sd / sqrt(datac$N)
ciMult <- qt(conf.interval/2 + .5, datac$N-1)
datac$ci <- datac$se * ciMult
return(datac)
}
Now we can create a vector of average values, another vector of average SEs, and combine them into a data frame. Then we’ll add a column indicating the time point (0 = baseline, 1 = stress, 2 = recovery). We will use this smaller dataframe to plot the average cortisol values (and SEs) across the session.
cortvalues <- NA
cortvalues[1] <- mean(df$cortBL, na.rm=T)
cortvalues[2] <- mean(df$cortStress, na.rm=T)
cortvalues[3] <- mean(df$cortRec, na.rm=T)
sevalues <- NA
a <- summarySE(df, measurevar="cortBL", na.rm=T)
sevalues[1] <- a$se
a2 <- summarySE(df, measurevar="cortStress", na.rm=T)
sevalues[2] <- a2$se
a3 <- summarySE(df, measurevar="cortRec", na.rm=T)
sevalues[3] <- a3$se
Cortvalues <- NA
Cortvalues <- cbind(as.data.frame(cortvalues),as.data.frame(sevalues))
Cortvalues$Time <- c(0,1,2)
We’ll use ggplot to create the plot.
p<- ggplot(Cortvalues, aes(x=Time, y=cortvalues)) +
geom_line() +
geom_point()+
geom_errorbar(aes(ymin=cortvalues-sevalues, ymax=cortvalues+sevalues), width=.2,
position=position_dodge(0.05))
Below is the plot of cortisol over the course of the session.
# Finished line plot
p+labs(title="Average cortisol across course of experimental stress manipulation", x="Time Point", y = "Average Cortisol (nmol/L)")+ theme_classic() + scale_x_continuous(breaks=c(0,1,2), labels=c("Baseline","Stress","Recovery")) + theme(plot.title = element_text(hjust = 0.5))
The plot clearly indicates an average increase in cortisol during the stress induction, and a decrease in cortisol as individuals recovered from the stressor.
The same process and code will be used to clean and visualize the data measuring individual differences in negative affect over the course of the laboratory session. Below are the plots produced:
## Warning: Removed 80 rows containing missing values (geom_path).
A similar process was used to plot the three gambling task parameters.
Resulting plots from ggplot were edited to publication quality using Adobe Illustrator. Plots are below: