-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemotional_processes.Rmd
346 lines (269 loc) · 13.4 KB
/
emotional_processes.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
---
title: "Analyses of the Anger Experiencers' Emotional Processes"
author: "Pooya Razavi"
date: "last knitted: `r Sys.time()`"
output:
html_document:
theme: cosmo
highlight: textmate
toc: TRUE
toc_float: TRUE
editor_options:
chunk_output_type: console
---
This script represents the test of the hypotheses and research questions about the emotional processes of the participants during their anger experience, and how the different aspects of these processes vary between justified and unjustified anger prototypes.
```{r setup, include=FALSE, warning=FALSE}
#load libraries
package_list <- c("dplyr", "tidyr", "ggplot2", "MetBrewer")
lapply(package_list, require, character.only = TRUE)
#read in the data
df <- readxl::read_xlsx("C:/Users/pooya/Dropbox (University of Oregon)/Anger Dissertation/Prototype study analysis/ProcessedData_F21_W22_S22_F22.xlsx")
#Function to report correlation
cor_report <- function(cor_output) {
r <- cor_output[["estimate"]] %>% round(2)
df <- cor_output[["parameter"]] %>% round(1)
ci_lb <- (cor_output[["conf.int"]])[1] %>% round(2)
ci_ub <- (cor_output[["conf.int"]])[2] %>% round(2)
original_p <- cor_output[["p.value"]] %>% round(3)
p <- if_else(original_p >= .001, paste0("= ", as.character(original_p)), "< .001")
print(paste0("r(", df, ") = ", r, " [", ci_lb, ", ", ci_ub, "], p ", p))
}
#Function to report independent-samples t-test
ind_ttest_report <- function(iv, dv) {
ttest <- t.test(dv ~ iv)
effect_size <- effectsize::cohens_d(dv ~ iv, pooled_sd = FALSE)
t <- ttest[["statistic"]] %>% round(2)
df <- ttest[["parameter"]] %>% round(1)
original_p <- ttest[["p.value"]] %>% round(3)
p <- if_else(original_p >= .001, paste0("= ", as.character(original_p)), "< .001")
d <- effect_size[1,1] %>% round(2)
print(paste0("t(", df, ") = ", t, ", p ", p, ", d = ", d))
}
#Function to report paired-samples t-test
paired_ttest_report <- function(t1, t2) {
ttest <- t.test(Pair(t1, t2) ~ 1)
effect_size <- effectsize::cohens_d(Pair(t1, t2) ~ 1, pooled_sd = FALSE)
t <- ttest[["statistic"]] %>% round(2)
df <- ttest[["parameter"]] %>% round(1)
original_p <- ttest[["p.value"]] %>% round(3)
p <- if_else(original_p >= .001, paste0("= ", as.character(original_p)), "< .001")
d <- effect_size[1,1] %>% round(2)
print(paste0("t(", df, ") = ", t, ", p ", p, ", d = ", d))
}
#Function to calculate percentages for each category of a Factor variable
percentage <- function(var, includeNA = TRUE) {
tabb <- table(var) %>% as.data.frame()
if (includeNA == TRUE) {
tabb$percentage <- (tabb$Freq * 100 / length(var))
} else {
tabb$percentage <- (tabb$Freq * 100 / sum(tabb$Freq))
}
colnames(tabb)[1] <- c("category")
print(tabb)
}
knitr::opts_chunk$set(echo = TRUE)
```
```{r, data-exclusion}
#assigning values to factor levels
df$NarrativeWritten <- as.factor(df$NarrativeWritten)
df$NarrativeRelevant <- as.factor(df$NarrativeRelevant)
df$Condition <- as.factor(df$Condition)
levels(df$NarrativeWritten) <- c("No", "Yes")
levels(df$NarrativeRelevant) <- c("No", "Yes", NA, NA)
levels(df$Condition) <- c("justified", "nonjustified", NA)
#drop cases following preregistration
df1 <- df %>%
filter(NarrativeWritten != "No") %>%
filter(NarrativeRelevant != "No") %>%
filter(!is.na(Condition))
```
# Affective Experience
**Research Question:** What are the differences between justified vs. unjustified anger in terms of the intensity of affective experiences? <br>
## Dimensionality Analyses
To compare the broader affective experiences of participants across the justified and unjustified anger events, participants were asked to rate their emotional experience during the anger eliciting event using 27 positive and negative emotions. First, following the preregistration, the structure of the affective experiences will be determined using dimensionality reduction analysis (i.e., PCA).
```{r, affec-pca}
df_affect <- df1 %>%
select(ResponseId, Condition, starts_with("em_"))
#scree plot
df_affect %>%
select(starts_with("em_")) %>%
psych::scree(hline = -1) #suggests 4 components
#parallel analysis
df_affect %>%
select(starts_with("em_")) %>%
psych::fa.parallel() #suggests 4 components
#Velicor's MAP
df_affect %>%
select(starts_with("em_")) %>%
psych::nfactors(n = 27) #Velicor's MAP suggests 4 factors
#PCA with 4 components
pca_4_component <- df_affect %>%
select(starts_with("em_")) %>%
psych::principal(., nfactors = 4, rotate = "varimax")
four_comp_outcome <- psych::kaiser(pca_4_component, rotate = "Varimax") %>% psych::fa.sort()
four_comp_outcome[["loadings"]] %>%
knitr::kable(digits = 2) %>%
kableExtra::kable_styling(bootstrap_options = c("striped", "hover")) %>%
kableExtra::kable_paper(full_width = F)
#"Strong" has the strongest cross-loading. It will be dropped before the next iteration.
pca_4_component_i2 <- df_affect %>%
select(starts_with("em_"), -em_strong) %>%
psych::principal(., nfactors = 4, rotate = "varimax")
four_comp_outcome_i2 <- psych::kaiser(pca_4_component_i2, rotate = "Varimax") %>% psych::fa.sort()
four_comp_outcome_i2[["loadings"]] %>%
knitr::kable(digits = 2) %>%
kableExtra::kable_styling(bootstrap_options = c("striped", "hover")) %>%
kableExtra::kable_paper(full_width = F)
#"Surprised" does not have a high loading (i.e., > .40) on any of the components. It will be dropped before the next iteration.
pca_4_component_i3 <- df_affect %>%
select(starts_with("em_"), -em_strong, -em_surprised) %>%
psych::principal(., nfactors = 4, rotate = "varimax")
four_comp_outcome_i3 <- psych::kaiser(pca_4_component_i3, rotate = "Varimax") %>% psych::fa.sort()
four_comp_outcome_i3[["loadings"]] %>%
as.data.frame() %>%
tibble::rownames_to_column("item") %>%
mutate(Item = gsub("^.{0,3}", "", item)) %>%
mutate(Item = stringr::str_replace_all(Item, "_", " ")) %>%
select(Item, starts_with("RC")) %>%
knitr::kable(digits = 2) %>%
kableExtra::kable_styling(bootstrap_options = c("striped", "hover")) %>%
kableExtra::kable_paper(full_width = F)
#to save the output in a .csv (for the manuscript table)
#four_comp_outcome_i3[["loadings"]] %>%
# as.data.frame() %>%
# tibble::rownames_to_column("item") %>%
# mutate(Item = gsub("^.{0,3}", "", item)) %>%
# select(Item, starts_with("RC")) %>% write.csv("affective_experience_pca.csv")
```
Create scree plot, parallel analyses, and Velicor's MAP figures for the manuscript:
```{r}
#figure for the manuscript
df_affect %>%
select(starts_with("em_")) %>%
psych::scree(factors = FALSE, hline = -1)
df_affect %>%
select(starts_with("em_")) %>%
psych::fa.parallel(fa = "pc")
velicor_map <- df_affect %>%
select(starts_with("em_")) %>%
psych::nfactors(n = 27)
plot(velicor_map[["map"]],
main = "Velicor's MAP",
xlab = "Number of Factos",
ylab = "MAP Index",
xlim=c(0,20), ylim=c(0,0.10),
type = "b")
abline(h=0.011, col="blue")
```
Based on the PCA results, scale scores will be created.
```{r, affect-scoring}
#Hypothetical scenario: code for calculating scale scores for 2 components
keys.list <- list(self_blame = c("em_disgusted_w_self","em_ashamed","em_guilty","em_angry_at_self", "em_embarrassed"),
hostility = c("em_hostile","em_loathing_hateful","em_frustrated","em_irritable", "em_upset", "em_disgusted", "em_alert", "em_daring"),
forlorn = c("em_depressed", "em_sad", "em_lonely", "em_anxious", "em_afraid", "em_shy"),
joy = c("em_excited", "em_happy", "em_enthusiastic", "em_proud", "em_relaxed", "em_lively"))
affect_scores <- psych::scoreItems(keys.list, df_affect)
affect_scores
df_affect <- cbind(df_affect, affect_scores$scores)
#The 3 lines below will save the APA-style correlation table in a word document:
#df_affect %>%
# select(self_blame, hostility, forlorn, joy) %>%
# apaTables::apa.cor.table(.,filename = "affect_cor.doc", table.number = 1, show.conf.interval = T)
```
## Comparison of Anger Variants
```{r, affective-comparison}
#descriptives
df_affect %>%
group_by(Condition) %>%
select(self_blame, hostility, forlorn, joy) %>%
summarise_all(list(mean, sd))
#Compare conditions for each of the 4 components
#self-blame
df_affect %>%
t.test(self_blame ~ Condition, data = .)
df_affect %>%
effectsize::cohens_d(self_blame ~ Condition, data = .)
#for reporting
ind_ttest_report(df_affect$Condition, df_affect$self_blame)
#hostility
df_affect %>%
t.test(hostility ~ Condition, data = .)
df_affect %>%
effectsize::cohens_d(hostility ~ Condition, data = .)
#for reporting
ind_ttest_report(df_affect$Condition, df_affect$hostility)
#forlorn
df_affect %>%
t.test(forlorn ~ Condition, data = .)
df_affect %>%
effectsize::cohens_d(forlorn ~ Condition, data = .)
#for reporting
ind_ttest_report(df_affect$Condition, df_affect$forlorn)
#joy
df_affect %>%
t.test(joy ~ Condition, data = .)
df_affect %>%
effectsize::cohens_d(joy ~ Condition, data = .)
#for reporting
ind_ttest_report(df_affect$Condition, df_affect$joy)
```
# Expressivity
**Hypothesis 1:** Participants are more likely to evaluate their own anger expression as “exaggerated” in the unjustified (vs. justified) anger condition.
```{r, exag-express}
df1$behav_reac <- as.factor(df1$behav_reac)
levels(df1$behav_reac) <- c("fully_concealed", "partly_concealed", "fully_expressed", "exaggerated")
percentage(df1$behav_reac)
#Compare the reactions based on Condition
#cross-tabs
expressivity_table1 <- xtabs( ~ Condition + behav_reac,
data=df1)
prop.table(expressivity_table1, 1) %>%
round(2)
#overall chi-square
chisq.test(df1$Condition,
df1$behav_reac)
#Since the overall chi-square is significant, follow-up analyses will be conducted. Of these four analyses, the first one corresponds to the hypothesis (stated above), and the rest are exploratory:
df_exaggerated <- df1 %>%
mutate(exaggerated = if_else(behav_reac == "exaggerated", "Yes", "No")) %>%
select(Condition, exaggerated)
chisq.test(df_exaggerated$Condition,
df_exaggerated$exaggerated)
df_fully_expressed <- df1 %>%
mutate(fully_expressed = if_else(behav_reac == "fully_expressed", "Yes", "No")) %>%
select(Condition, fully_expressed)
chisq.test(df_fully_expressed$Condition,
df_fully_expressed$fully_expressed)
df_partly_concealed <- df1 %>%
mutate(partly_concealed = if_else(behav_reac == "partly_concealed", "Yes", "No")) %>%
select(Condition, partly_concealed)
chisq.test(df_partly_concealed$Condition,
df_partly_concealed$partly_concealed)
df_fully_concealed <- df1 %>%
mutate(fully_concealed = if_else(behav_reac == "fully_concealed", "Yes", "No")) %>%
select(Condition, fully_concealed)
chisq.test(df_fully_concealed$Condition,
df_fully_concealed$fully_concealed)
```
**Hypothesis 2:** The strength of the experience-expression relation tamps down as the anger intensity increases, and this deceleration is stronger for justified anger.
```{r, feel-exp-relation}
df_feel_exp <- df1 %>%
select(ResponseId, Condition, anger_feel, anger_express) %>%
mutate(anger_feel_c = as.double(scale(anger_feel, scale = FALSE)),
anger_feel_c_sq = anger_feel_c^2)
#A linear model testing the feel-express relation
mod1_linear <- lm(anger_express ~ anger_feel_c,
data = df_feel_exp)
summary(mod1_linear)
confint(mod1_linear)
#A curvilinear model testing the feel-express relation: This is the test of the first part of the hypothesis.
mod1_nonlinear <- lm(anger_express ~ anger_feel_c + anger_feel_c_sq,
data = df_feel_exp)
summary(mod1_nonlinear)
confint(mod1_nonlinear)
anova(mod1_linear, mod1_nonlinear)
#If the curvilinear relation is significant, the moderating role of Condition for this curvilinear relation will be tested, which will correspond to the second part of the hypothesis.
mod2_nonlinear <- lm(anger_express ~ anger_feel_c * Condition + anger_feel_c_sq * Condition,
data = df_feel_exp)
summary(mod2_nonlinear)
confint(mod2_nonlinear)
```