The code chunk below (click the button to expand it, or select the option in the upper right </> Code to expand all code chunks) reads data from an Excel file into a DataFrame df. It then filters out participants who failed attention checks and retains only those who could recall a real conflict situation. Additionally, it removes a participant who left a comment indicating non-serious participation (“don’t use these data; was just clicking through”) and reported an unrealistic age (149). The code chunk also renames the original variables to more meaningful names for clarity and ease of analysis. Finally, the DataFrame is transformed into a long format for further analysis. The resulting sample size is 42.
Unfold Code Chunk
library(tidyverse)df<-readxl::read_excel("Data - Fall 2023.xlsx", sheet ="Data")|>filter(passedattn=="yes")|>filter(real_imaginary=="I have thought of a real argument/conflict from my life where this is true")|>filter(age!=149)|>rename( you_first_no_return =feelings_youalone, you_first_then_partner =feelings_bothyoufirst, partner_first_no_return =feelings_themalone, partner_first_then_you =feelings_boththemfirst, neither_apologized =feelings_neither, you_first_then_partner_forgiven =feelings_youaloneforgiven)|>pivot_longer( cols =you_first_no_return:you_first_then_partner_forgiven, names_to ="scenarios", values_to ="value")
One-Way Repeated Measures ANOVA
The plot below presents the results from a repeated measures ANOVA, highlighting significant differences in how participants would feel across various scenarios. Each violin plot represents a different scenario, accompanied by its sample size and overlaid with individual data points and box plots for additional detail. Notably, the analysis provides clear evidence of variability in emotional responses between different interaction patterns, as indicated by the significant p-values listed above the plot.
The black lines connecting the violin plots indicate significant differences as determined by post hoc pairwise t-tests, which have been subjected to the Holm-Bonferroni correction method. This method adjusts the significance levels to control for the increased risk of Type I errors when conducting multiple comparisons. The scenario you_first_no_return stands out as having a significantly lower mean value compared to the other four groups, with the sole exception of the neither_apologized scenario. This signifies that participants expect to feel comparatively worse when they are the first to apologize without receiving an apology in return, except in the case where no apologies are exchanged at all (addressing Task 2 Question b).
Furthermore, if a reciprocal apology were merely perceived as an act of forgiveness, there should be no significant emotional difference between scenarios where participants apologize first and then receive an apology, versus those where they receive forgiveness without an apology. Contrary to this expectation, the significant differences highlighted by the t-test results in the plot below suggest that a reciprocal apology is not simply viewed as a form of forgiveness. Specifically, receiving an apology leads to a more positive emotional response than forgiveness without reciprocation (addressing Task 1 Question 3).
Unfold Code Chunk
library(ggstatsplot)# Calculate the mean and sortscenario_means<-df|>group_by(scenarios)|>summarise(mean_value =mean(value, na.rm =TRUE))|>arrange((mean_value))|>pull(scenarios)# Reorder the scenarios factordf$scenarios<-factor(df$scenarios, levels =scenario_means)# Generate the plotggwithinstats(data =df, x =scenarios, y =value, type ="parametric", bf.message =FALSE, ggplot.component =scale_y_continuous(breaks =seq(-30, 30, 10), limits =c(-30, 70)))+theme(axis.text.x =element_text(angle =15))+labs( title ="Feelings and Apology Scenarios", x ="Apology Scenarios", y ="Feelings", caption ="Results from repeated measures ANOVA are indicated below the title. Paired t-tests yield significant distinctions between certain scenarios, as visualized by the connecting lines above.")
The plot below illustrates significant variations in emotional responses for individuals who initiate an apology. As demonstrated by the significant outcomes of the ANOVA and the paired t-tests, these differences are statistically noteworthy. This pattern indicates that receiving an apology in return is meaningful to those who apologize first. More precisely, it appears that individuals anticipate feeling better when their apology is reciprocated, compared to being forgiven without an apology, with the least favorable emotional response associated with no return apology at all (addressing Task 1 Question 1).
Unfold Code Chunk
df|>filter(str_starts(scenarios, "you_first"))|>ggwithinstats(x =scenarios, y =value, bf.message =FALSE, type ="parametric", ggplot.component =scale_y_continuous(breaks =seq(-30, 30, 10), limits =c(-30, 50)))+labs( title ="Feelings and \"You First\" Apology Scenarios", x ="\"You First\" Apology Scenarios", y ="Feelings", caption ="Results from repeated measures ANOVA are indicated below the title. Paired t-tests yield significant distinctions, as visualized by the connecting lines above.")
Linear Mixed-Effects Modeling
The code chunk below fits a linear mixed-effects model to a subset of the data using lme4::lmer, specifically focusing on scenarios where participants would initiate the apology. The jtools::summ function is then employed to generate a well-formatted summary, which includes estimated effects and model diagnostics. The analysis shows no significant interaction between scenario types and initiator types on emotional responses. That is, the correlation between “you apologize first” scenarios and emotional responses does not depend on the “initiator type” (addressing Task 1 Question 2).
Unfold Code Chunk
lme4::lmer(value~scenarios*initiator_type+(1|ResponseId), data =filter(df, str_starts(scenarios, "you_first")))|>jtools::summ()
The bar plot below illustrates the average feelings to each apology scenario. It shows a distinct trend: the scenario where participants apologize first without receiving a return apology is met with the most negative average feeling, while the scenario in which the partner initiates the apology followed by the participant’s apology leads to the most positive average response. This gradient of emotional response indicates a discernible preference for mutual apology exchanges (addressing Task 2 Question a).
Unfold Code Chunk
# Calculate means and standard errorssummary_df<-df|>group_by(scenarios)|>summarise(mean_feelings =mean(value, na.rm =TRUE), se_feelings =sd(value, na.rm =TRUE)/sqrt(n()))|>arrange(mean_feelings)# Create the bar graphggplot(summary_df, aes(x =reorder(scenarios, mean_feelings), y =mean_feelings, fill =mean_feelings))+geom_bar(stat ="identity")+geom_errorbar(aes(ymin =mean_feelings-se_feelings, ymax =mean_feelings+se_feelings), width =0.2)+scale_fill_gradient(low ="lightblue", high ="darkblue")+labs(title ="Emotional Reactions for Various Apology Scenarios", x ="Scenarios", y ="Feelings", fill ="Average\nFeelings", caption ="Error bars represent standard errors.")+theme_minimal()+coord_flip()
Visualization and Analysis for outcome_binary1
The pie plot below visualizes participants’ preferences regarding apology initiation. The results, derived from a chi-squared goodness of fit test, indicate a significant preference among participants: a substantial majority, 81% (34 out of 42 individuals), prefer to apologize first and then receive an apology, in contrast to 19% who prefer that neither party apologizes. The chi-squared statistic (χ²(1) = 16.10, p = 6.02e-05) confirms the significance of this preference. This indicates a strong tendency for individuals to favor mutual apology over the absence of apology in interactions.
Unfold Code Chunk
df|>pivot_wider(names_from =scenarios, values_from =value)|>ggpiestats( x =outcome_binary1, type ="parametric", label ="both", bf.message =FALSE, title ="Percentage Breakdown of Apology Initiation Preferences", caption ="Results from chi-squared goodness of fit test are indicated below the title.", legend.title ="Initiator Type")
To be rigorous, an exact binomial test was conducted alongside the chi-squared analysis, focusing on the binary nature of the data. The binomial test, based on the binomial distribution, provides exact p-values for binary outcomes and is suited for small sample sizes. In contrast, the chi-squared test, which relies on the chi-squared distribution, offers an approximate method more suitable for larger or multi-category datasets. Despite their differences in underlying distributions, both tests consistently demonstrate that the preference for mutual apologies significantly exceeds the expected 50%, confirming the robustness of the findings (addressing Task 2 Question 3).
Unfold Code Chunk
binom.test( x =34, n =42, p =0.5, alternative ="two.sided")
Exact binomial test
data: 34 and 42
number of successes = 34, number of trials = 42, p-value = 6.877e-05
alternative hypothesis: true probability of success is not equal to 0.5
95 percent confidence interval:
0.6588156 0.9139944
sample estimates:
probability of success
0.8095238
Sentiment Analysis with ChatGPT
Rathje et al. (2013) propose that GPT may outperform many existing automated text analysis methods. For instance, traditional text analysis methods might erroneously classify both “I work a lot.” and “There is a lot of work.” as positive, despite the latter likely conveying negative sentiment. In contrast, ChatGPT can accurately discern the sentiment in these cases. Therefore, ChatGPT Model 3.5 Turbo was employed to assess the sentiment of participants’ descriptions of conflict scenarios.
The code snippets below illustrate how to interact with ChatGPT in R. To minimize repeated costs, the results were stored in df_sentiment.csv, but executing the code snippets below should replicate the findings, provided that temperature = 0, ensuring ChatGPT consistently delivers the same response.
The pie plot, chi-squared goodness of fit test, and exact binomial test collectively indicate that participants predominantly experience negative emotions when reflecting on conflict scenarios, in contrast to a neutral 50% expectation. This suggests that individuals generally feel negative emotions when contemplating conflict situations where neither party has apologized (addressing Task 2 Question 4).
Unfold Code Chunk
library(httr)# Put your API key heremy_API<-"Find on https://openai.com/"# Run the function, change `model =` if necessaryhey_chatGPT<-function(answer_my_question){chat_GPT_answer<-POST( url ="https://api.openai.com/v1/chat/completions",add_headers(Authorization =paste("Bearer", my_API)),content_type_json(), encode ="json", body =list( model ="gpt-3.5-turbo-0301", temperature =0, # Set 0 to be reproducible messages =list(list( role ="user", content =answer_my_question))))str_trim(content(chat_GPT_answer)$choices[[1]]$message$content)}# Say hi to test the functionhey_chatGPT("hi")
Unfold Code Chunk
# Analyze sentiment for each describe and output the resultsdf_sentiment<-df%>%select(describe)%>%distinct(describe)%>%mutate( sentiment =map_chr(describe, ~hey_chatGPT(paste("Is the sentiment of this text positive, neutral, or negative? Answer only with one word: Positive, Neutral, or Negative (no punctuation). Here is the text:", .x))))
Unfold Code Chunk
# Results were saved to a .csv file to reduce costsdf_sentiment<-readr::read_csv("df_sentiment.csv")# Analyze and plotdf_sentiment|>ggpiestats( x =sentiment, type ="parametric", label ="both", bf.message =FALSE, title ="Sentiment Composition of Descriptions", caption ="Results from chi-squared goodness of fit test are indicated below the title.", legend.title ="Sentiment Type")
Unfold Code Chunk
binom.test( x =28, n =42, p =0.5, alternative ="two.sided")
Exact binomial test
data: 28 and 42
number of successes = 28, number of trials = 42, p-value = 0.04356
alternative hypothesis: true probability of success is not equal to 0.5
95 percent confidence interval:
0.5045125 0.8043320
sample estimates:
probability of success
0.6666667
Exploratory Analysis
Further, a series of mean comparison analyses were conducted to explore whether feelings in various apology scenarios vary systematically across different initiator and gender types. As depicted in the plots below, the pattern of feelings is quite consistent. Mutual apology scenarios (where either participants or their partners apologize first and receive a return apology) are associated with the most positive feelings, while scenarios where participants apologize first without receiving a return apology elicit the most negative feelings. This suggests that individuals tend to feel better when both parties apologize, but significantly worse when they initiate an apology without reciprocation.
Unfold Code Chunk
df|>filter(initiator_type=="always")|>ggwithinstats( x =scenarios, y =value, type ="parametric", bf.message =FALSE, ggplot.component =scale_y_continuous(breaks =seq(-30, 30, 10), limits =c(-30, 70)))+theme(axis.text.x =element_text(angle =15))+labs( title ="Feelings and Apology Scenarios (initiator_type == \"always\")", x ="Apology Scenarios", y ="Feelings", caption ="Results from repeated measures ANOVA are indicated below the title. Paired t-tests yield significant distinctions between certain scenarios, as visualized by the connecting lines above.")
Unfold Code Chunk
df|>filter(initiator_type=="conditional")|>ggwithinstats( x =scenarios, y =value, type ="parametric", bf.message =FALSE, ggplot.component =scale_y_continuous(breaks =seq(-30, 30, 10), limits =c(-30, 70)))+theme(axis.text.x =element_text(angle =15))+labs( title ="Feelings and Apology Scenarios (initiator_type == \"conditional\")", x ="Apology Scenarios", y ="Feelings", caption ="Results from repeated measures ANOVA are indicated below the title. Paired t-tests yield significant distinctions between certain scenarios, as visualized by the connecting lines above.")
Unfold Code Chunk
df|>filter(initiator_type=="never")|>ggwithinstats( x =scenarios, y =value, type ="parametric", bf.message =FALSE, ggplot.component =scale_y_continuous(breaks =seq(-30, 30, 10), limits =c(-30, 70)))+theme(axis.text.x =element_text(angle =15))+labs( title ="Feelings and Apology Scenarios (initiator_type == \"never\")", x ="Apology Scenarios", y ="Feelings", caption ="Results from repeated measures ANOVA are indicated below the title. Paired t-tests yield significant distinctions between certain scenarios, as visualized by the connecting lines above.")
Unfold Code Chunk
df|>filter(sex=="Male")|>ggwithinstats( x =scenarios, y =value, type ="parametric", bf.message =FALSE, ggplot.component =scale_y_continuous(breaks =seq(-30, 30, 10), limits =c(-30, 70)))+theme(axis.text.x =element_text(angle =15))+labs( title ="Feelings and Apology Scenarios (Male)", x ="Apology Scenarios", y ="Feelings", caption ="Results from repeated measures ANOVA are indicated below the title. Paired t-tests yield significant distinctions between certain scenarios, as visualized by the connecting lines above.")
Unfold Code Chunk
df|>filter(sex=="Female")|>ggwithinstats( x =scenarios, y =value, type ="parametric", bf.message =FALSE, ggplot.component =scale_y_continuous(breaks =seq(-30, 30, 10), limits =c(-30, 70)))+theme(axis.text.x =element_text(angle =15))+labs( title ="Feelings and Apology Scenarios (Female)", x ="Apology Scenarios", y ="Feelings", caption ="Results from repeated measures ANOVA are indicated below the title. Paired t-tests yield significant distinctions between certain scenarios, as visualized by the connecting lines above.")
Discussion
A series of analyses consistently demonstrate that mutual apologies, where both parties take blame, elicit the most positive emotions, while unreciprocated apologies result in the most negative emotional responses. This pattern underscores the importance of reciprocity in apology scenarios. Mutual apologies, by their nature, involve both parties acknowledging their wrongdoing, which can reinforce a sense of fairness and shared responsibility. Conversely, when an individual apologizes without receiving a response, it may lead to feelings of vulnerability or a sense of injustice, contributing to negative emotions.
However, the influece of apology patterns on emotions may depend on on factors such as the status difference between the parties involved and the closeness of their relationship. In conflicts involving a hierarchy, such as those between a supervisor and a subordinate, the expectation for mutual apologies may not hold. Subordinates might perceive a lack of apology from a supervisor as normal, especially in cultures with strict hierarchical norms, such as Japan or China. Furthermore, the closeness of the relationship can also act as a moderating factor. In familiar relationships, non-mutual apologies might lead to fewer negative feelings, as individuals are more likely to be forgiving and understanding towards people they know well.
Reference List
Rathje, S., Mirea, D., Sucholutsky, I., Marjieh, R., Robertson, C., & Van Bavel, J. J. (2023, May 19). GPT is an effective tool for multilingual psychological text analysis. https://doi.org/10.31234/osf.io/sekf5
Source Code
---title: "Chicago Booth Data Analysis Task (2024)"execute: enabled: trueformat: html: toc: true embed-resources: false code-overflow: wrap code-link: true message: false warning: false code-fold: true code-summary: Unfold Code Chunk code-tools: trueproject: type: website---# Data PreparationThe code chunk below (**click the button to expand it, or select the option in the upper right `</> Code` to expand all code chunks**) reads data from an Excel file into a DataFrame `df`. It then filters out participants who failed attention checks and retains only those who could recall a real conflict situation. Additionally, it removes a participant who left a comment indicating non-serious participation ("don't use these data; was just clicking through") and reported an unrealistic age (149). The code chunk also renames the original variables to more meaningful names for clarity and ease of analysis. Finally, the DataFrame is transformed into a long format for further analysis. The resulting sample size is 42.```{r}library(tidyverse)df <- readxl::read_excel("Data - Fall 2023.xlsx", sheet ="Data") |>filter(passedattn =="yes") |>filter(real_imaginary =="I have thought of a real argument/conflict from my life where this is true") |>filter(age !=149) |>rename(you_first_no_return = feelings_youalone,you_first_then_partner = feelings_bothyoufirst,partner_first_no_return = feelings_themalone,partner_first_then_you = feelings_boththemfirst,neither_apologized = feelings_neither,you_first_then_partner_forgiven = feelings_youaloneforgiven ) |>pivot_longer(cols = you_first_no_return:you_first_then_partner_forgiven,names_to ="scenarios",values_to ="value" )```# One-Way Repeated Measures ANOVAThe plot below presents the results from a repeated measures ANOVA, highlighting significant differences in how participants would feel across various scenarios. Each violin plot represents a different scenario, accompanied by its sample size and overlaid with individual data points and box plots for additional detail. Notably, the analysis provides clear evidence of variability in emotional responses between different interaction patterns, as indicated by the significant *p*-values listed above the plot.The black lines connecting the violin plots indicate significant differences as determined by post hoc pairwise *t*-tests, which have been subjected to the Holm-Bonferroni correction method. This method adjusts the significance levels to control for the increased risk of Type I errors when conducting multiple comparisons. The scenario `you_first_no_return` stands out as having a significantly lower mean value compared to the other four groups, with the sole exception of the `neither_apologized` scenario. This signifies that participants expect to feel comparatively worse when they are the first to apologize without receiving an apology in return, except in the case where no apologies are exchanged at all (addressing **Task 2 Question b**).Furthermore, if a reciprocal apology were merely perceived as an act of forgiveness, there should be no significant emotional difference between scenarios where participants apologize first and then receive an apology, versus those where they receive forgiveness without an apology. Contrary to this expectation, the significant differences highlighted by the *t*-test results in the plot below suggest that a reciprocal apology is not simply viewed as a form of forgiveness. Specifically, receiving an apology leads to a more positive emotional response than forgiveness without reciprocation (addressing **Task 1 Question 3**).```{r}#| fig-height: 10library(ggstatsplot)# Calculate the mean and sortscenario_means <- df |>group_by(scenarios) |>summarise(mean_value =mean(value, na.rm =TRUE)) |>arrange((mean_value)) |>pull(scenarios)# Reorder the scenarios factordf$scenarios <-factor(df$scenarios, levels = scenario_means)# Generate the plotggwithinstats(data = df, x = scenarios, y = value, type ="parametric", bf.message =FALSE,ggplot.component =scale_y_continuous(breaks =seq(-30, 30, 10), limits =c(-30, 70))) +theme(axis.text.x =element_text(angle =15)) +labs(title ="Feelings and Apology Scenarios",x ="Apology Scenarios",y ="Feelings",caption ="Results from repeated measures ANOVA are indicated below the title. Paired t-tests yield significant distinctions between certain scenarios, as visualized by the connecting lines above." )```The plot below illustrates significant variations in emotional responses for individuals who initiate an apology. As demonstrated by the significant outcomes of the ANOVA and the paired *t*-tests, these differences are statistically noteworthy. This pattern indicates that receiving an apology in return is meaningful to those who apologize first. More precisely, it appears that individuals anticipate feeling better when their apology is reciprocated, compared to being forgiven without an apology, with the least favorable emotional response associated with no return apology at all (addressing **Task 1 Question 1**).```{r}df |>filter(str_starts(scenarios, "you_first")) |>ggwithinstats(x = scenarios, y = value, bf.message =FALSE,type ="parametric",ggplot.component =scale_y_continuous(breaks =seq(-30, 30, 10), limits =c(-30, 50))) +labs(title ="Feelings and \"You First\" Apology Scenarios",x ="\"You First\" Apology Scenarios",y ="Feelings",caption ="Results from repeated measures ANOVA are indicated below the title. Paired t-tests yield significant distinctions, as visualized by the connecting lines above." )```# Linear Mixed-Effects ModelingThe code chunk below fits a linear mixed-effects model to a subset of the data using `lme4::lmer`, specifically focusing on scenarios where participants would initiate the apology. The `jtools::summ` function is then employed to generate a well-formatted summary, which includes estimated effects and model diagnostics. The analysis shows no significant interaction between scenario types and initiator types on emotional responses. That is, the correlation between "you apologize first" scenarios and emotional responses does not depend on the "initiator type" (addressing **Task 1 Question 2**).```{r}lme4::lmer(value ~ scenarios * initiator_type + (1|ResponseId), data =filter(df, str_starts(scenarios, "you_first"))) |> jtools::summ()```# Bar PlotThe bar plot below illustrates the average feelings to each apology scenario. It shows a distinct trend: the scenario where participants apologize first without receiving a return apology is met with the most negative average feeling, while the scenario in which the partner initiates the apology followed by the participant's apology leads to the most positive average response. This gradient of emotional response indicates a discernible preference for mutual apology exchanges (addressing **Task 2 Question a**).```{r}# Calculate means and standard errorssummary_df <- df |>group_by(scenarios) |>summarise(mean_feelings =mean(value, na.rm =TRUE),se_feelings =sd(value, na.rm =TRUE) /sqrt(n())) |>arrange(mean_feelings)# Create the bar graphggplot(summary_df, aes(x =reorder(scenarios, mean_feelings), y = mean_feelings, fill = mean_feelings)) +geom_bar(stat ="identity") +geom_errorbar(aes(ymin = mean_feelings - se_feelings, ymax = mean_feelings + se_feelings), width =0.2) +scale_fill_gradient(low ="lightblue", high ="darkblue") +labs(title ="Emotional Reactions for Various Apology Scenarios",x ="Scenarios",y ="Feelings",fill ="Average\nFeelings",caption ="Error bars represent standard errors.") +theme_minimal() +coord_flip()```# Visualization and Analysis for `outcome_binary1`The pie plot below visualizes participants' preferences regarding apology initiation. The results, derived from a chi-squared goodness of fit test, indicate a significant preference among participants: a substantial majority, 81% (34 out of 42 individuals), prefer to apologize first and then receive an apology, in contrast to 19% who prefer that neither party apologizes. The chi-squared statistic (χ²(1) = 16.10, *p* = 6.02e-05) confirms the significance of this preference. This indicates a strong tendency for individuals to favor mutual apology over the absence of apology in interactions.```{r}df |>pivot_wider(names_from = scenarios, values_from = value) |>ggpiestats(x = outcome_binary1,type ="parametric",label ="both",bf.message =FALSE,title ="Percentage Breakdown of Apology Initiation Preferences",caption ="Results from chi-squared goodness of fit test are indicated below the title.",legend.title ="Initiator Type" )```To be rigorous, an exact binomial test was conducted alongside the chi-squared analysis, focusing on the binary nature of the data. The binomial test, based on the binomial distribution, provides exact *p*-values for binary outcomes and is suited for small sample sizes. In contrast, the chi-squared test, which relies on the chi-squared distribution, offers an approximate method more suitable for larger or multi-category datasets. Despite their differences in underlying distributions, both tests consistently demonstrate that the preference for mutual apologies significantly exceeds the expected 50%, confirming the robustness of the findings (addressing **Task 2 Question 3**).```{r}binom.test(x =34, n =42, p =0.5, alternative ="two.sided")```# Sentiment Analysis with ChatGPTRathje et al. (2013) propose that GPT may outperform many existing automated text analysis methods. For instance, traditional text analysis methods might erroneously classify both "I work a lot." and "There is a lot of work." as positive, despite the latter likely conveying negative sentiment. In contrast, ChatGPT can accurately discern the sentiment in these cases. Therefore, ChatGPT Model 3.5 Turbo was employed to assess the sentiment of participants' descriptions of conflict scenarios.The code snippets below illustrate how to interact with ChatGPT in R. To minimize repeated costs, the results were stored in `df_sentiment.csv`, but executing the code snippets below should replicate the findings, provided that `temperature = 0`, ensuring ChatGPT consistently delivers the same response.The pie plot, chi-squared goodness of fit test, and exact binomial test collectively indicate that participants predominantly experience negative emotions when reflecting on conflict scenarios, in contrast to a neutral 50% expectation. This suggests that individuals generally feel negative emotions when contemplating conflict situations where neither party has apologized (addressing **Task 2 Question 4**).```{r}#| eval: falselibrary(httr)# Put your API key heremy_API <-"Find on https://openai.com/"# Run the function, change `model =` if necessaryhey_chatGPT <-function(answer_my_question) { chat_GPT_answer <-POST(url ="https://api.openai.com/v1/chat/completions",add_headers(Authorization =paste("Bearer", my_API)),content_type_json(),encode ="json",body =list(model ="gpt-3.5-turbo-0301",temperature =0, # Set 0 to be reproduciblemessages =list(list(role ="user",content = answer_my_question ) ) ) )str_trim(content(chat_GPT_answer)$choices[[1]]$message$content)}# Say hi to test the functionhey_chatGPT("hi") ``````{r}#| cache: true #| eval: false# Analyze sentiment for each describe and output the resultsdf_sentiment <- df %>%select(describe) %>%distinct(describe) %>%mutate(sentiment =map_chr(describe, ~hey_chatGPT(paste("Is the sentiment of this text positive, neutral, or negative? Answer only with one word: Positive, Neutral, or Negative (no punctuation). Here is the text:", .x))) )``````{r}# Results were saved to a .csv file to reduce costsdf_sentiment <- readr::read_csv("df_sentiment.csv")# Analyze and plotdf_sentiment |>ggpiestats(x = sentiment,type ="parametric",label ="both",bf.message =FALSE,title ="Sentiment Composition of Descriptions",caption ="Results from chi-squared goodness of fit test are indicated below the title.",legend.title ="Sentiment Type" )``````{r}binom.test(x =28, n =42, p =0.5, alternative ="two.sided")```# Exploratory AnalysisFurther, a series of mean comparison analyses were conducted to explore whether feelings in various apology scenarios vary systematically across different initiator and gender types. As depicted in the plots below, the pattern of feelings is quite consistent. Mutual apology scenarios (where either participants or their partners apologize first and receive a return apology) are associated with the most positive feelings, while scenarios where participants apologize first without receiving a return apology elicit the most negative feelings. This suggests that individuals tend to feel better when both parties apologize, but significantly worse when they initiate an apology without reciprocation.```{r}#| fig-height: 10#| code-fold: truedf |>filter(initiator_type =="always") |>ggwithinstats(x = scenarios, y = value, type ="parametric", bf.message =FALSE,ggplot.component =scale_y_continuous(breaks =seq(-30, 30, 10), limits =c(-30, 70))) +theme(axis.text.x =element_text(angle =15)) +labs(title ="Feelings and Apology Scenarios (initiator_type == \"always\")",x ="Apology Scenarios",y ="Feelings",caption ="Results from repeated measures ANOVA are indicated below the title. Paired t-tests yield significant distinctions between certain scenarios, as visualized by the connecting lines above." )df |>filter(initiator_type =="conditional") |>ggwithinstats(x = scenarios, y = value, type ="parametric", bf.message =FALSE,ggplot.component =scale_y_continuous(breaks =seq(-30, 30, 10), limits =c(-30, 70))) +theme(axis.text.x =element_text(angle =15)) +labs(title ="Feelings and Apology Scenarios (initiator_type == \"conditional\")",x ="Apology Scenarios",y ="Feelings",caption ="Results from repeated measures ANOVA are indicated below the title. Paired t-tests yield significant distinctions between certain scenarios, as visualized by the connecting lines above." )df |>filter(initiator_type =="never") |>ggwithinstats(x = scenarios, y = value, type ="parametric", bf.message =FALSE,ggplot.component =scale_y_continuous(breaks =seq(-30, 30, 10), limits =c(-30, 70))) +theme(axis.text.x =element_text(angle =15)) +labs(title ="Feelings and Apology Scenarios (initiator_type == \"never\")",x ="Apology Scenarios",y ="Feelings",caption ="Results from repeated measures ANOVA are indicated below the title. Paired t-tests yield significant distinctions between certain scenarios, as visualized by the connecting lines above." )df |>filter(sex =="Male") |>ggwithinstats(x = scenarios, y = value, type ="parametric", bf.message =FALSE,ggplot.component =scale_y_continuous(breaks =seq(-30, 30, 10), limits =c(-30, 70))) +theme(axis.text.x =element_text(angle =15)) +labs(title ="Feelings and Apology Scenarios (Male)",x ="Apology Scenarios",y ="Feelings",caption ="Results from repeated measures ANOVA are indicated below the title. Paired t-tests yield significant distinctions between certain scenarios, as visualized by the connecting lines above." )df |>filter(sex =="Female") |>ggwithinstats(x = scenarios, y = value, type ="parametric", bf.message =FALSE,ggplot.component =scale_y_continuous(breaks =seq(-30, 30, 10), limits =c(-30, 70))) +theme(axis.text.x =element_text(angle =15)) +labs(title ="Feelings and Apology Scenarios (Female)",x ="Apology Scenarios",y ="Feelings",caption ="Results from repeated measures ANOVA are indicated below the title. Paired t-tests yield significant distinctions between certain scenarios, as visualized by the connecting lines above." )```# DiscussionA series of analyses consistently demonstrate that mutual apologies, where both parties take blame, elicit the most positive emotions, while unreciprocated apologies result in the most negative emotional responses. This pattern underscores the importance of reciprocity in apology scenarios. Mutual apologies, by their nature, involve both parties acknowledging their wrongdoing, which can reinforce a sense of fairness and shared responsibility. Conversely, when an individual apologizes without receiving a response, it may lead to feelings of vulnerability or a sense of injustice, contributing to negative emotions.However, the influece of apology patterns on emotions may depend on on factors such as the status difference between the parties involved and the closeness of their relationship. In conflicts involving a hierarchy, such as those between a supervisor and a subordinate, the expectation for mutual apologies may not hold. Subordinates might perceive a lack of apology from a supervisor as normal, especially in cultures with strict hierarchical norms, such as Japan or China. Furthermore, the closeness of the relationship can also act as a moderating factor. In familiar relationships, non-mutual apologies might lead to fewer negative feelings, as individuals are more likely to be forgiving and understanding towards people they know well.# Reference ListRathje, S., Mirea, D., Sucholutsky, I., Marjieh, R., Robertson, C., & Van Bavel, J. J. (2023, May 19). GPT is an effective tool for multilingual psychological text analysis. https://doi.org/10.31234/osf.io/sekf5