Data Preparation

Load packages

Data Wrangling

d <- d %>%
  dplyr::slice(-1, -2) %>% #remove first 2 rows with title info
  filter(Status==0) %>% #Remove Survey Preview rows
  arrange(Agency2) %>% #Arrange data by condition
  rename(ECNA = "Q51") %>% #241 initial participants
  filter(AttnCheck==5) %>% #Exclude participants who failed attention end-check (6)
  filter(!is.na(Agency2)|!is.na(NonA2)) %>%  #Exclude participants who left attn. manipulation checks blank (5)
  convert(num(Sab1_1,Sab1_2, Sab1_3, Sab1_4,Sab1_5,
         Sab1b_1,Sab1b_2,Sab1b_3,Sab1b_4,Sab1b_5,
         Sab2_1,Sab2_2,Sab2_3,Sab2_4,Sab2_5,
         Sab2b_1,Sab2b_2,Sab2b_3,Sab2b_4,Sab2b_5,
         Sab3_1,Sab3_2,Sab3_3,Sab3_4,Sab3_5,
         Sab3b_1,Sab3b_2,Sab3b_3,Sab3b_4,Sab3b_5,
         EC,
         Sab1NA_1,Sab1NA_2,Sab1NA_3,Sab1NA_4,Sab1NA_5,
         Sab1NAb_1,Sab1NAb_2,Sab1NAb_3,Sab1NAb_4,Sab1NAb_5,
         Sab2NA_1,Sab2NA_2,Sab2NA_3,Sab2NA_4,Sab2NA_5,
         Sab2NAb_1,Sab2NAb_2,Sab2NAb_3,Sab2NAb_4,Sab2NAb_5,
         Sab3NA_1,Sab3NA_2,Sab3NA_3,Sab3NA_4,Sab3NA_5,
         Sab3NAb_1,Sab3NAb_2,Sab3NAb_3,Sab3NAb_4,Sab3NAb_5,
         ECNA,AttnCheck)) %>% #convert relevant cols from character to numeric
  mutate(condition = ifelse(is.na(Agency2), "Compliance", "Agency")) %>% #create longform condition label column
  rowwise() %>%
  mutate(deserve.sab1 = ifelse(condition == "Agency", #create summed columns for each condition && vignette
                              sum(Sab1_1, Sab1_2, Sab1_3, Sab1_4, Sab1_5, na.rm = TRUE),
                              sum(Sab1NA_1, Sab1NA_2, Sab1NA_3, Sab1NA_4, Sab1NA_5, na.rm = TRUE))) %>%
  mutate(deserve.sab2 = ifelse(condition == "Agency",
                              sum(Sab2_1, Sab2_2, Sab2_3, Sab2_4, Sab2_5, na.rm = TRUE),
                              sum(Sab2NA_1, Sab2NA_2, Sab2NA_3, Sab2NA_4, Sab2NA_5, na.rm = TRUE))) %>%
  mutate(deserve.sab3 = ifelse(condition == "Agency",
                              sum(Sab3_1, Sab3_2, Sab3_3, Sab3_4, Sab3_5, na.rm = TRUE),
                              sum(Sab3NA_1, Sab3NA_2, Sab3NA_3, Sab3NA_4, Sab3NA_5, na.rm = TRUE))) %>%
  
  mutate(actual.sab1 = ifelse(condition == "Agency",
                              sum(Sab1b_1, Sab1b_2, Sab1b_3, Sab1b_4, Sab1b_5, na.rm = TRUE),
                              sum(Sab1NAb_1, Sab1NAb_2, Sab1NAb_3, Sab1NAb_4, Sab1NAb_5, na.rm = TRUE))) %>%
  mutate(actual.sab2 = ifelse(condition == "Agency",
                              sum(Sab2b_1, Sab2b_2, Sab2b_3, Sab2b_4, Sab2b_5, na.rm = TRUE),
                              sum(Sab2NAb_1, Sab2NAb_2, Sab2NAb_3, Sab2NAb_4, Sab2NAb_5, na.rm = TRUE))) %>%
  mutate(actual.sab3 = ifelse(condition == "Agency",
                              sum(Sab3b_1, Sab3b_2, Sab3b_3, Sab3b_4, Sab3b_5, na.rm = TRUE),
                              sum(Sab3NAb_1, Sab3NAb_2, Sab3NAb_3, Sab3NAb_4, Sab3NAb_5, na.rm = TRUE))) %>%
  dplyr::select(ResponseId, Agency2, NonA2, condition,
               deserve.sab1, deserve.sab2, deserve.sab3,
               actual.sab1, actual.sab2, actual.sab3)  #select relevant columns for further analysis 

Attention Exclusions

Agency Exclusions

Excluding based on failed attention responses in Agency condition manipulation check (57 exclusions)

d <- d %>%
  filter( # Exclusion 2: exclude failed condition 1 Attention Check
       !grepl("5", Agency2),
       # CODER 1 - JOSEPH OUTA
       !grepl("Balancing the Company's Needs and Employee Satisfaction", Agency2), #page 1
       !grepl("Based on the company values or mission statement", Agency2),
       !grepl("By the value", Agency2),
       !grepl("Company decisions should be based on values", Agency2),
       !grepl("Decisions will be all over the place and inconsistent.", Agency2),
       !grepl("Employees should make decisions based on values.", Agency2), #page 2 of preview
       !grepl("Employees should keep the big picture in mind. Not ever customer will be the same and they must respect them and handle them in a friendly manner.", Agency2), # page 3
       !grepl("Focus on customer care and well-being", Agency2), # page 4
       !grepl("It treats the costumer with professionalism", Agency2),  
       !grepl("Quality and respect", Agency2), #page 5
       !grepl("quickly and confidently", Agency2),
       !grepl("should make them respectfully and fairly", Agency2), #page 7
       !grepl("That they should do them with the best interests of the company in mind", Agency2),
       !grepl("They respect there policy", Agency2), #page 8
       !grepl("They should make decisions that the company would approve of and they themselves would approve of.", Agency2),
       !grepl("They should think about your value as a pets", Agency2), #page 9
       !grepl("They should try to be more friendly towards customers.", Agency2),
       !grepl("to serve the customer best", Agency2), #page 10
       !grepl("Treat customers in professional and friendly manner", Agency2),
       !grepl("treat employees well", Agency2),
       !grepl("Treat the customers well.", Agency2),
       !grepl("yes", Agency2), #page 11
       
       # CODER 2 - YUEL LI ADDITIONAL EXCLUSIONS
       !grepl("Allows customers to make company decisions", Agency2),
       !grepl("By working together", Agency2),
       !grepl("Employees of SerVest should be mindful of the different value's their customers might have.", Agency2),
       !grepl("Employees should make company decisions based on the values the company at large has, not their own.", Agency2),
       !grepl("Employees should make company decisions taking into account customer values.", Agency2),
       !grepl("Employees should make company decisions with the customer's best interest in mind. All decisions should benefit the customer first.", Agency2),
       !grepl("employees should make the best decisions for the customers", Agency2),
       !grepl("Employees should work together to make decisions.", Agency2),
       !grepl("Following their guidelines", Agency2),
       !grepl("How to best serve their interests.", Agency2),
       !grepl("I believe that when the company encourages people who do not agree with their beliefs to find another place to be serviced, it gives the employees more power to say who can and cannot shop there.", Agency2),
       !grepl("In a professional and caring manner", Agency2),
       !grepl("Sarvest trusts its employees to make good decisions", Agency2),
       !grepl("Servest relies on employees making good choices.", Agency2),
       !grepl("SerVest understands that company values vary and they trust companies to make their own decisions that reflect those.", Agency2),
       !grepl("That the company has certain values and also employees should also have those values and their own", Agency2),
       !grepl("They respect there policy", Agency2),
       !grepl("They should accomidate the customer's values", Agency2),
       !grepl("They should make decisions that the company would approve of and they themselves would approve of.", Agency2),
       !grepl("They should make decisions with the customers in mind", Agency2),
       !grepl("They should put customer service first.", Agency2),
       !grepl("They should reflect customer values", Agency2),
       !grepl("they take in mind what customers say", Agency2),
       !grepl("to reflect customer's beliefs", Agency2),
       !grepl("trust employee to make decisions that will reflect positively on the company", Agency2),
       !grepl("values reflect the work culture", Agency2),
       !grepl("with consideration of the customer needs", Agency2),
       !grepl("With morals & sincerity. SerVest trusts the employees", Agency2),
       !grepl("with the customer in mind", Agency2),
       !grepl("with the upmost integrity", Agency2)
       )

NonAgency Exclusions

Excluding based on failed responses in Non-Agency condition manipulation check (32 exclusions)

d <- d %>%
  filter(# CODER 1 - JOSEPH OUTA
         !grepl("By keeping a good relationship with the customer- honesty and respect.", NonA2), #page 1
         !grepl("Company decisions are basically based in how they treat their cliental.", NonA2),
         !grepl("Decisions should be made in a way that will serve the customers better", NonA2),
         !grepl("Do not understand the question", NonA2),
         !grepl("Employees should share their knowledge with others", NonA2),# page 3
         !grepl("employess should be involved with company decisions since everyone has different opinions", NonA2), #page 4
         !grepl("Ethical decisions", NonA2),
         !grepl("I cannot remember", NonA2),
         !grepl("im not aware", NonA2),
         !grepl("It denotes professionalism that isn't swayed by the person in charge's own views.", NonA2),
         !grepl("It says that Servest understands there are different personal values and trusts that those values will be reflected by you in the company.", NonA2),
         !grepl("iT SHOULD BE REAL", NonA2), #page 5
         !grepl("make them as a good decision", NonA2),
         !grepl("my values might clash with company values", NonA2),
         !grepl("Of course, they should think carefully and make a good decision", NonA2), #page 7
         !grepl("Of course, they should think carefully and make a good decision.", NonA2),
         !grepl("ok", NonA2),
         !grepl("SerVest does not discriminate.", NonA2), #page 8
         !grepl("should keep customer in mind", NonA2),
         !grepl("Should not use company's beliefs as part of personality", NonA2),
         !grepl("They are respectful and pay close attention to detail", NonA2), #page 9
         !grepl("they say you put the emotions of the customer into consideration", NonA2),
         !grepl("They should think about the customer more than themselves.", NonA2),#page 10
         !grepl("to the best", NonA2), #page 11
         !grepl("Trust themselves to not let their values be swayed", NonA2),
         !grepl("Value your privacy and your opinions.", NonA2),
         !grepl("varies", NonA2),
         !grepl("Vary depending on customer values", NonA2), #page 12
         !grepl("with responsibility", NonA2),
         !grepl("You should decide what to do", NonA2),
         
         # CODER 2 - YUE LI ADDITIONAL EXCLUSIONS
         !grepl("Employees Should be able to make their own decisions", NonA2),
         !grepl("information technogy company", NonA2),
         !grepl("It's Information Technogy", NonA2),
         !grepl("Like many companies, SerVest is committed to making sure customers are treated in a professional, friendly, and patient manner.", NonA2),
         !grepl("my values might conflict with the company's", NonA2) 
  )

Primary Analysis

Will increasing agency lead to less retaliatory customer sabotage?

Exploratory Analyses 1

#First wrangle data column to make plottable
dat <- d %>%
  dplyr::select(ResponseId, condition,
                deserve.sab1, deserve.sab2, deserve.sab3,
                actual.sab1, actual.sab2, actual.sab3) %>%
  pivot_longer(-c("ResponseId", "condition"), 
               names_to = "Key", 
               values_to = "Behaviors") %>% #pivot long for plotting
  separate(Key, c("Kind", "Sabotage")) %>% # splits Key into kind and sabotage 
  mutate(Vignette = ifelse(Sabotage == 'sab1', 'vign1',
                           ifelse(Sabotage == 'sab2', 'vign2', 'vign3'))) %>% 
  filter(Kind == "actual") %>% 
  dplyr::select(ResponseId, condition, Vignette, Behaviors) %>% 
  mutate_at(vars(condition), factor) %>%
  mutate_at(vars(Vignette), factor) 

Plots

# facetted histogram of sabotage behaviors across conditions and vignettes
dat %>% 
  ggplot(aes(x = Behaviors, group = condition, fill = condition)) +
  geom_bar(width = 0.75, position = position_dodge()) +
  scale_x_continuous(breaks = seq (from = 0, to = 5, by = 1)) +
  facet_grid(vars(Vignette), vars(condition)) +
  labs(x = "Number of sabotage behaviors selected",
       y = "Count",
       fill = "Condition") +
  theme(legend.position="none")

# boxplot of unethical behaviors across all 3 IVs
dat %>% 
  ggplot(aes(x = condition, y = Behaviors,  color = Vignette)) +
  geom_boxplot() #looks left skewed, makes sense since DV is Likert-type/ ordinal

# boxplot but binned by within-participant variable Sabotage
dat %>%
  ggplot(aes(x = Vignette, y = Behaviors,  color = condition)) +
  geom_boxplot()

#interaction plot
dat %>%
  with(interaction.plot(x.factor = condition, trace.factor = Vignette, 
                        response = Behaviors))

std <- function(x) sd(x)/sqrt(length(x))
dodge <- position_dodge(width = 0.9)

dd <- dat %>% 
  group_by(condition, Vignette) %>%
  summarize(n = n(),
            Mean = round(mean(Behaviors), 2), 
            SE = round(std(Behaviors), 2))
## `summarise()` has grouped output by 'condition'. You can override using the `.groups` argument.
write.csv(dd, "hyp1means.csv")

# barplot of mean actual behaviors across condition 
dd %>%
  ggplot(aes(x = condition, y = Mean, fill = Vignette)) +
  geom_bar(stat = "identity", position = position_dodge()) +
  geom_errorbar(aes(ymax = Mean + SE, ymin = Mean - SE),  position = dodge, width = 0.2) +
  scale_y_continuous(breaks = seq(from = 0, to = 1.2, by = 0.2)) +
  labs(y = "Mean sabotage behaviors") 

# point-plot of summary statistics
dd %>% 
  ggplot(aes(x = condition, y = Mean, group = Vignette, color = Vignette)) + 
  geom_point() + geom_line() + #stat_summary(geom = "line") 
  labs(y = "Mean sabotage behaviors")

# point plot but binned by within-participant variable Sabotage
dd %>%
  ggplot(aes(x = Vignette, y = Mean, group = condition, col = condition)) + 
  geom_point() + geom_line()

# binned by Sabotage but averaged out across condition
dd %>%
  ggplot(aes(x = Vignette, y = Mean, group = condition, col = condition)) + 
  geom_point() + geom_line()

Point plots and their violin alternatives

#version1: A point plot with geom jitter to visualize overlapping points  (original version)
dat %>%
  ggplot(aes(x = condition, y = Behaviors, group = Vignette, color = Vignette)) +
  geom_point() +
  geom_jitter(width = 0.3, height = 0.1) +
  stat_summary(
    geom = "line",
    fun.y = "mean",
    size = 1,
    fill = "red") +
  stat_summary(
    geom = "point",
    fun.y = "mean",
    size = 3) 
## Warning: `fun.y` is deprecated. Use `fun` instead.
## Warning: Ignoring unknown parameters: fill
## Warning: `fun.y` is deprecated. Use `fun` instead.

#version 2: Violin plot + point plot binned by vignette
dat %>%
  ggplot(aes(x = Vignette, y = Behaviors, color = Vignette)) +
  geom_violin(trim = F) +
  geom_jitter(width = 0.3,
              height = 0.05) +
  facet_wrap(~condition) +
  theme(legend.position="none") +
  stat_summary(fun.data = "mean_cl_boot",
               geom = "pointrange",
               color = "black",
               size = 0.3)

#3: single black mean line
dat %>%
  ggplot(aes(x = condition, y = Behaviors, color = condition)) +
  geom_violin(trim = F) +
  geom_jitter(width = 0.3,
              height = 0.05) +
  theme(legend.position="none") +
  stat_summary(fun = "mean", 
               geom = "line", 
               group = 1, 
               color = "black") +
  stat_summary(fun.data = "mean_cl_boot",
               geom = "pointrange",
               color = "black",
               size = 0.3) +
  theme(legend.position="none") 

#4: mean lines colored, data points black
dat %>%
  ggplot(aes(x = condition, y = Behaviors)) +
  geom_violin(trim = F) +
  geom_jitter(width = 0.3,
              height = 0.05) +
  theme(legend.position="none") +
  stat_summary(aes(group = Vignette, color = Vignette),
               fun = "mean", 
               geom = "line") +
  stat_summary(aes(group = Vignette, color = Vignette),
               fun.data = "mean_cl_boot",
               geom = "pointrange",
               size = 0.3) +
  theme(legend.position="none") 

#colored mean lines
dat %>%
  ggplot(aes(x = condition, y = Behaviors, color = condition)) +
  geom_violin(trim = F) +
  geom_jitter(width = 0.25,
              height = 0.05) +
  theme(legend.position="none") +
  stat_summary(aes(group = Vignette, color = Vignette),
               fun = "mean", 
               geom = "line") +
  stat_summary(aes(group = Vignette, color = Vignette),
               fun.data = "mean_cl_boot",
               geom = "pointrange",
               size = 0.3) +
  theme(legend.position="none") 

#mean lines are all black
dat %>%
  ggplot(aes(x = condition, y = Behaviors, color = condition)) +
  geom_violin(trim = F) +
  geom_jitter(width = 0.25,
              height = 0.05) +
  theme(legend.position="none") +
  stat_summary(aes(group = Vignette),
               fun = "mean", 
               geom = "line",
               color = "black") +
  stat_summary(aes(group = Vignette),
               fun.data = "mean_cl_boot",
               geom = "pointrange",
               size = 0.3,
               color = "black") +
  theme(legend.position="none") 

Confirmatory Analyses 1

ANOVA and Ordinal Logistic Regression

Two-way Mixed Effects Anova

Since normality appears to be violated, we will conduct a two-way ANOVA anyway, then we will also conduct an ordinal logistic regression to see if results hold. Moreover, linear tests aren’t as sensitive to normality assumptions as they are to homogeneity of variance assumptions. Since the data passed the homogeneity test, it makes sense to proceed with both an ANOVA and a regression.

Our two way mixed ANOVA has 3 null hypotheses: - No difference in between-group variable (condition) - No difference in within group variable (Sabotage) - No interaction effect (condition:Sabotage)

two.way <- anova_test(
  data = dat, dv = Behaviors, wid = ResponseId,
  between = condition, within = Vignette
  )
get_anova_table(two.way) # There was a statistically significant main effect of condition F(1, 146) = 0.032, main effect of Sabotage on unethical behaviors F(2, 277) = 7.93, p = 0.0004, and main interaction effect F(2, 277) = 0.015. generalized effect sizes were low
## ANOVA Table (type III tests)
## 
##               Effect DFn    DFd     F        p p<.05   ges
## 1          condition 1.0 146.00 4.670 0.032000     * 0.023
## 2           Vignette 1.9 277.68 8.178 0.000452     * 0.014
## 3 condition:Vignette 1.9 277.68 4.339 0.015000     * 0.007
#============ Post-Hoc Tests =============== ##

# Simple Main Effect of Condition at each vignette level
  ## Effect of condition at each sabotage
dat %>%
  group_by(Vignette) %>%
  anova_test(dv = Behaviors, wid = ResponseId, between = condition) %>%
  get_anova_table() %>%
  adjust_pvalue(method = "bonferroni") # Considering the Bonferroni adjusted p-value, the simple main effect of condition was significant at sab1 (p = 0.006) but not at sab2 (p = 0.88) and sab3 (p = 0.61).
## Coefficient covariances computed by hccm()
## Coefficient covariances computed by hccm()
## Coefficient covariances computed by hccm()
## # A tibble: 3 x 9
##   Vignette Effect      DFn   DFd     F     p `p<.05`   ges p.adj
##   <fct>    <chr>     <dbl> <dbl> <dbl> <dbl> <chr>   <dbl> <dbl>
## 1 vign1    condition     1   146  9.92 0.002 "*"     0.064 0.006
## 2 vign2    condition     1   146  1.10 0.296 ""      0.007 0.888
## 3 vign3    condition     1   146  1.64 0.203 ""      0.011 0.609
  ## Pairwise comparisons between conditions
dat %>%
  group_by(Vignette) %>%
  pairwise_t_test(Behaviors ~ condition, p.adjust.method = "bonferroni") # Pairwise comparisons show that the mean Behaviors were significantly different in condition 1 vs condition 2 comparison at vignette 1(p = 0.00199); but not in condition 1 vs condition 2 at vign 2 (p = 0.296) and at vign 3 (p = 0.203).
## # A tibble: 3 x 10
##   Vignette .y.   group1 group2    n1    n2       p p.signif   p.adj p.adj.signif
## * <fct>    <chr> <chr>  <chr>  <int> <int>   <dbl> <chr>      <dbl> <chr>       
## 1 vign1    Beha… Agency Compl…    63    85 0.00199 **       0.00199 **          
## 2 vign2    Beha… Agency Compl…    63    85 0.296   ns       0.296   ns          
## 3 vign3    Beha… Agency Compl…    63    85 0.203   ns       0.203   ns
# Simple Main effects of vignette variable 
  ## Effect of Sabotage at each level of condition
dat %>%
  group_by(condition) %>%
  anova_test(dv = Behaviors, wid = ResponseId, within = Vignette) %>%
  get_anova_table() %>%
  adjust_pvalue(method = "bonferroni") # There was a statistically significant effect of vignette on mean Behaviors for condition 1 (p = 0.008) but not for condition 2 (p = 0.384). 
## # A tibble: 2 x 9
##   condition  Effect     DFn   DFd     F     p `p<.05`   ges p.adj
##   <fct>      <chr>    <dbl> <dbl> <dbl> <dbl> <chr>   <dbl> <dbl>
## 1 Agency     Vignette  1.83  113.  6.05 0.004 "*"     0.031 0.008
## 2 Compliance Vignette  2     168   1.67 0.192 ""      0.003 0.384
  ## Pairwise comparisons between condition at each Sabotage levels - Paired t-test is used because we have repeated measures by Sabotage
dat %>%
  group_by(condition) %>%
  pairwise_t_test(
    Behaviors ~ Vignette, paired = TRUE, 
    p.adjust.method = "bonferroni"
    ) %>%
  dplyr::select(-df, -statistic, -p) ## Using pairwise paired t-test comparisons, it can be seen that for condition 1, the mean Behaviors were statistically significantly different between Sabotage 1 and 2(p = 0.005) but not for the rest of the Sabotage pairs. For condition 2 the means were not significantly different for any of the Sabotage pairs
## # A tibble: 6 x 8
##   condition  .y.       group1 group2    n1    n2 p.adj p.adj.signif
##   <fct>      <chr>     <chr>  <chr>  <int> <int> <dbl> <chr>       
## 1 Agency     Behaviors vign1  vign2     63    63 0.005 **          
## 2 Agency     Behaviors vign1  vign3     63    63 0.138 ns          
## 3 Agency     Behaviors vign2  vign3     63    63 0.477 ns          
## 4 Compliance Behaviors vign1  vign2     85    85 0.543 ns          
## 5 Compliance Behaviors vign1  vign3     85    85 1     ns          
## 6 Compliance Behaviors vign2  vign3     85    85 0.269 ns

Assumptions of ANOVA

Since our DV is a Likert-scale, it is expected that this dataset will violate the assumptions of an ANOVA, since its highly likely that data will not be normally distributed. Below some standard tests were performed to see if our data meets assumptions of two-way ANOVA

# Outlier check
dat %>%
  group_by(condition, Vignette) %>%
  identify_outliers(Behaviors) # Violated. 9 outliers, 2 of them are extreme
## # A tibble: 9 x 6
##   condition  Vignette ResponseId        Behaviors is.outlier is.extreme
##   <fct>      <fct>    <chr>                 <dbl> <lgl>      <lgl>     
## 1 Agency     vign1    R_37wEjP1S43lUXuh         5 TRUE       TRUE      
## 2 Agency     vign1    R_PSUGTrux930fiCd         3 TRUE       FALSE     
## 3 Agency     vign1    R_1cY4g8keLgtfKoz         3 TRUE       FALSE     
## 4 Agency     vign1    R_2ZIBGmC6fnzveHi         3 TRUE       FALSE     
## 5 Agency     vign1    R_3DpVNND6Pfjxol3         3 TRUE       FALSE     
## 6 Agency     vign2    R_2CZAKFPGVkO1ZjA         3 TRUE       FALSE     
## 7 Agency     vign3    R_2CZAKFPGVkO1ZjA         3 TRUE       FALSE     
## 8 Agency     vign3    R_3DpVNND6Pfjxol3         5 TRUE       TRUE      
## 9 Compliance vign3    R_1hG3vlq65rS5MJu         3 TRUE       FALSE
# Normality Check 1: Shapiro-Wilk test
dat %>%
  group_by(condition, Vignette) %>% # if Normal, p-values are greater than 0.05
  shapiro_test(Behaviors) # Violated. All p-values are very low meaning data is non-normal. 
## # A tibble: 6 x 5
##   condition  Vignette variable  statistic        p
##   <fct>      <fct>    <chr>         <dbl>    <dbl>
## 1 Agency     vign1    Behaviors     0.792 4.93e- 8
## 2 Agency     vign2    Behaviors     0.778 2.33e- 8
## 3 Agency     vign3    Behaviors     0.729 1.80e- 9
## 4 Compliance vign1    Behaviors     0.756 1.45e-10
## 5 Compliance vign2    Behaviors     0.738 5.30e-11
## 6 Compliance vign3    Behaviors     0.761 1.97e-10
# Normality Check 2: QQ-Plots (for sample sizes > 50)
dat %>%
  ggqqplot("Behaviors", ggtheme = theme_bw()) +
  facet_grid(condition ~ Vignette) # Violated. Non-normal behavior, since our DV is ordinal  

# Check for Homogeneity of Variance assumption of btn-subject factor (condition), at each within-subject level
dat %>%
  group_by(Vignette) %>%
  levene_test(Behaviors ~ condition) # there is HOV since Levene's p-values>0.05. All have similar variance
## # A tibble: 3 x 5
##   Vignette   df1   df2 statistic     p
##   <fct>    <int> <int>     <dbl> <dbl>
## 1 vign1        1   146   0.314   0.576
## 2 vign2        1   146   0.00456 0.946
## 3 vign3        1   146   0.0920  0.762
dat %>%
  group_by(condition) %>%
  levene_test(Behaviors ~ Vignette) 
## # A tibble: 2 x 5
##   condition    df1   df2 statistic     p
##   <fct>      <int> <int>     <dbl> <dbl>
## 1 Agency         2   186    0.0120 0.988
## 2 Compliance     2   252    0.0874 0.916
# Check for Homogeneity of Covariances of between-subject factor (condition)
box_m(dat[, "Behaviors", drop = FALSE], dat$condition) # Box's M test p < 0.001 so unequal covariances
## # A tibble: 1 x 4
##   statistic   p.value parameter method                                          
##       <dbl>     <dbl>     <dbl> <chr>                                           
## 1      18.4 0.0000180         1 Box's M-test for Homogeneity of Covariance Matr…

Ordinal Logistic Regression 1

To preview the results of this OLR, significant results under the OLR generally match up with the ANOVA findings. Main effect of condition, Sabotage and interaction are all significant, though p-values for condition and Sabotage are less extreme under the OLR analysis, whereas the p-value for interaction effect is more extreme under the OLR.

dat3 <- dat %>%
    mutate_at(vars(Behaviors), factor)

#1 - Main effect of condition
mod1 <- clmm(Behaviors ~ 1 + (1|ResponseId), data = dat3, link = "logit") #mixed cumulative link model
mod2 <- clmm(Behaviors ~ condition + (1|ResponseId), data = dat3, link = "logit")
anova(mod1, mod2) #main effect of condition p = 0.047
## Likelihood ratio tests of cumulative link models:
##  
##      formula:                                 link: threshold:
## mod1 Behaviors ~ 1 + (1 | ResponseId)         logit flexible  
## mod2 Behaviors ~ condition + (1 | ResponseId) logit flexible  
## 
##      no.par    AIC  logLik LR.stat df Pr(>Chisq)  
## mod1      5 744.21 -367.10                        
## mod2      6 742.27 -365.13  3.9429  1    0.04707 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#2 - Main effect of vignette
mod3 <- clmm(Behaviors ~ Vignette + (1|ResponseId), data = dat3, link = "logit")
anova(mod1, mod3) #p = 0.0058
## Likelihood ratio tests of cumulative link models:
##  
##      formula:                                link: threshold:
## mod1 Behaviors ~ 1 + (1 | ResponseId)        logit flexible  
## mod3 Behaviors ~ Vignette + (1 | ResponseId) logit flexible  
## 
##      no.par    AIC  logLik LR.stat df Pr(>Chisq)   
## mod1      5 744.21 -367.10                         
## mod3      7 737.90 -361.95  10.312  2   0.005765 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#3 - interaction effect
mod4 <- clmm(Behaviors ~ condition*Vignette + (1|ResponseId), data = dat3, link = "logit")
anova(mod1, mod4) #p = 0.001
## Likelihood ratio tests of cumulative link models:
##  
##      formula:                                            link: threshold:
## mod1 Behaviors ~ 1 + (1 | ResponseId)                    logit flexible  
## mod4 Behaviors ~ condition * Vignette + (1 | ResponseId) logit flexible  
## 
##      no.par    AIC  logLik LR.stat df Pr(>Chisq)   
## mod1      5 744.21 -367.10                         
## mod4     10 734.29 -357.15  19.919  5   0.001294 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Linear mixed effects regression
lin <- lmer(Behaviors~condition + Vignette + condition*Vignette + (1|ResponseId), data = dat)
anova(lin) #just to confirm ANOVA results = similar findings
## Type III Analysis of Variance Table with Satterthwaite's method
##                    Sum Sq Mean Sq NumDF DenDF F value    Pr(>F)    
## condition          0.9809 0.98093     1   146  4.6700 0.0323250 *  
## Vignette           3.4356 1.71778     2   292  8.1780 0.0003502 ***
## condition:Vignette 1.8230 0.91148     2   292  4.3393 0.0138969 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Secondary Analysis

The primary analysis considered only actual behaviors across condition and sabotage levels. This secondary analysis, on the other hand, will be more comprehensive, considering both actual and deserve behaviors across condition and sabotage levels.

Exploratory Analyses 2

# boxplot of unethical behaviors across all 3 IVs
df <- d %>%
  dplyr::select(ResponseId, condition,
                deserve.sab1, deserve.sab2, deserve.sab3,
                actual.sab1, actual.sab2, actual.sab3) %>%
  pivot_longer(-c("ResponseId", "condition"), names_to = "Key", values_to = "Behaviors") %>% #pivot long then separate
  separate(Key, c("Kind", "Sabotage")) %>% # splits Key into kind and sabotage 
  mutate_at(vars(condition), factor) %>%
  mutate_at(vars(Kind), factor) %>%
  mutate_at(vars(Sabotage), factor) 

df %>% 
  ggplot(aes(x = condition, y = Behaviors,  color = Sabotage)) +
  geom_boxplot() + 
  facet_wrap(~Kind)

# boxplot but binned by within-participant variable Sabotage
df %>%
  ggplot(aes(x = Sabotage, y = Behaviors,  color = condition)) +
  geom_boxplot() +
  facet_wrap(~Kind)

#interaction plot
df %>%
interaction.ABC.plot(x.factor = condition, groups.factor = Sabotage, trace.factor = Kind, 
                        response = Behaviors)

dd2 <- df %>% 
  group_by(condition, Kind, Sabotage) %>%
  summarize(Mean = mean(Behaviors), 
            SE = std(Behaviors)) 
## `summarise()` has grouped output by 'condition', 'Kind'. You can override using the `.groups` argument.
# point-plot with error-bars 
dd2 %>% 
  ggplot(aes(x = condition, y = Mean, group = Sabotage, color = Sabotage)) + 
  geom_point() +
  stat_summary(fun.y = mean, geom = "line") +
  facet_wrap(~Kind) +
  geom_errorbar(aes(ymin = Mean - SE, ymax = Mean + SE), 
                width=0.2,
                position = position_dodge(0.01)) 
## Warning: `fun.y` is deprecated. Use `fun` instead.

std <- function(x) sd(x)/sqrt(length(x))
dodge <- position_dodge(width = 0.9)


# barplot of mean unethical behaviors across condition, kind and sabotage
dd2 %>%
  ggplot(aes(x = interaction(Kind, condition), y = Mean, fill=Sabotage)) +
  geom_bar(position=position_dodge(), stat = "identity") +
  geom_errorbar(aes(ymax = Mean + SE, ymin = Mean - SE), position = dodge, width = 0.2) +
  annotate("text", x = 1:4, y = - 0.05,
           label = rep(c("Actual", "Deserve"), 2)) +
  annotate("text", c(1.5, 3.5), y = -0.2 , label = c("Agency", "Compliance"))  +
  theme(plot.margin = unit(c(1, 1, 4, 1), "lines"),
        axis.title.x = element_blank(),
        axis.text.x = element_blank(),
        text=element_text(size=12,  family="sans")
  )

#all but without geom smooth
df %>%
  ggplot(aes(x = Sabotage, y = Behaviors, group = Kind, color = Kind)) +
  stat_summary(fun.y = mean,
               geom = "pointrange") +  
  stat_summary(fun.y = mean, geom = "line") +
  facet_wrap(~condition) 
## Warning: `fun.y` is deprecated. Use `fun` instead.

## Warning: `fun.y` is deprecated. Use `fun` instead.
## Warning: Removed 6 rows containing missing values (geom_segment).

## Warning: Removed 6 rows containing missing values (geom_segment).

#all with geom smooth
df %>%
  ggplot(aes(x = Sabotage, y = Behaviors, group = Kind, color = Kind)) +
  stat_summary(fun.y = mean,
               geom = "pointrange") +  
  facet_wrap(~condition) +
  stat_summary(fun.y = mean, geom = "line") +
  geom_smooth(method = 'lm', se = FALSE)
## Warning: `fun.y` is deprecated. Use `fun` instead.
## Warning: `fun.y` is deprecated. Use `fun` instead.
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 6 rows containing missing values (geom_segment).
## Warning: Removed 6 rows containing missing values (geom_segment).

#all with geom smooth + error bars (bars too large)
df %>%
  ggplot(aes(x = Sabotage, y = Behaviors, color = Kind, group = Kind)) +
  stat_summary(fun.y = mean,
               fun.ymin = function(x) mean(x) - sd(x), 
               fun.ymax = function(x) mean(x) + sd(x), 
               position = dodge, width = 0.2,
               geom = "pointrange") +  
  stat_summary(fun.y = mean, geom = "line") +
  facet_wrap(~condition) +
  geom_smooth(method = 'lm', se = FALSE)
## Warning: `fun.y` is deprecated. Use `fun` instead.
## Warning: `fun.ymin` is deprecated. Use `fun.min` instead.
## Warning: `fun.ymax` is deprecated. Use `fun.max` instead.
## Warning: Ignoring unknown parameters: width
## Warning: `fun.y` is deprecated. Use `fun` instead.
## `geom_smooth()` using formula 'y ~ x'

Confirmatory Analyses 2

Assumptions of ANOVA

Since our DV is a Likert-scale, it is expected that this dataset will violate the assumptions of an ANOVA, since its highly likely that data will not be normally distributed. Below some standard tests were performed to see if our data meets assumptions of two-way ANOVA

# Outlier check
df %>%
  group_by(condition, Kind, Sabotage) %>%
  identify_outliers(Behaviors) # Violated. 9 outliers, two of which are extreme
## # A tibble: 16 x 7
##    condition  Kind    Sabotage ResponseId        Behaviors is.outlier is.extreme
##    <fct>      <fct>   <fct>    <chr>                 <dbl> <lgl>      <lgl>     
##  1 Agency     actual  sab1     R_37wEjP1S43lUXuh         5 TRUE       TRUE      
##  2 Agency     actual  sab1     R_PSUGTrux930fiCd         3 TRUE       FALSE     
##  3 Agency     actual  sab1     R_1cY4g8keLgtfKoz         3 TRUE       FALSE     
##  4 Agency     actual  sab1     R_2ZIBGmC6fnzveHi         3 TRUE       FALSE     
##  5 Agency     actual  sab1     R_3DpVNND6Pfjxol3         3 TRUE       FALSE     
##  6 Agency     actual  sab2     R_2CZAKFPGVkO1ZjA         3 TRUE       FALSE     
##  7 Agency     actual  sab3     R_2CZAKFPGVkO1ZjA         3 TRUE       FALSE     
##  8 Agency     actual  sab3     R_3DpVNND6Pfjxol3         5 TRUE       TRUE      
##  9 Agency     deserve sab2     R_2Wxpb14An8Ls4K1         3 TRUE       FALSE     
## 10 Agency     deserve sab2     R_2CZAKFPGVkO1ZjA         5 TRUE       TRUE      
## 11 Agency     deserve sab2     R_1DMQ0QOIzRGpCRA         3 TRUE       FALSE     
## 12 Agency     deserve sab2     R_ufetLlUgncHuL73         4 TRUE       FALSE     
## 13 Agency     deserve sab2     R_0kWSbIpgyAcxvy1         3 TRUE       FALSE     
## 14 Agency     deserve sab2     R_3JhkPCq2OAEGwvC         4 TRUE       FALSE     
## 15 Agency     deserve sab2     R_3HZYk0m6UiVTqVm         5 TRUE       TRUE      
## 16 Compliance actual  sab3     R_1hG3vlq65rS5MJu         3 TRUE       FALSE
# Normality Check 1: Shapiro-Wilk test
df %>%
  group_by(condition, Kind, Sabotage) %>% # if Normal, p-values are greater than 0.05
  shapiro_test(Behaviors) # Violated. All p-values are very low meaning data is non-normal. 
## # A tibble: 12 x 6
##    condition  Kind    Sabotage variable  statistic        p
##    <fct>      <fct>   <fct>    <chr>         <dbl>    <dbl>
##  1 Agency     actual  sab1     Behaviors     0.792 4.93e- 8
##  2 Agency     actual  sab2     Behaviors     0.778 2.33e- 8
##  3 Agency     actual  sab3     Behaviors     0.729 1.80e- 9
##  4 Agency     deserve sab1     Behaviors     0.816 2.05e- 7
##  5 Agency     deserve sab2     Behaviors     0.784 3.09e- 8
##  6 Agency     deserve sab3     Behaviors     0.864 5.11e- 6
##  7 Compliance actual  sab1     Behaviors     0.756 1.45e-10
##  8 Compliance actual  sab2     Behaviors     0.738 5.30e-11
##  9 Compliance actual  sab3     Behaviors     0.761 1.97e-10
## 10 Compliance deserve sab1     Behaviors     0.816 6.48e- 9
## 11 Compliance deserve sab2     Behaviors     0.822 9.71e- 9
## 12 Compliance deserve sab3     Behaviors     0.848 7.04e- 8
# Normality Check 2: QQ-Plots (for sample sizes > 50)
df %>%
  ggqqplot("Behaviors", ggtheme = theme_bw()) +
  facet_grid(condition ~ Sabotage) # Violated. Highly non-normal behavior - should be linear

# Check for Homogeneity of Variance assumption of btn-subject factor (condition), at each within-subject level
df %>%
  group_by(Kind, Sabotage) %>%
  levene_test(Behaviors ~ condition) # there is HOV since Levene's p-values>0.05. All groups have similar variance
## # A tibble: 6 x 6
##   Kind    Sabotage   df1   df2 statistic     p
##   <fct>   <fct>    <int> <int>     <dbl> <dbl>
## 1 actual  sab1         1   146   0.314   0.576
## 2 actual  sab2         1   146   0.00456 0.946
## 3 actual  sab3         1   146   0.0920  0.762
## 4 deserve sab1         1   146   0.0255  0.873
## 5 deserve sab2         1   146   0.155   0.695
## 6 deserve sab3         1   146   0.0261  0.872
# Check for Homogeneity of Covariances of between-subject factor (condition)
box_m(dat[, "Behaviors", drop = FALSE], dat$condition) # Box's M test p = 0.09 which is > 0.001 so we have equal covariances
## # A tibble: 1 x 4
##   statistic   p.value parameter method                                          
##       <dbl>     <dbl>     <dbl> <chr>                                           
## 1      18.4 0.0000180         1 Box's M-test for Homogeneity of Covariance Matr…

Three-way Mixed Effects Anova

three.way <- anova_test(
  data = df, dv = Behaviors, wid = ResponseId,
  between = condition, within = c(Kind, Sabotage)
  )
get_anova_table(three.way) # There was a statistically significant main effect of Kind and main effect of Sabotage, and interaction effect of Kind and Sabotage. main effect of condition was non-significant.
## ANOVA Table (type III tests)
## 
##                    Effect  DFn    DFd      F        p p<.05      ges
## 1               condition 1.00 146.00  1.866 1.74e-01       0.007000
## 2                    Kind 1.00 146.00 38.864 4.62e-09     * 0.048000
## 3                Sabotage 2.00 292.00  5.892 3.00e-03     * 0.006000
## 4          condition:Kind 1.00 146.00  0.699 4.05e-01       0.000898
## 5      condition:Sabotage 2.00 292.00  1.656 1.93e-01       0.002000
## 6           Kind:Sabotage 1.85 270.31  6.154 3.00e-03     * 0.003000
## 7 condition:Kind:Sabotage 1.85 270.31  0.951 3.82e-01       0.000497
#============ Post-Hoc Tests =============== ##

# Simple Main Effect of Condition at each Kind and Sabotage level
## Effect of condition at each sabotage and kind level
df %>%
  group_by(Kind, Sabotage) %>%
  anova_test(dv = Behaviors, wid = ResponseId, between = condition) %>%
  get_anova_table() %>%
  adjust_pvalue(method = "bonferroni") # Considering the Bonferroni adjusted p-value, it can be seen that the simple main effect of condition was only significant for sab1 in actual factor (p = 0.012)
## Coefficient covariances computed by hccm()
## Coefficient covariances computed by hccm()
## Coefficient covariances computed by hccm()
## Coefficient covariances computed by hccm()
## Coefficient covariances computed by hccm()
## Coefficient covariances computed by hccm()
## # A tibble: 6 x 10
##   Kind    Sabotage Effect      DFn   DFd     F     p `p<.05`      ges p.adj
##   <fct>   <fct>    <chr>     <dbl> <dbl> <dbl> <dbl> <chr>      <dbl> <dbl>
## 1 actual  sab1     condition     1   146 9.92  0.002 "*"     0.064    0.012
## 2 actual  sab2     condition     1   146 1.10  0.296 ""      0.007    1    
## 3 actual  sab3     condition     1   146 1.64  0.203 ""      0.011    1    
## 4 deserve sab1     condition     1   146 0.776 0.38  ""      0.005    1    
## 5 deserve sab2     condition     1   146 0.138 0.711 ""      0.000942 1    
## 6 deserve sab3     condition     1   146 0.202 0.654 ""      0.001    1
## Pairwise comparisons between condition and kind
df %>%
  group_by(Kind, Sabotage) %>%
  pairwise_t_test(Behaviors ~ condition, p.adjust.method = "bonferroni") # Similarly, pairwise comparisons show that the mean Behaviors were significantly different in condition 1 vs condition 2 comparison only at Sabotage 1(p = 0.00199).
## # A tibble: 6 x 11
##   Kind  Sabotage .y.   group1 group2    n1    n2       p p.signif   p.adj
## * <fct> <fct>    <chr> <chr>  <chr>  <int> <int>   <dbl> <chr>      <dbl>
## 1 actu… sab1     Beha… Agency Compl…    63    85 0.00199 **       0.00199
## 2 actu… sab2     Beha… Agency Compl…    63    85 0.296   ns       0.296  
## 3 actu… sab3     Beha… Agency Compl…    63    85 0.203   ns       0.203  
## 4 dese… sab1     Beha… Agency Compl…    63    85 0.38    ns       0.38   
## 5 dese… sab2     Beha… Agency Compl…    63    85 0.711   ns       0.711  
## 6 dese… sab3     Beha… Agency Compl…    63    85 0.654   ns       0.654  
## # … with 1 more variable: p.adj.signif <chr>
### Simple Main effects of Sabotage variable 
# Effect of Sabotage at each level of each factor
df %>%
  group_by(Kind, condition) %>%
  anova_test(dv = Behaviors, wid = ResponseId, within = Sabotage) %>%
  get_anova_table() %>%
  adjust_pvalue(method = "bonferroni") # There was a statistically significant effect of Sabotage on mean Behaviors for actual factor in condition 1 (p = 0.016)
## # A tibble: 4 x 10
##   condition  Kind    Effect     DFn   DFd     F     p `p<.05`   ges p.adj
##   <fct>      <fct>   <chr>    <dbl> <dbl> <dbl> <dbl> <chr>   <dbl> <dbl>
## 1 Agency     actual  Sabotage  1.83  113.  6.05 0.004 "*"     0.031 0.016
## 2 Compliance actual  Sabotage  2     168   1.67 0.192 ""      0.003 0.768
## 3 Agency     deserve Sabotage  2     124   2.12 0.124 ""      0.008 0.496
## 4 Compliance deserve Sabotage  2     168   3.22 0.043 "*"     0.008 0.172
# Pairwise comparisons between condition at each Kind and sabotage levels 
df %>%
  group_by(Kind, condition) %>%
  pairwise_t_test(
    Behaviors ~ Sabotage, paired = TRUE, 
    p.adjust.method = "bonferroni"
    ) %>%
  dplyr::select(-df, -statistic, -p) #removes details ## Using pairwise paired t-test comparisons, it can be seen that the mean Behaviors were only statistically significantly different between Sabotage 1 and 2(p = 0.005) in condition 1, actual factor
## # A tibble: 12 x 9
##    condition  Kind    .y.       group1 group2    n1    n2 p.adj p.adj.signif
##    <fct>      <fct>   <chr>     <chr>  <chr>  <int> <int> <dbl> <chr>       
##  1 Agency     actual  Behaviors sab1   sab2      63    63 0.005 **          
##  2 Agency     actual  Behaviors sab1   sab3      63    63 0.138 ns          
##  3 Agency     actual  Behaviors sab2   sab3      63    63 0.477 ns          
##  4 Compliance actual  Behaviors sab1   sab2      85    85 0.543 ns          
##  5 Compliance actual  Behaviors sab1   sab3      85    85 1     ns          
##  6 Compliance actual  Behaviors sab2   sab3      85    85 0.269 ns          
##  7 Agency     deserve Behaviors sab1   sab2      63    63 0.963 ns          
##  8 Agency     deserve Behaviors sab1   sab3      63    63 0.987 ns          
##  9 Agency     deserve Behaviors sab2   sab3      63    63 0.085 ns          
## 10 Compliance deserve Behaviors sab1   sab2      85    85 1     ns          
## 11 Compliance deserve Behaviors sab1   sab3      85    85 0.195 ns          
## 12 Compliance deserve Behaviors sab2   sab3      85    85 0.056 ns

Ordinal Logistic Regression 2

dat4 <- df %>%
    mutate_at(vars(Behaviors), factor)

#1 - Main effect of condition
mod1b <- clmm(Behaviors ~ 1 + (1|ResponseId), data = dat4, link = "logit") #mixed cumulative link model
mod2b <- clmm(Behaviors ~ condition + (1|ResponseId), data = dat4, link = "logit")
anova(mod1b, mod2b) #main effect of condition p = 0.04
## Likelihood ratio tests of cumulative link models:
##  
##       formula:                                 link: threshold:
## mod1b Behaviors ~ 1 + (1 | ResponseId)         logit flexible  
## mod2b Behaviors ~ condition + (1 | ResponseId) logit flexible  
## 
##       no.par    AIC  logLik LR.stat df Pr(>Chisq)
## mod1b      6 1887.8 -937.91                      
## mod2b      7 1887.7 -936.83  2.1582  1     0.1418
#2 - Main effect of Sabotage
mod3b <- clmm(Behaviors ~ Sabotage + (1|ResponseId), data = dat4, link = "logit")
anova(mod1b, mod3b) #p = 0.0058
## Likelihood ratio tests of cumulative link models:
##  
##       formula:                                link: threshold:
## mod1b Behaviors ~ 1 + (1 | ResponseId)        logit flexible  
## mod3b Behaviors ~ Sabotage + (1 | ResponseId) logit flexible  
## 
##       no.par    AIC  logLik LR.stat df Pr(>Chisq)   
## mod1b      6 1887.8 -937.91                         
## mod3b      8 1881.5 -932.76  10.308  2   0.005775 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#3 - Main effect of Kind
mod4b <- clmm(Behaviors ~ Kind + (1|ResponseId), data = dat4, link = "logit")
anova(mod1b, mod4b) #p = 0.0058
## Likelihood ratio tests of cumulative link models:
##  
##       formula:                            link: threshold:
## mod1b Behaviors ~ 1 + (1 | ResponseId)    logit flexible  
## mod4b Behaviors ~ Kind + (1 | ResponseId) logit flexible  
## 
##       no.par    AIC  logLik LR.stat df Pr(>Chisq)    
## mod1b      6 1887.8 -937.91                          
## mod4b      7 1809.0 -897.52  80.784  1  < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#4 - interaction effect
mod5b <- clmm(Behaviors ~ condition*Sabotage + (1|ResponseId), data = dat4, link = "logit")
anova(mod1b, mod5b) #p = 0.001
## Likelihood ratio tests of cumulative link models:
##  
##       formula:                                            link: threshold:
## mod1b Behaviors ~ 1 + (1 | ResponseId)                    logit flexible  
## mod5b Behaviors ~ condition * Sabotage + (1 | ResponseId) logit flexible  
## 
##       no.par    AIC  logLik LR.stat df Pr(>Chisq)  
## mod1b      6 1887.8 -937.91                        
## mod5b     11 1882.8 -930.39   15.04  5    0.01019 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# linear mixed effects regression
linb <- lmer(Behaviors~condition + Kind + Sabotage + condition*Sabotage + condition*Kind + Kind*Sabotage + condition*Kind*Sabotage + (1|ResponseId), data = df)
anova(linb) #ran linear just to see if similar results to ANOVA > mostly similar
## Type III Analysis of Variance Table with Satterthwaite's method
##                         Sum Sq Mean Sq NumDF DenDF F value    Pr(>F)    
## condition                0.938   0.938     1   146  1.8663  0.174004    
## Kind                    43.196  43.196     1   730 85.9085 < 2.2e-16 ***
## Sabotage                 5.602   2.801     2   730  5.5704  0.003973 ** 
## condition:Sabotage       1.575   0.787     2   730  1.5659  0.209611    
## condition:Kind           0.777   0.777     1   730  1.5450  0.214274    
## Kind:Sabotage            2.781   1.390     2   730  2.7653  0.063614 .  
## condition:Kind:Sabotage  0.430   0.215     2   730  0.4271  0.652532    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1