#install and load required packages
options(repos = c(CRAN = "https://cran.rstudio.com"))
install.packages("tidyverse")
##
## The downloaded binary packages are in
## /var/folders/p9/jsgk53613jn647r1ccjz2xh80000gn/T//RtmpexPCOM/downloaded_packages
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.1 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
#mean(my_data$age)
install.packages("qualtRics")
##
## The downloaded binary packages are in
## /var/folders/p9/jsgk53613jn647r1ccjz2xh80000gn/T//RtmpexPCOM/downloaded_packages
install.packages("ggplot2")
##
## The downloaded binary packages are in
## /var/folders/p9/jsgk53613jn647r1ccjz2xh80000gn/T//RtmpexPCOM/downloaded_packages
library(qualtRics)
library(ggplot2)
install.packages("dplyr")
##
## The downloaded binary packages are in
## /var/folders/p9/jsgk53613jn647r1ccjz2xh80000gn/T//RtmpexPCOM/downloaded_packages
#read in the data
my_data = read.csv("/Users/amberzettle/Downloads/temptation + context fixed.csv")
#delete all data before the official start time of the study: 16:42
my_data = tail(my_data, -34)
#select columns for context and no-context data
context_data = select(my_data,TakeRes.C._DV,Ignoring.C._DV, Playbook.C._DV, Theft.C._DV)
nocontext_data = select(my_data,TakeRes.NC._DV,Ignoring.NC._DV,Playbook.NC._DV,Theft.NC._DV)
#create a new dataframe called both_data which includes both context and no-context variables in addition to Response ID
both_data = select(my_data,ResponseId,TakeRes.C._DV,Ignoring.C._DV, Playbook.C._DV, Theft.C._DV,TakeRes.NC._DV,Ignoring.NC._DV,Playbook.NC._DV,Theft.NC._DV)
#change dataframe from a wide format to a long format to more easily analyze the data, remove the rows where the values are empty, and create two new columns: condition (which indicates if the variable is from the "C" or "NC" condition) and scenario (which has the first five characters of the variable name)
bothLong = both_data %>%
pivot_longer(TakeRes.C._DV:Theft.NC._DV) %>%
filter(!(value=="")) %>%
mutate(condition = ifelse(str_detect(name,"NC"),"NC","C"),
scenario = substr(name,1,5)) %>%
select(-name)
#main finding: we used regression, we predict moral ratings as a function of condition (context or no context)-- we analyzed our data with regression: dependent was rating, independent was condition
#linear regression looking at just condition
summary(lm(value ~ condition, data = bothLong))
##
## Call:
## lm(formula = value ~ condition, data = bothLong)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.5263 -0.5263 0.0426 0.4737 3.0426
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.04261 0.06392 -0.667 0.505
## conditionNC 0.56892 0.09040 6.293 5.13e-10 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.277 on 796 degrees of freedom
## Multiple R-squared: 0.0474, Adjusted R-squared: 0.0462
## F-statistic: 39.61 on 1 and 796 DF, p-value: 5.125e-10
#making a graph for the mean value by condition
df = as.data.frame(bothLong)
df$value <- as.numeric(df$value)
summary_stats <- df %>%
filter(!is.na(value)) %>% # Exclude rows with NA in 'value'
group_by(condition) %>%
summarise(
mean = mean(value),
sem = sd(value) / sqrt(n()),
ci_lower = mean - 1.96 * sem,
ci_upper = mean + 1.96 * sem
)
ggplot(summary_stats, aes(x = condition, y = mean, fill = condition)) +
geom_bar(stat = "identity", color = "black", alpha = 0.8) +
geom_errorbar(aes(ymin = ci_lower, ymax = ci_upper), width = 0.2) +
labs(
title = "Mean Value by Condition with 95% Confidence Intervals",
x = "Condition",
y = "Mean Value"
) +
theme_minimal() +
scale_fill_viridis_d(option = "viridis") +
theme(legend.position = "none")

#linear regression looking at condition and scenario
summary(lm(value ~ condition+scenario, data = bothLong))
##
## Call:
## lm(formula = value ~ condition + scenario, data = bothLong)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.5745 -0.5553 0.0100 0.5000 3.0966
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.09656 0.09905 -0.975 0.330
## conditionNC 0.56531 0.09095 6.216 8.24e-10 ***
## scenarioPlayb 0.03130 0.12815 0.244 0.807
## scenarioTakeR 0.08652 0.12786 0.677 0.499
## scenarioTheft 0.10573 0.12857 0.822 0.411
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.279 on 793 degrees of freedom
## Multiple R-squared: 0.04844, Adjusted R-squared: 0.04364
## F-statistic: 10.09 on 4 and 793 DF, p-value: 5.687e-08
#select the demographic information and join it
demos = select(my_data,ResponseId,age,gender,ethnicity,political,religion.affiliation,SES)
#organized SES ranges into three categories and ethnicity into two
demos = select(my_data,ResponseId,age,gender,ethnicity,political,religion.affiliation,SES) %>%
mutate(SEScat = case_when(SES>=14 & SES < 18 ~ "low",
SES>=18 & SES<22 ~ "mid",
SES >= 22 ~ "high"),
ethnicitycat = ifelse(ethnicity %in% c("White", "white","Caucasian", "caucasian"),"White","NonWhite"))
#adding demographic data into larger data set
both_data = left_join(bothLong,demos)
## Joining with `by = join_by(ResponseId)`
##Regressions to look at interaction effects with gender, political, ethnicity, and SES
#gender (1 = male, 2 = female, 3 = non-binary)
summary(lm(value ~ condition * as.factor(gender), data = both_data))
##
## Call:
## lm(formula = value ~ condition * as.factor(gender), data = both_data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.5260 -0.5260 -0.0733 0.5152 3.1242
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.1242 0.1024 -1.212 0.22581
## conditionNC 0.6502 0.1446 4.495 8e-06 ***
## as.factor(gender)2 0.1975 0.1320 1.496 0.13500
## as.factor(gender)3 -0.9472 0.3538 -2.677 0.00758 **
## conditionNC:as.factor(gender)2 -0.2386 0.1865 -1.279 0.20126
## conditionNC:as.factor(gender)3 1.6356 0.5003 3.269 0.00113 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.267 on 792 degrees of freedom
## Multiple R-squared: 0.06647, Adjusted R-squared: 0.06057
## F-statistic: 11.28 on 5 and 792 DF, p-value: 1.597e-10
#look at political orientation to see if there are interactions/main effects
summary(lm(value ~ condition * as.numeric(political), data = both_data))
##
## Call:
## lm(formula = value ~ condition * as.numeric(political), data = both_data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.5589 -0.5449 -0.0353 0.4691 3.1500
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.19631 0.13037 -1.506 0.133
## conditionNC 0.76924 0.18465 4.166 3.44e-05 ***
## as.numeric(political) 0.04632 0.03424 1.353 0.177
## conditionNC:as.numeric(political) -0.06034 0.04847 -1.245 0.214
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.277 on 794 degrees of freedom
## Multiple R-squared: 0.04979, Adjusted R-squared: 0.0462
## F-statistic: 13.87 on 3 and 794 DF, p-value: 8.044e-09
summary(lm(value ~ condition + as.numeric(political), data = both_data))
##
## Call:
## lm(formula = value ~ condition + as.numeric(political), data = both_data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.5859 -0.5372 0.0154 0.4911 3.0802
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.09638 0.10276 -0.938 0.349
## conditionNC 0.56880 0.09043 6.290 5.24e-10 ***
## as.numeric(political) 0.01621 0.02424 0.668 0.504
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.277 on 795 degrees of freedom
## Multiple R-squared: 0.04793, Adjusted R-squared: 0.04554
## F-statistic: 20.01 on 2 and 795 DF, p-value: 3.312e-09
#look at interaction effects with ethnicity
summary(lm(value ~ condition * as.factor(ethnicity), data = both_data))
##
## Call:
## lm(formula = value ~ condition * as.factor(ethnicity), data = both_data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.5370 -0.5000 0.0000 0.4907 3.1667
##
## Coefficients:
## Estimate
## (Intercept) -2.097e-13
## conditionNC 3.616e-13
## as.factor(ethnicity)african american -2.500e+00
## as.factor(ethnicity)African American 2.143e-13
## as.factor(ethnicity)African-American 5.000e-01
## as.factor(ethnicity)Afro-American 2.181e-13
## as.factor(ethnicity)american -1.000e+00
## as.factor(ethnicity)American 2.001e-13
## as.factor(ethnicity)American white 1.500e+00
## as.factor(ethnicity)asian -1.500e+00
## as.factor(ethnicity)Asian -3.000e-01
## as.factor(ethnicity)Asian American -1.250e-01
## as.factor(ethnicity)Biracial, asian-caucasian -5.000e-01
## as.factor(ethnicity)Biriacial 2.078e-13
## as.factor(ethnicity)black -8.750e-01
## as.factor(ethnicity)Black 5.000e-01
## as.factor(ethnicity)Black 2.500e-01
## as.factor(ethnicity)Black and White -1.000e+00
## as.factor(ethnicity)Black or African American 3.000e+00
## as.factor(ethnicity)Black/African American 5.000e-01
## as.factor(ethnicity)caucasian -1.667e-01
## as.factor(ethnicity)Caucasian -1.429e-01
## as.factor(ethnicity)Caucasian -2.500e-01
## as.factor(ethnicity)Caucasian/Cherokee Indian 2.252e-13
## as.factor(ethnicity)Caucasian/White 2.133e-13
## as.factor(ethnicity)chicano -1.500e+00
## as.factor(ethnicity)Chinese American -5.000e-01
## as.factor(ethnicity)filipino 2.120e-13
## as.factor(ethnicity)hispanic -3.000e+00
## as.factor(ethnicity)Hispanic 1.667e-01
## as.factor(ethnicity)Hispanic, latino -5.000e-01
## as.factor(ethnicity)hispanic/white 5.000e-01
## as.factor(ethnicity)Indian 1.000e+00
## as.factor(ethnicity)Irish -5.000e-01
## as.factor(ethnicity)Korean 2.078e-13
## as.factor(ethnicity)Latina/white/north african 2.182e-13
## as.factor(ethnicity)latino 3.333e-01
## as.factor(ethnicity)Latino -1.000e+00
## as.factor(ethnicity)mexican -1.000e+00
## as.factor(ethnicity)mixed- white and asian 2.159e-13
## as.factor(ethnicity)mixed/multi -1.500e+00
## as.factor(ethnicity)multiracial 1.000e+00
## as.factor(ethnicity)Multiracial 1.000e+00
## as.factor(ethnicity)N/A 5.000e-01
## as.factor(ethnicity)Native American 5.000e-01
## as.factor(ethnicity)Native American -5.000e-01
## as.factor(ethnicity)Pakistani 2.160e-13
## as.factor(ethnicity)white 6.481e-02
## as.factor(ethnicity)White -3.261e-02
## as.factor(ethnicity)WHITE 3.000e+00
## as.factor(ethnicity)white 3.000e+00
## as.factor(ethnicity)White 1.500e+00
## as.factor(ethnicity)white - american 2.202e-13
## as.factor(ethnicity)White (USA) -1.000e+00
## as.factor(ethnicity)white mixed latina -5.000e-01
## as.factor(ethnicity)White/Caucasian 2.244e-13
## as.factor(ethnicity)White/Hispanic -1.000e+00
## conditionNC:as.factor(ethnicity)african american -3.616e-13
## conditionNC:as.factor(ethnicity)African American 8.333e-02
## conditionNC:as.factor(ethnicity)African-American -3.652e-13
## conditionNC:as.factor(ethnicity)Afro-American -3.706e-13
## conditionNC:as.factor(ethnicity)american 1.000e+00
## conditionNC:as.factor(ethnicity)American -3.613e-13
## conditionNC:as.factor(ethnicity)American white -3.639e-13
## conditionNC:as.factor(ethnicity)asian 3.250e+00
## conditionNC:as.factor(ethnicity)Asian 8.000e-01
## conditionNC:as.factor(ethnicity)Asian American 3.750e-01
## conditionNC:as.factor(ethnicity)Biracial, asian-caucasian 1.500e+00
## conditionNC:as.factor(ethnicity)Biriacial -3.636e-13
## conditionNC:as.factor(ethnicity)black 1.625e+00
## conditionNC:as.factor(ethnicity)Black -7.143e-02
## conditionNC:as.factor(ethnicity)Black -3.625e-13
## conditionNC:as.factor(ethnicity)Black and White 4.000e+00
## conditionNC:as.factor(ethnicity)Black or African American -5.000e-01
## conditionNC:as.factor(ethnicity)Black/African American 1.500e+00
## conditionNC:as.factor(ethnicity)caucasian 1.667e-01
## conditionNC:as.factor(ethnicity)Caucasian 7.857e-01
## conditionNC:as.factor(ethnicity)Caucasian 2.500e-01
## conditionNC:as.factor(ethnicity)Caucasian/Cherokee Indian 1.000e+00
## conditionNC:as.factor(ethnicity)Caucasian/White -3.638e-13
## conditionNC:as.factor(ethnicity)chicano 4.500e+00
## conditionNC:as.factor(ethnicity)Chinese American -1.000e+00
## conditionNC:as.factor(ethnicity)filipino -3.580e-13
## conditionNC:as.factor(ethnicity)hispanic 6.000e+00
## conditionNC:as.factor(ethnicity)Hispanic 1.500e+00
## conditionNC:as.factor(ethnicity)Hispanic, latino 1.500e+00
## conditionNC:as.factor(ethnicity)hispanic/white 5.000e-01
## conditionNC:as.factor(ethnicity)Indian 5.000e-01
## conditionNC:as.factor(ethnicity)Irish 5.000e-01
## conditionNC:as.factor(ethnicity)Korean -3.565e-13
## conditionNC:as.factor(ethnicity)Latina/white/north african 5.000e-01
## conditionNC:as.factor(ethnicity)latino 1.667e-01
## conditionNC:as.factor(ethnicity)Latino 2.000e+00
## conditionNC:as.factor(ethnicity)mexican -2.000e+00
## conditionNC:as.factor(ethnicity)mixed- white and asian 1.000e+00
## conditionNC:as.factor(ethnicity)mixed/multi 5.000e-01
## conditionNC:as.factor(ethnicity)multiracial -5.000e-01
## conditionNC:as.factor(ethnicity)Multiracial -1.000e+00
## conditionNC:as.factor(ethnicity)N/A 1.500e+00
## conditionNC:as.factor(ethnicity)Native American 2.500e-01
## conditionNC:as.factor(ethnicity)Native American 5.000e-01
## conditionNC:as.factor(ethnicity)Pakistani -3.713e-13
## conditionNC:as.factor(ethnicity)white 4.722e-01
## conditionNC:as.factor(ethnicity)White 4.722e-01
## conditionNC:as.factor(ethnicity)WHITE -3.634e-13
## conditionNC:as.factor(ethnicity)white -3.646e-13
## conditionNC:as.factor(ethnicity)White -3.636e-13
## conditionNC:as.factor(ethnicity)white - american -3.706e-13
## conditionNC:as.factor(ethnicity)White (USA) 1.000e+00
## conditionNC:as.factor(ethnicity)white mixed latina 2.000e+00
## conditionNC:as.factor(ethnicity)White/Caucasian 5.000e-01
## conditionNC:as.factor(ethnicity)White/Hispanic 1.000e+00
## Std. Error t value
## (Intercept) 8.317e-01 0.000
## conditionNC 1.176e+00 0.000
## as.factor(ethnicity)african american 1.176e+00 -2.126
## as.factor(ethnicity)African American 8.983e-01 0.000
## as.factor(ethnicity)African-American 1.176e+00 0.425
## as.factor(ethnicity)Afro-American 1.176e+00 0.000
## as.factor(ethnicity)american 1.176e+00 -0.850
## as.factor(ethnicity)American 1.019e+00 0.000
## as.factor(ethnicity)American white 1.176e+00 1.275
## as.factor(ethnicity)asian 1.019e+00 -1.473
## as.factor(ethnicity)Asian 8.723e-01 -0.344
## as.factor(ethnicity)Asian American 9.298e-01 -0.134
## as.factor(ethnicity)Biracial, asian-caucasian 1.176e+00 -0.425
## as.factor(ethnicity)Biriacial 1.176e+00 0.000
## as.factor(ethnicity)black 9.298e-01 -0.941
## as.factor(ethnicity)Black 8.891e-01 0.562
## as.factor(ethnicity)Black 1.019e+00 0.245
## as.factor(ethnicity)Black and White 1.176e+00 -0.850
## as.factor(ethnicity)Black or African American 1.176e+00 2.551
## as.factor(ethnicity)Black/African American 1.176e+00 0.425
## as.factor(ethnicity)caucasian 9.603e-01 -0.174
## as.factor(ethnicity)Caucasian 8.891e-01 -0.161
## as.factor(ethnicity)Caucasian 1.019e+00 -0.245
## as.factor(ethnicity)Caucasian/Cherokee Indian 1.176e+00 0.000
## as.factor(ethnicity)Caucasian/White 1.176e+00 0.000
## as.factor(ethnicity)chicano 1.176e+00 -1.275
## as.factor(ethnicity)Chinese American 1.176e+00 -0.425
## as.factor(ethnicity)filipino 1.176e+00 0.000
## as.factor(ethnicity)hispanic 1.176e+00 -2.551
## as.factor(ethnicity)Hispanic 9.603e-01 0.174
## as.factor(ethnicity)Hispanic, latino 1.176e+00 -0.425
## as.factor(ethnicity)hispanic/white 1.176e+00 0.425
## as.factor(ethnicity)Indian 1.176e+00 0.850
## as.factor(ethnicity)Irish 1.176e+00 -0.425
## as.factor(ethnicity)Korean 1.176e+00 0.000
## as.factor(ethnicity)Latina/white/north african 1.176e+00 0.000
## as.factor(ethnicity)latino 1.074e+00 0.310
## as.factor(ethnicity)Latino 1.176e+00 -0.850
## as.factor(ethnicity)mexican 1.176e+00 -0.850
## as.factor(ethnicity)mixed- white and asian 1.176e+00 0.000
## as.factor(ethnicity)mixed/multi 1.176e+00 -1.275
## as.factor(ethnicity)multiracial 1.176e+00 0.850
## as.factor(ethnicity)Multiracial 1.176e+00 0.850
## as.factor(ethnicity)N/A 1.176e+00 0.425
## as.factor(ethnicity)Native American 1.019e+00 0.491
## as.factor(ethnicity)Native American 1.176e+00 -0.425
## as.factor(ethnicity)Pakistani 1.176e+00 0.000
## as.factor(ethnicity)white 8.393e-01 0.077
## as.factor(ethnicity)White 8.407e-01 -0.039
## as.factor(ethnicity)WHITE 1.176e+00 2.551
## as.factor(ethnicity)white 1.176e+00 2.551
## as.factor(ethnicity)White 1.176e+00 1.275
## as.factor(ethnicity)white - american 1.176e+00 0.000
## as.factor(ethnicity)White (USA) 1.176e+00 -0.850
## as.factor(ethnicity)white mixed latina 1.176e+00 -0.425
## as.factor(ethnicity)White/Caucasian 1.176e+00 0.000
## as.factor(ethnicity)White/Hispanic 1.176e+00 -0.850
## conditionNC:as.factor(ethnicity)african american 1.663e+00 0.000
## conditionNC:as.factor(ethnicity)African American 1.270e+00 0.066
## conditionNC:as.factor(ethnicity)African-American 1.663e+00 0.000
## conditionNC:as.factor(ethnicity)Afro-American 1.663e+00 0.000
## conditionNC:as.factor(ethnicity)american 1.663e+00 0.601
## conditionNC:as.factor(ethnicity)American 1.441e+00 0.000
## conditionNC:as.factor(ethnicity)American white 1.663e+00 0.000
## conditionNC:as.factor(ethnicity)asian 1.441e+00 2.256
## conditionNC:as.factor(ethnicity)Asian 1.234e+00 0.649
## conditionNC:as.factor(ethnicity)Asian American 1.315e+00 0.285
## conditionNC:as.factor(ethnicity)Biracial, asian-caucasian 1.663e+00 0.902
## conditionNC:as.factor(ethnicity)Biriacial 1.663e+00 0.000
## conditionNC:as.factor(ethnicity)black 1.315e+00 1.236
## conditionNC:as.factor(ethnicity)Black 1.257e+00 -0.057
## conditionNC:as.factor(ethnicity)Black 1.441e+00 0.000
## conditionNC:as.factor(ethnicity)Black and White 1.663e+00 2.405
## conditionNC:as.factor(ethnicity)Black or African American 1.663e+00 -0.301
## conditionNC:as.factor(ethnicity)Black/African American 1.663e+00 0.902
## conditionNC:as.factor(ethnicity)caucasian 1.358e+00 0.123
## conditionNC:as.factor(ethnicity)Caucasian 1.257e+00 0.625
## conditionNC:as.factor(ethnicity)Caucasian 1.441e+00 0.174
## conditionNC:as.factor(ethnicity)Caucasian/Cherokee Indian 1.663e+00 0.601
## conditionNC:as.factor(ethnicity)Caucasian/White 1.663e+00 0.000
## conditionNC:as.factor(ethnicity)chicano 1.663e+00 2.705
## conditionNC:as.factor(ethnicity)Chinese American 1.663e+00 -0.601
## conditionNC:as.factor(ethnicity)filipino 1.663e+00 0.000
## conditionNC:as.factor(ethnicity)hispanic 1.663e+00 3.607
## conditionNC:as.factor(ethnicity)Hispanic 1.358e+00 1.104
## conditionNC:as.factor(ethnicity)Hispanic, latino 1.663e+00 0.902
## conditionNC:as.factor(ethnicity)hispanic/white 1.663e+00 0.301
## conditionNC:as.factor(ethnicity)Indian 1.663e+00 0.301
## conditionNC:as.factor(ethnicity)Irish 1.663e+00 0.301
## conditionNC:as.factor(ethnicity)Korean 1.663e+00 0.000
## conditionNC:as.factor(ethnicity)Latina/white/north african 1.663e+00 0.301
## conditionNC:as.factor(ethnicity)latino 1.480e+00 0.113
## conditionNC:as.factor(ethnicity)Latino 1.663e+00 1.202
## conditionNC:as.factor(ethnicity)mexican 1.663e+00 -1.202
## conditionNC:as.factor(ethnicity)mixed- white and asian 1.663e+00 0.601
## conditionNC:as.factor(ethnicity)mixed/multi 1.663e+00 0.301
## conditionNC:as.factor(ethnicity)multiracial 1.663e+00 -0.301
## conditionNC:as.factor(ethnicity)Multiracial 1.663e+00 -0.601
## conditionNC:as.factor(ethnicity)N/A 1.663e+00 0.902
## conditionNC:as.factor(ethnicity)Native American 1.441e+00 0.174
## conditionNC:as.factor(ethnicity)Native American 1.663e+00 0.301
## conditionNC:as.factor(ethnicity)Pakistani 1.663e+00 0.000
## conditionNC:as.factor(ethnicity)white 1.187e+00 0.398
## conditionNC:as.factor(ethnicity)White 1.189e+00 0.397
## conditionNC:as.factor(ethnicity)WHITE 1.663e+00 0.000
## conditionNC:as.factor(ethnicity)white 1.663e+00 0.000
## conditionNC:as.factor(ethnicity)White 1.663e+00 0.000
## conditionNC:as.factor(ethnicity)white - american 1.663e+00 0.000
## conditionNC:as.factor(ethnicity)White (USA) 1.663e+00 0.601
## conditionNC:as.factor(ethnicity)white mixed latina 1.663e+00 1.202
## conditionNC:as.factor(ethnicity)White/Caucasian 1.663e+00 0.301
## conditionNC:as.factor(ethnicity)White/Hispanic 1.663e+00 0.601
## Pr(>|t|)
## (Intercept) 1.000000
## conditionNC 1.000000
## as.factor(ethnicity)african american 0.033906 *
## as.factor(ethnicity)African American 1.000000
## as.factor(ethnicity)African-American 0.670893
## as.factor(ethnicity)Afro-American 1.000000
## as.factor(ethnicity)american 0.395507
## as.factor(ethnicity)American 1.000000
## as.factor(ethnicity)American white 0.202635
## as.factor(ethnicity)asian 0.141323
## as.factor(ethnicity)Asian 0.731007
## as.factor(ethnicity)Asian American 0.893102
## as.factor(ethnicity)Biracial, asian-caucasian 0.670893
## as.factor(ethnicity)Biriacial 1.000000
## as.factor(ethnicity)black 0.347034
## as.factor(ethnicity)Black 0.574054
## as.factor(ethnicity)Black 0.806193
## as.factor(ethnicity)Black and White 0.395507
## as.factor(ethnicity)Black or African American 0.010973 *
## as.factor(ethnicity)Black/African American 0.670893
## as.factor(ethnicity)caucasian 0.862271
## as.factor(ethnicity)Caucasian 0.872397
## as.factor(ethnicity)Caucasian 0.806193
## as.factor(ethnicity)Caucasian/Cherokee Indian 1.000000
## as.factor(ethnicity)Caucasian/White 1.000000
## as.factor(ethnicity)chicano 0.202635
## as.factor(ethnicity)Chinese American 0.670893
## as.factor(ethnicity)filipino 1.000000
## as.factor(ethnicity)hispanic 0.010973 *
## as.factor(ethnicity)Hispanic 0.862271
## as.factor(ethnicity)Hispanic, latino 0.670893
## as.factor(ethnicity)hispanic/white 0.670893
## as.factor(ethnicity)Indian 0.395507
## as.factor(ethnicity)Irish 0.670893
## as.factor(ethnicity)Korean 1.000000
## as.factor(ethnicity)Latina/white/north african 1.000000
## as.factor(ethnicity)latino 0.756311
## as.factor(ethnicity)Latino 0.395507
## as.factor(ethnicity)mexican 0.395507
## as.factor(ethnicity)mixed- white and asian 1.000000
## as.factor(ethnicity)mixed/multi 0.202635
## as.factor(ethnicity)multiracial 0.395507
## as.factor(ethnicity)Multiracial 0.395507
## as.factor(ethnicity)N/A 0.670893
## as.factor(ethnicity)Native American 0.623676
## as.factor(ethnicity)Native American 0.670893
## as.factor(ethnicity)Pakistani 1.000000
## as.factor(ethnicity)white 0.938471
## as.factor(ethnicity)White 0.969070
## as.factor(ethnicity)WHITE 0.010973 *
## as.factor(ethnicity)white 0.010973 *
## as.factor(ethnicity)White 0.202635
## as.factor(ethnicity)white - american 1.000000
## as.factor(ethnicity)White (USA) 0.395507
## as.factor(ethnicity)white mixed latina 0.670893
## as.factor(ethnicity)White/Caucasian 1.000000
## as.factor(ethnicity)White/Hispanic 0.395507
## conditionNC:as.factor(ethnicity)african american 1.000000
## conditionNC:as.factor(ethnicity)African American 0.947719
## conditionNC:as.factor(ethnicity)African-American 1.000000
## conditionNC:as.factor(ethnicity)Afro-American 1.000000
## conditionNC:as.factor(ethnicity)american 0.547913
## conditionNC:as.factor(ethnicity)American 1.000000
## conditionNC:as.factor(ethnicity)American white 1.000000
## conditionNC:as.factor(ethnicity)asian 0.024383 *
## conditionNC:as.factor(ethnicity)Asian 0.516870
## conditionNC:as.factor(ethnicity)Asian American 0.775600
## conditionNC:as.factor(ethnicity)Biracial, asian-caucasian 0.367491
## conditionNC:as.factor(ethnicity)Biriacial 1.000000
## conditionNC:as.factor(ethnicity)black 0.216986
## conditionNC:as.factor(ethnicity)Black 0.954715
## conditionNC:as.factor(ethnicity)Black 1.000000
## conditionNC:as.factor(ethnicity)Black and White 0.016452 *
## conditionNC:as.factor(ethnicity)Black or African American 0.763815
## conditionNC:as.factor(ethnicity)Black/African American 0.367491
## conditionNC:as.factor(ethnicity)caucasian 0.902367
## conditionNC:as.factor(ethnicity)Caucasian 0.532260
## conditionNC:as.factor(ethnicity)Caucasian 0.862271
## conditionNC:as.factor(ethnicity)Caucasian/Cherokee Indian 0.547913
## conditionNC:as.factor(ethnicity)Caucasian/White 1.000000
## conditionNC:as.factor(ethnicity)chicano 0.006996 **
## conditionNC:as.factor(ethnicity)Chinese American 0.547913
## conditionNC:as.factor(ethnicity)filipino 1.000000
## conditionNC:as.factor(ethnicity)hispanic 0.000333 ***
## conditionNC:as.factor(ethnicity)Hispanic 0.269787
## conditionNC:as.factor(ethnicity)Hispanic, latino 0.367491
## conditionNC:as.factor(ethnicity)hispanic/white 0.763815
## conditionNC:as.factor(ethnicity)Indian 0.763815
## conditionNC:as.factor(ethnicity)Irish 0.763815
## conditionNC:as.factor(ethnicity)Korean 1.000000
## conditionNC:as.factor(ethnicity)Latina/white/north african 0.763815
## conditionNC:as.factor(ethnicity)latino 0.910370
## conditionNC:as.factor(ethnicity)Latino 0.229637
## conditionNC:as.factor(ethnicity)mexican 0.229637
## conditionNC:as.factor(ethnicity)mixed- white and asian 0.547913
## conditionNC:as.factor(ethnicity)mixed/multi 0.763815
## conditionNC:as.factor(ethnicity)multiracial 0.763815
## conditionNC:as.factor(ethnicity)Multiracial 0.547913
## conditionNC:as.factor(ethnicity)N/A 0.367491
## conditionNC:as.factor(ethnicity)Native American 0.862271
## conditionNC:as.factor(ethnicity)Native American 0.763815
## conditionNC:as.factor(ethnicity)Pakistani 1.000000
## conditionNC:as.factor(ethnicity)white 0.690886
## conditionNC:as.factor(ethnicity)White 0.691398
## conditionNC:as.factor(ethnicity)WHITE 1.000000
## conditionNC:as.factor(ethnicity)white 1.000000
## conditionNC:as.factor(ethnicity)White 1.000000
## conditionNC:as.factor(ethnicity)white - american 1.000000
## conditionNC:as.factor(ethnicity)White (USA) 0.547913
## conditionNC:as.factor(ethnicity)white mixed latina 0.229637
## conditionNC:as.factor(ethnicity)White/Caucasian 0.763815
## conditionNC:as.factor(ethnicity)White/Hispanic 0.547913
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.176 on 670 degrees of freedom
## (16 observations deleted due to missingness)
## Multiple R-squared: 0.2932, Adjusted R-squared: 0.1761
## F-statistic: 2.504 on 111 and 670 DF, p-value: 8.529e-13
summary(lm(value ~ condition * as.factor(ethnicitycat), data = both_data))
##
## Call:
## lm(formula = value ~ condition * as.factor(ethnicitycat), data = both_data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.5722 -0.5722 -0.0045 0.5114 3.1006
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.10056 0.09549 -1.053 0.293
## conditionNC 0.67278 0.13486 4.989 7.46e-07
## as.factor(ethnicitycat)White 0.10510 0.12860 0.817 0.414
## conditionNC:as.factor(ethnicitycat)White -0.18874 0.18182 -1.038 0.300
##
## (Intercept)
## conditionNC ***
## as.factor(ethnicitycat)White
## conditionNC:as.factor(ethnicitycat)White
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.278 on 794 degrees of freedom
## Multiple R-squared: 0.04871, Adjusted R-squared: 0.04511
## F-statistic: 13.55 on 3 and 794 DF, p-value: 1.251e-08
#look at SES to see if there are interactions/main effects
summary(lm(value ~ condition * as.factor(SEScat), data = both_data))
##
## Call:
## lm(formula = value ~ condition * as.factor(SEScat), data = both_data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.6735 -0.4788 -0.0482 0.5212 3.1753
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.04819 0.09875 0.488 0.62567
## conditionNC 0.43060 0.13987 3.079 0.00215 **
## as.factor(SEScat)low -0.22345 0.16261 -1.374 0.16978
## as.factor(SEScat)mid -0.06334 0.14838 -0.427 0.66956
## conditionNC:as.factor(SEScat)low 0.41813 0.22972 1.820 0.06911 .
## conditionNC:as.factor(SEScat)mid 0.04668 0.20998 0.222 0.82414
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.272 on 784 degrees of freedom
## (8 observations deleted due to missingness)
## Multiple R-squared: 0.04924, Adjusted R-squared: 0.04317
## F-statistic: 8.12 on 5 and 784 DF, p-value: 1.749e-07
anova(lm(value ~ condition * as.factor(SEScat), data = both_data))
## Analysis of Variance Table
##
## Response: value
## Df Sum Sq Mean Sq F value Pr(>F)
## condition 1 59.61 59.606 36.8212 2.014e-09 ***
## as.factor(SEScat) 2 0.24 0.120 0.0740 0.9287
## condition:as.factor(SEScat) 2 5.88 2.940 1.8159 0.1634
## Residuals 784 1269.14 1.619
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(lm(value ~ condition + as.factor(SEScat), data = both_data))
##
## Call:
## lm(formula = value ~ condition + as.factor(SEScat), data = both_data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.5384 -0.5384 0.0110 0.4754 3.0512
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.01103 0.08332 -0.132 0.895
## conditionNC 0.54940 0.09063 6.062 2.08e-09 ***
## as.factor(SEScat)low -0.01380 0.11498 -0.120 0.905
## as.factor(SEScat)mid -0.04018 0.10510 -0.382 0.702
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.274 on 786 degrees of freedom
## (8 observations deleted due to missingness)
## Multiple R-squared: 0.04483, Adjusted R-squared: 0.04119
## F-statistic: 12.3 on 3 and 786 DF, p-value: 7.217e-08
#look at the structure of the data
str(my_data)
## 'data.frame': 202 obs. of 62 variables:
## $ StartDate : chr "2024-11-13 14:44:47" "2024-11-13 14:50:03" "2024-11-13 14:50:35" "2024-11-13 14:51:23" ...
## $ EndDate : chr "2024-11-13 14:50:04" "2024-11-13 14:50:14" "2024-11-13 14:55:31" "2024-11-13 14:56:32" ...
## $ Status : chr "0" "0" "0" "0" ...
## $ IPAddress : chr "24.0.111.241" "172.56.78.229" "71.59.253.68" "100.36.192.56" ...
## $ Progress : chr "100" "100" "100" "100" ...
## $ Duration..in.seconds. : chr "316" "10" "296" "309" ...
## $ Finished : chr "1" "1" "1" "1" ...
## $ RecordedDate : chr "2024-11-13 14:50:04" "2024-11-13 14:50:15" "2024-11-13 14:55:32" "2024-11-13 14:56:33" ...
## $ ResponseId : chr "R_5JL6I1Hbo6317Uf" "R_6m7Oycz3p5OaQIF" "R_5d0cVKflukLJCsF" "R_7hWN2TFf0qAlXov" ...
## $ RecipientLastName : chr "" "" "" "" ...
## $ RecipientFirstName : chr "" "" "" "" ...
## $ RecipientEmail : chr "" "" "" "" ...
## $ ExternalReference : chr "" "" "" "" ...
## $ LocationLatitude : chr "39.9242" "28.5788" "45.6435" "38.6438" ...
## $ LocationLongitude : chr "-75.0193" "-81.4396" "-122.6247" "-77.3451" ...
## $ DistributionChannel : chr "anonymous" "anonymous" "anonymous" "anonymous" ...
## $ UserLanguage : chr "EN" "EN" "EN" "EN" ...
## $ consent : chr "1" "" "1" "1" ...
## $ TakeRes.C._DV : chr "" "" "" "" ...
## $ TakeRes.C._free : chr "" "" "" "" ...
## $ Ignoring.C._DV : chr "-2" "" "-1" "0" ...
## $ Ignoring.C._free : chr "madeline sacrificed time for her own tasks while clara did not" "" "Both chose to help, but Clara gave up part of her busy day to do so." "I don't think morality can be construed from a simple workplace decision." ...
## $ Playbook.NC._DV : chr "" "" "" "0" ...
## $ Playbook.NC._free : chr "" "" "" "ultimately the came to same decision, so same morality" ...
## $ Theft.NC._DV : chr "0" "" "0" "" ...
## $ Theft.NC._free : chr "Don't know enough about why sara was tempted and kenna was not. " "" "Both ultimately made the right moral choice" "" ...
## $ Playbook.C._DV : chr "-2" "" "0" "" ...
## $ Playbook.C._free : chr "anthony had no stakes while Carl had a lot to gain" "" "Ultimately, they both chose not to cheat" "" ...
## $ Ignoring.NC._DV : chr "" "" "" "" ...
## $ Ignoring.NC._free : chr "" "" "" "" ...
## $ Theft.C._DV : chr "" "" "" "0" ...
## $ Theft.C._free : chr "" "" "" "again came to the same decision so equally moral" ...
## $ TakeRes.NC._DV : chr "0" "" "0" "0" ...
## $ TakeRes.NC._free : chr "don't know enough about reasons behind tempted/not tempted to make judgement call" "" "Both did the right thing in the end" "whether you wrestle with the decision or not when you come to the same conclusion the morality is the same" ...
## $ Ratings_immorality_1 : chr "3" "" "3" "2" ...
## $ Ratings_immorality_2 : chr "2" "" "1" "1" ...
## $ Ratings_immorality_3 : chr "3" "" "3" "2" ...
## $ Ratings_immorality_4 : chr "4" "" "4" "3" ...
## $ attention : chr "3" "" "3" "3" ...
## $ age : chr "42" "" "50" "44" ...
## $ gender : chr "2" "" "1" "1" ...
## $ gender_4_TEXT : chr "" "" "" "" ...
## $ ethnicity : chr "white" "" "Irish" "White" ...
## $ political : chr "1" "" "5" "3" ...
## $ religion.affiliation : chr "4" "" "4" "6" ...
## $ religion.affiliation_7_TEXT: chr "" "" "" "" ...
## $ SES : chr "22" "" "25" "25" ...
## $ takingresponsibility : chr "nocontext" "" "nocontext" "nocontext" ...
## $ ignoring : chr "context" "" "context" "context" ...
## $ playbook : chr "context" "" "context" "nocontext" ...
## $ theft : chr "nocontext" "" "nocontext" "context" ...
## $ PROLIFIC_PID : chr "662ec419662b0b0cdb0366dd" "66f33be2bc0c71ae9547b7bb" "670d71af070434dddcf04dd1" "6365593d8f35fcb8f68d982a" ...
## $ STUDY_ID : chr "6734fe7dd108913c528337d6" "6734fe7dd108913c528337d6" "6734fe7dd108913c528337d6" "6734fe7dd108913c528337d6" ...
## $ SESSION_ID : chr "67351dc49c8560c2d3e58e61" "67351ecf98123fde8b38af43" "67351f13b2ed29745239ac55" "67351f4702692f8b3439527d" ...
## $ takingresponsibility_name1 : chr "Liam" "Liam" "Benjamin" "Benjamin" ...
## $ takingresponsibility_name2 : chr "Benjamin" "Benjamin" "Liam" "Liam" ...
## $ ignoring_name1 : chr "Madeline" "Madeline" "Clara" "Madeline" ...
## $ ignoring_name2 : chr "Clara" "Clara" "Madeline" "Clara" ...
## $ playbook_name1 : chr "Carl" "Anthony" "Anthony" "Carl" ...
## $ playbook_name2 : chr "Anthony" "Carl" "Carl" "Anthony" ...
## $ theft_name1 : chr "Sara" "Sara" "Sara" "Sara" ...
## $ theft_name2 : chr "Kenna" "Kenna" "Kenna" "Kenna" ...
###IMMORALITY EXPLORATORY ANALYSIS###
#getting data ready to work with
demos = select(my_data,ResponseId,age,gender,ethnicity,political,religion.affiliation,SES, Ratings_immorality_1, Ratings_immorality_2, Ratings_immorality_3, Ratings_immorality_4)
both_data = left_join(bothLong,demos)
## Joining with `by = join_by(ResponseId)`
#turning numeric
both_data$Ratings_immorality_1 <- as.numeric(both_data$Ratings_immorality_1)
both_data$Ratings_immorality_2 <- as.numeric(both_data$Ratings_immorality_2)
both_data$Ratings_immorality_3 <- as.numeric(both_data$Ratings_immorality_3)
both_data$Ratings_immorality_4 <- as.numeric(both_data$Ratings_immorality_4)
#making new 'targetRating' variable with
both_data$targetRating <- case_when(both_data$scenario == 'Ignor' ~ both_data$Ratings_immorality_2,
both_data$scenario == 'TakeR' ~ both_data$Ratings_immorality_1,
both_data$scenario == 'Playb' ~ both_data$Ratings_immorality_3,
both_data$scenario == 'Theft' ~ both_data$Ratings_immorality_4)
#do ratings of immorality + condition predict individuals ratings?
both_data$cond = as.factor(both_data$condition)
mod = lm(value ~ targetRating*cond, data = both_data)
summary(mod)
##
## Call:
## lm(formula = value ~ targetRating * cond, data = both_data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.6988 -0.5380 0.0005 0.4620 3.0936
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.09265 0.20052 0.462 0.6442
## targetRating -0.04656 0.06545 -0.711 0.4770
## condNC -0.03717 0.28415 -0.131 0.8960
## targetRating:condNC 0.20741 0.09241 2.244 0.0251 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.273 on 794 degrees of freedom
## Multiple R-squared: 0.05523, Adjusted R-squared: 0.05166
## F-statistic: 15.47 on 3 and 794 DF, p-value: 8.632e-10
#suggesting that ratings of immorality did not matter overall
#HOWEVER, there was an interaction effect suggesting that it only predicts for NC condition but not the C condition
##when you are in the context condition, it doesn't really seem like it really matters how immoral people rated a specific scenario
##however, when you are in the no context condition, there is a positive relationship (those individual ratings matter more when there is no context)
#plotting interaction
sjPlot::plot_model(mod,type='int', title = "Temptation", axis.title = c("Rating of Immorality", "Tempted/Non-Tempted Individual"), legend.title = "Condition")

###T-TESTS###
#nocontext
nocontext <- bothLong[bothLong$condition == "NC", ]
nocontext$value <- as.numeric(nocontext$value)
t.test(nocontext$value) #p-value is significant
##
## One Sample t-test
##
## data: nocontext$value
## t = 8.552, df = 398, p-value = 2.637e-16
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
## 0.4053253 0.6473062
## sample estimates:
## mean of x
## 0.5263158
#the mean is positive (positive values correspond to individuals rating the non-tempted agent as more moral)
#context -- one sample t test comparing context ratings to 0
context <- bothLong[bothLong$condition == "C", ]
context$value <- as.numeric(context$value)
t.test(context$value) #p-value is not significant (mean of context$value is not significantly different from 0 which corresponds to the statement "[tempted agent] and [non-tempted agent] are equally moral")
##
## One Sample t-test
##
## data: context$value
## t = -0.64345, df = 398, p-value = 0.5203
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
## -0.17278326 0.08757023
## sample estimates:
## mean of x
## -0.04260652
#comparing nocontext to context
t.test(as.numeric(bothLong$value) ~ bothLong$condition) #significant p-value
##
## Welch Two Sample t-test
##
## data: as.numeric(bothLong$value) by bothLong$condition
## t = -6.2934, df = 791.77, p-value = 5.139e-10
## alternative hypothesis: true difference in means between group C and group NC is not equal to 0
## 95 percent confidence interval:
## -0.7463739 -0.3914707
## sample estimates:
## mean in group C mean in group NC
## -0.04260652 0.52631579
#doing a similar analysis but this time using a regression
summary(lm(value ~ condition, data = bothLong)) #in the no context condition, the coefficient was positive (rated the non-tempted individual as more moral) they rated individuals equal in the context condition (indicated by the insignificant intercept coefficient)
##
## Call:
## lm(formula = value ~ condition, data = bothLong)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.5263 -0.5263 0.0426 0.4737 3.0426
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.04261 0.06392 -0.667 0.505
## conditionNC 0.56892 0.09040 6.293 5.13e-10 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.277 on 796 degrees of freedom
## Multiple R-squared: 0.0474, Adjusted R-squared: 0.0462
## F-statistic: 39.61 on 1 and 796 DF, p-value: 5.125e-10
#the intercept basically represents condition C and it has a coefficient that is negative but small (and that is insignificant)
# non-tempted person rated higher in no-context condition #
# context condition is 0, does not replicate McManus #
# different scenarios do not matter #