Load in relevant libraries and the dataset
First, explore the data.
#summarize the data
summary_data <- recall_data %>%
select(feelings_youalone, feelings_bothyoufirst) %>%
drop_na() %>%
summary()
summary_data
## feelings_youalone feelings_bothyoufirst
## Min. :-30.00 Min. :-30.000
## 1st Qu.:-30.00 1st Qu.: 0.000
## Median :-20.00 Median : 10.000
## Mean :-18.63 Mean : 7.449
## 3rd Qu.:-10.00 3rd Qu.: 20.000
## Max. : 10.00 Max. : 30.000
#tidy the data
recall_tidy <- recall_data %>%
select(feelings_youalone, feelings_bothyoufirst, initiator_type) %>%
drop_na() %>%
pivot_longer(cols = c(feelings_youalone, feelings_bothyoufirst),
names_to = "treatment", values_to = "feelings") %>%
mutate(treatment = as.factor(treatment),
initiator_type = as.factor(initiator_type))
The results of the t-test analysis provided evidence supporting the notion that individuals do indeed care about receiving a return apology after initiating an apology themselves. The t-test (t = 9.89, df = 92.16, p-value = 3.75e-16) revealed a statistically significant difference in feelings between individuals who received a return apology and those who did not. This meaningful effect was also supported by a substantial difference in mean feelings and a narrow 95% confidence interval (20.85 to 31.32). The accompanying box plot (Figure 1) illustrates this difference, with the group receiving a return apology (feelings_bothyoufirst) showing higher median and interquartile range values, indicating a positive emotional impact associated with receiving a return apology.
Figure 1 Difference in Feelings Depending on Treatment
#conduct the t-test
t_test_result <- t.test(feelings ~ treatment, data = recall_tidy)
t_test_result
##
## Welch Two Sample t-test
##
## data: feelings by treatment
## t = 9.8942, df = 92.159, p-value = 3.747e-16
## alternative hypothesis: true difference in means between group feelings_bothyoufirst and group feelings_youalone is not equal to 0
## 95 percent confidence interval:
## 20.84633 31.31694
## sample estimates:
## mean in group feelings_bothyoufirst mean in group feelings_youalone
## 7.44898 -18.63265
#visualize the data
recall_plot <- ggplot(recall_tidy, aes(x = treatment, y = feelings)) +
geom_boxplot() +
labs(x = "Treatment", y = "Feelings") +
ggtitle("Difference in Feelings Depending on Treatment")
recall_plot
RQ #2: Does this vary as a function of individual differences in
“initiator type”?
Further analysis using linear regression with an interaction term explored the relationship between treatment, initiator type, and feelings. The interaction term was statistically significant (F-statistic: 24.84, p-value: 9.25e-16), indicating that the emotional impact of receiving a return apology indeed varies based on individual differences in initiator type. The coefficients in the regression output provide insights into how different initiator types influence the emotional response to receiving or not receiving a return apology. For instance, individuals with the initiator type “conditional” experienced a significant negative impact on feelings, suggesting that for this group, receiving a return apology had a lesser emotional benefit compared to other initiator types. The accompanying regression plot (Figure 2) illustrates the interaction effect. The different regression lines for each initiator type exhibit varying slopes, indicating that the emotional impact of a return apology varies based on initiator type.
Figure 2 Difference in Feelings Depending on Treatment & Initiator Type
#linear regression with interaction
feelings_treatment_interaction_fit <- lm(feelings ~ treatment * initiator_type, data = recall_tidy)
summary(feelings_treatment_interaction_fit)
##
## Call:
## lm(formula = feelings ~ treatment * initiator_type, data = recall_tidy)
##
## Residuals:
## Min 1Q Median 3Q Max
## -33.529 -6.235 -0.159 7.697 33.765
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 13.0909 2.6343
## treatmentfeelings_youalone -26.8636 3.7254
## initiator_typeconditional -9.5615 3.9900
## initiator_typenever -11.3909 4.7124
## treatmentfeelings_youalone:initiator_typeconditional -0.4305 5.6427
## treatmentfeelings_youalone:initiator_typenever 4.5636 6.6643
## t value Pr(>|t|)
## (Intercept) 4.969 3.09e-06 ***
## treatmentfeelings_youalone -7.211 1.52e-10 ***
## initiator_typeconditional -2.396 0.0186 *
## initiator_typenever -2.417 0.0176 *
## treatmentfeelings_youalone:initiator_typeconditional -0.076 0.9394
## treatmentfeelings_youalone:initiator_typenever 0.685 0.4952
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 12.36 on 92 degrees of freedom
## Multiple R-squared: 0.5745, Adjusted R-squared: 0.5514
## F-statistic: 24.84 on 5 and 92 DF, p-value: 9.253e-16
# Visualize the data with regression lines
recall_plot_regression <- ggplot(recall_tidy, aes(x = treatment, y = feelings, color = initiator_type)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, aes(group = initiator_type)) +
labs(x = "Treatment", y = "Feelings", color = "Initiator Type") +
ggtitle("Linear Regression: Feelings on Treatment and Initiator Type")
recall_plot_regression
## `geom_smooth()` using formula = 'y ~ x'
#unsure how to do this with the given data - something to do with the feelings_youaloneforgiven variable?
#would it be helpful to see more of the documentation for the data?
The positive impact of receiving a return apology may be rooted in feelings of acknowledgment, validation, and closure. The varying effects observed for different initiator types could be explained by differences in individuals’ expectations, communication styles, and emotional needs. Factors such as the nature of the relationship, cultural nuances in interpreting apologies, and individual personality traits could significantly influence the emotional impact of return apologies. Additionally, the severity of the transgression, sincerity of the apology, and contextual factors may influence the observed effects. While exploring the interaction between treatment and initiator type, the analysis illuminated insights into how different initiator types influence the emotional response. Further analysis could explore qualitative coding of participants’ responses to the “describe” variable and compare the influences of the specifics of the conflict on the observed effects. In summary, the findings not only affirm the importance of return apologies in influencing emotions but also highlight the significance of considering individual differences in understanding the complex dynamics of interpersonal conflict.
Use the data to complete the tasks below. You may include these in the same RMD & HTML files created for Task 1. Produce a single bar graph that shows the average of the “feelings” variable for all six scenarios, in order of decreasing value. Include error bars (standard errors or confidence intervals). Label fully.
#tidy the data
recall_tidy <- recall_data %>%
select(feelings_boththemfirst, feelings_youalone, feelings_bothyoufirst, feelings_neither, feelings_youaloneforgiven, feelings_themalone) %>%
drop_na() %>%
mutate(across(starts_with("feelings"), as.numeric)) %>%
pivot_longer(cols = starts_with("feelings"),
names_to = "treatment", values_to = "feelings") %>%
mutate(treatment = as.factor(treatment))
#calculate the mean and standard error for each scenario
mean_by_scenario <- recall_tidy %>%
group_by(treatment) %>%
summarise(mean_feelings = mean(feelings),
se_feelings = sd(feelings) / sqrt(n()))
#order the scenarios by decreasing mean_feelings
order_by_mean <- mean_by_scenario %>%
arrange(desc(mean_feelings))
#create a bar graph with grouped bars and error bars
feelings_bar_graph <- ggplot(order_by_mean, aes(x = reorder(treatment, -mean_feelings),
y = mean_feelings)) +
geom_bar(stat = "identity", position = position_dodge(width = 0.8), width = 0.7) +
geom_errorbar(aes(ymin = mean_feelings - se_feelings,
ymax = mean_feelings + se_feelings),
position = position_dodge(width = 0.8),
width = 0.2) +
labs(x = "Scenario", y = "Average Feelings") +
ggtitle("Average Feelings for Each Scenario") +
theme_minimal()
feelings_bar_graph
Participants only reported positive feelings in scenarios in which both
individuals apologized. Additionally, participants felt significantly
worse in one-sided apology scenarios when the participant was the only
one to apologize.
Conduct a one way ANOVA to determine if there are differences in feelings across the six scenarios. Then perform pairwise t-tests to compare “feelings_youalone” to the other five scenarios.
#conduct a one-way ANOVA
feelings_aov <- aov(feelings ~ 1 + factor(treatment), data = recall_tidy)
coef(feelings_aov)
## (Intercept)
## 17.367347
## factor(treatment)feelings_bothyoufirst
## -9.918367
## factor(treatment)feelings_neither
## -31.653061
## factor(treatment)feelings_themalone
## -22.836735
## factor(treatment)feelings_youalone
## -36.000000
## factor(treatment)feelings_youaloneforgiven
## -30.836735
summary(feelings_aov)
## Df Sum Sq Mean Sq F value Pr(>F)
## factor(treatment) 5 48894 9779 53.71 <2e-16 ***
## Residuals 288 52439 182
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#conduct pairwise t-tests to compare "feelings_youalone" to the other five scenarios - wasn't able to do this
#conduct TukeyHSD instead
TukeyHSD(feelings_aov)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = feelings ~ 1 + factor(treatment), data = recall_tidy)
##
## $`factor(treatment)`
## diff lwr
## feelings_bothyoufirst-feelings_boththemfirst -9.9183673 -17.7397108
## feelings_neither-feelings_boththemfirst -31.6530612 -39.4744046
## feelings_themalone-feelings_boththemfirst -22.8367347 -30.6580781
## feelings_youalone-feelings_boththemfirst -36.0000000 -43.8213434
## feelings_youaloneforgiven-feelings_boththemfirst -30.8367347 -38.6580781
## feelings_neither-feelings_bothyoufirst -21.7346939 -29.5560373
## feelings_themalone-feelings_bothyoufirst -12.9183673 -20.7397108
## feelings_youalone-feelings_bothyoufirst -26.0816327 -33.9029761
## feelings_youaloneforgiven-feelings_bothyoufirst -20.9183673 -28.7397108
## feelings_themalone-feelings_neither 8.8163265 0.9949831
## feelings_youalone-feelings_neither -4.3469388 -12.1682822
## feelings_youaloneforgiven-feelings_neither 0.8163265 -7.0050169
## feelings_youalone-feelings_themalone -13.1632653 -20.9846087
## feelings_youaloneforgiven-feelings_themalone -8.0000000 -15.8213434
## feelings_youaloneforgiven-feelings_youalone 5.1632653 -2.6580781
## upr p adj
## feelings_bothyoufirst-feelings_boththemfirst -2.0970239 0.0043573
## feelings_neither-feelings_boththemfirst -23.8317178 0.0000000
## feelings_themalone-feelings_boththemfirst -15.0153913 0.0000000
## feelings_youalone-feelings_boththemfirst -28.1786566 0.0000000
## feelings_youaloneforgiven-feelings_boththemfirst -23.0153913 0.0000000
## feelings_neither-feelings_bothyoufirst -13.9133505 0.0000000
## feelings_themalone-feelings_bothyoufirst -5.0970239 0.0000495
## feelings_youalone-feelings_bothyoufirst -18.2602892 0.0000000
## feelings_youaloneforgiven-feelings_bothyoufirst -13.0970239 0.0000000
## feelings_themalone-feelings_neither 16.6376699 0.0169839
## feelings_youalone-feelings_neither 3.4744046 0.6028397
## feelings_youaloneforgiven-feelings_neither 8.6376699 0.9996753
## feelings_youalone-feelings_themalone -5.3419219 0.0000328
## feelings_youaloneforgiven-feelings_themalone -0.1786566 0.0416400
## feelings_youaloneforgiven-feelings_youalone 12.9846087 0.4079386
The one-way ANOVA indicates a significant overall difference in feelings across the six scenarios. The post-hoc Tukey tests reveal pairwise differences in feelings between scenarios, with “feelings_youalone” consistently showing significant differences compared to other scenarios.
Create a graph showing the proportion of people choosing each of the different options for the following variable: outcome_binary1
#examine the variable
table(recall_data$outcome_binary1)
##
## I apologize first, then ${e://Field/initials} apologizes.
## 39
## Neither I nor ${e://Field/initials} apologizes.
## 10
#create a bar graph showing the proportion of people choosing each option
outcome_binary1_bargraph <- ggplot(recall_data, aes(x = factor(1), fill = factor(outcome_binary1))) +
geom_bar(aes(y = (after_stat(count)/sum(after_stat(count))))) +
scale_y_continuous(labels = scales::percent_format(scale = 1)) +
labs(x = "", y = "Proportion", title = "Proportion of People Choosing Each Option for outcome_binary1") +
theme_minimal()
outcome_binary1_bargraph
Conduct a test to determine if the proportion differences across the
answers are significantly different from one another.
#create a contingency table
contingency_table <- table(recall_data$outcome_binary1)
#conduct a chi-square test
chi_square_test <- chisq.test(contingency_table)
chi_square_test
##
## Chi-squared test for given probabilities
##
## data: contingency_table
## X-squared = 17.163, df = 1, p-value = 3.43e-05
OPTIONAL – This NLP exercise is optional, and primarily relevant to Professors Chaudhry and Kirgios. Natural Language Processing (NLP) exercise: Find a way to analyze the sentiment and/or emotions present in the free form text responses in the “describe” variable. For instance, you may use packages like VADER, TextAnalyzer, or LIWC (or others). You might even use ChatGPT (in your code; not manually). Describe your observations in a few sentences.