Install libraries, upload data

library(tidyverse)
## ── Attaching packages ───────────────
## ✔ ggplot2 3.1.1     ✔ purrr   0.3.0
## ✔ tibble  2.1.3     ✔ dplyr   0.8.1
## ✔ tidyr   0.8.2     ✔ stringr 1.4.0
## ✔ readr   1.3.1     ✔ forcats 0.3.0
## ── Conflicts ────────────────────────
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(umx) #For Cronbach Alpha calculation
## Loading required package: OpenMx
## To take full advantage of multiple cores, use:
##   mxOption(NULL, 'Number of Threads', parallel::detectCores()) #now
##   Sys.setenv(OMP_NUM_THREADS=parallel::detectCores()) #before library(OpenMx)
## For an overview type '?umx'
## 
## Attaching package: 'umx'
## The following object is masked from 'package:stats':
## 
##     loadings
library(lmerTest) #For analyses using lmer
## Loading required package: lme4
## Loading required package: Matrix
## 
## Attaching package: 'Matrix'
## The following objects are masked from 'package:OpenMx':
## 
##     %&%, expm
## The following object is masked from 'package:tidyr':
## 
##     expand
## 
## Attaching package: 'lmerTest'
## The following object is masked from 'package:lme4':
## 
##     lmer
## The following object is masked from 'package:stats':
## 
##     step
library(emmeans) #For posthoc analyses
library(scales) #For rescaling y axis for AVI demographics plots
## 
## Attaching package: 'scales'
## The following object is masked from 'package:purrr':
## 
##     discard
## The following object is masked from 'package:readr':
## 
##     col_factor
#Load data so far (update as you collect more data)
Part1 <- read.csv("~/Dropbox/Lab Projects/Reputation Study/Data/Payment/2019.08.09 - Part 1 Data.csv")
Part2 <- read.csv("~/Dropbox/Lab Projects/Reputation Study/Data/Check Sample Size/2019.08.05 - Data So Far.csv")
#Set theme
theme_set(
  theme_classic() + # set the theme
    theme(text = element_text(size = 16)) 
)

Prepare both datasets so we can merge Part 1 and Part 2 based on pID/WelcomeCdoe.

#Before joining datasets, remove white spaces in case the extra space prevents participants from matching 
Part2$WelcomeCode <- gsub(" ", "", Part2$WelcomeCode) #Remove white spaces in WelcomeCode column (some participants added a space after the code which made it not match with the Part 1 pID)
Part1$email <- gsub(" ", "", Part1$email) #Remove white spaces in Part 1 email column just in case
Part2$Email <- gsub(" ", "", Part2$Email) #Remove white spaces in Part 2 email column just in case

#Note: Participants with pID "k3m2k7twob" and "fllt58q3s15" did not include email but this pID matched with no one's in Part 2, so they must not have completed Part 2
Part1 <- Part1[!(Part1$pID=="k3m2k7twob" | Part1$pID=="fllt58q3s15"),]

#Note: Participant with pID "ypv8o66vtx" did not include email either but matched with email "joshlevine12@comcast.net" in Part 2, so we'll include his email into Part 1 data as well:
Part1$email <- as.character(Part1$email) #Convert emails to character in order to perform operation below
Part1$email[Part1$pID == "ypv8o66vtx"] <- "joshlevine12@comcast.net"

#Note: Participant with pID "t3swzuuwhbp" entered that same code as his email in Part 1 so I must replace Part 1 email with the actual email he provided in Part 2:
Part1$email[Part1$email == "t3swzuuwhbp"] <- Part2$Email[Part2$WelcomeCode == "t3swzuuwhbp"]

#Someone wrote "I do not have one. My regular email is Jackcat00@aol.com" so I will replace that with just his email so that we can match emails in Part 2. His pID was "6o17usgpyei6".
Part1$email[Part1$pID == "6o17usgpyei6"] <- "Jackcat00@aol.com"

#Extract two separate pID for each duplicate, and take out second copy
#Part 1
Duplicate1 <- Part1$pID[Part1$email == "mstrang@wisc.edu"][2]
Duplicate2 <- Part1$pID[Part1$email == "a.swartz@ufl.edu"][2]
Duplicate3 <- Part1$pID[Part1$email == "jrtravagline@gmail.com"][2]
Duplicate4 <- Part1$pID[Part1$email == "houcka@oregonstate.edu"][2]
Part1 <- Part1[!(Part1$pID == Duplicate1 | Part1$pID == Duplicate2 | Part1$pID == Duplicate3 | Part1$pID == Duplicate4) ,] #Take them out
#Part 1
Duplicate1 <- Part2$WelcomeCode[Part2$Email == "houcka@oregonstate.edu"][2]
Part2 <- Part2[!(Part2$WelcomeCode == Duplicate1) ,] #Take them out

Now, join participants’ Part 1 and Part 2 data, and call this joined dataframe “Data”

#Turn pID and WelcomeCode into characters
Part1$pID <- as.character(Part1$pID)
Part2$WelcomeCode <- as.character(Part2$WelcomeCode)

#Leftjoin
Data <- left_join(Part1, Part2, by = c("pID" = "WelcomeCode")) #Combine Part1 & Part2 by pID/WelcomeCode

Remove participants who are over 30 years old

Data$Age <- as.numeric(as.character(Data$Age)) #Make Age numeric
Data <- Data %>% 
  filter(Age <= 30)

Set factor levels

#Gender
Data$Gender <- factor(Data$Gender,
                           levels = c(1,2),
                           labels = c("Male", "Female"))

#Education
Data$Education <- factor(Data$Education,
                              levels = c(1,2,3,4,5,6,7,8,9),
                              labels = c("Less than high school", "High School/GED", "Some college (not currently enrolled)", "Some college (currently enrolled)", "Associates degree", "BA/BS degree", "Master's Degree", "Doctoral Degree", "Professional Degree"))

#SES
Data$FamSES2 <- factor(Data$FamSES2,
                        levels = c(1,2,3,4,5,6,7,8),
                        labels = c("<10K", "10-20K", "20-30K", "30-40K", "40-50K", "50-75K","75-100K",">100K"))

#Set order for graphs
Data$reputation <- factor(Data$reputation, levels = c("low", "mod", "high"))
Data$expression <- factor(Data$expression, levels = c("neut", "calm", "exci"))

Test for outliers based on the standard discussed in lab meeting (i.e., exclude anything outside of boxplot (for the DV, in this case amount given, or “response”)).

boxplot(Data$response) #No outliers to remove

Create filtering variable so I can easily exclude and include participants who had no variation in the Trust Game (gave a fixed amount the whole time):

Data <- Data %>% 
  group_by(pID) %>% #Do below by participant
  mutate(responseSD = sd(response, na.rm = T)) %>% #First calculate each participants' SD in amount given
  mutate(responseNoVar = ifelse(responseSD==0, 1, 0)) #If SD for all trials was 0, make the responseNoVar equal to 1. If not 0, then make it equal to 0 

table(Data$responseNoVar)/72 #Count how many participants had no variation in trust game (under the heading "1")
## 
##  0  1 
## 81  6
#See what these no variation amounts were
Data %>% 
  filter(responseNoVar==1 & trial_num == 1) %>% #Filter for people who gave same amount and just select one trial out of 72 since they're all the same
  unique() %>% 
  summarize(response)
## # A tibble: 6 x 2
##   pID          response
##   <chr>           <int>
## 1 0m6kq8tbb8mp       10
## 2 1sv9s4ko8o9i        5
## 3 2mivlx9sx17        10
## 4 9tpuiq3jo39        10
## 5 m0ce8ox9id          3
## 6 ql9isp4x0hl        10

Find out who has done a study like this before and what they thought the purpose of the study was

# If participants answered "Yes" to "Have you ever done a study similar to this one?" see what they described this similar study as:
DidBefore <- Data %>% 
  group_by(pID, DidBefore, DidBefore_text) %>% 
  filter(DidBefore==1) %>% 
  dplyr::select(DidBefore_text) %>% 
  distinct()
## Adding missing grouping variables: `pID`, `DidBefore`
#See what people wrote when asked, "What do you think was the purpose of this study?"
Purpose <- Data %>% 
  filter(!is.na(Purpose_text)) %>% 
  dplyr::select(Purpose_text) %>% 
  distinct()
## Adding missing grouping variables: `pID`
#See what people wrote when asked, "Did you encounter any technical problems?"
TechProb <- Data %>% 
  filter(!is.na(TechProb_text)) %>% 
  dplyr::select(TechProb_text) %>% 
  distinct()
## Adding missing grouping variables: `pID`

Compute ideal and actual affect scores from AVI

# i1_1 enthusiastic
# i1_7 excited
# i1_9 elated
# i2_9 euphoric

# i1_6 relaxed
# i3_3 calm
# i3_9 peaceful
# i3_10 serene

# Compute actual and ideal affect scores
Data <- Data %>% 
  mutate_at(vars(a1_1:i4_9), list(~ as.numeric(as.character(.)))) %>% #Turn affect variables from factor to numeric
  group_by(pID) %>% 
  rowwise() %>% 
  mutate(aHAP = mean(c(a1_1, a1_7, a1_9, a2_9), na.rm = T), 
         aLAP = mean(c(a1_6, a3_3, a3_9, a3_10), na.rm = T),
         iHAP = mean(c(i1_1, i1_7, i1_9, i2_9), na.rm = T), 
         iLAP = mean(c(i1_6, i3_3, i3_9, i3_10), na.rm = T))

#Ipsatize actual and ideal (separately)
Ipsatized_Actual <- Data %>% 
  dplyr::select(pID, a1_1:a4_9) %>% #Only select actual affect variables
  ungroup() %>% 
  mutate(aSD = apply(.[,2:ncol(.)], na.rm = T, 1, sd)) %>% #Compute rowwise SD
  mutate(aMean = rowMeans(dplyr::select(., contains("_")), na.rm = T)) %>% #Compute rowwise means
  mutate(a_enthus_i = (a1_1 - aMean)/aSD, #Ipsatize enthusiastic
         a_excited_i = (a1_7 - aMean)/aSD, #Ipsatize excited
         a_elated_i = (a1_9 - aMean)/aSD, #Ipsatize elated
         a_euphoric_i = (a2_9 - aMean)/aSD, #Ipsatize euphoric
         a_relaxed_i = (a1_6 - aMean)/aSD, #Ipsatize relaxed
         a_calm_i = (a3_3 - aMean)/aSD, #Ipsatize calm
         a_peaceful_i = (a3_9 - aMean)/aSD, #Ipsatize peaceful
         a_serene_i = (a3_10 - aMean)/aSD) %>% #Ipsatize serene
  rowwise %>% 
  mutate(aHAP_i = mean(c(a_enthus_i, a_excited_i, a_elated_i, a_euphoric_i), na.rm = T), #Compute ipsatized HAP
         aLAP_i = mean(c(a_relaxed_i, a_calm_i, a_peaceful_i, a_serene_i), na.rm = T)) %>% #Compute ipsatized LAP
  dplyr::select(pID, aHAP_i, aLAP_i) %>% #Keep only the ipsatized HAP and LAP scores
  distinct()

Ipsatized_Ideal <- Data %>% 
  dplyr::select(pID, i1_1:i4_9) %>% #Only select ideal affect variables
  ungroup() %>% 
  mutate(iSD = apply(.[,2:ncol(.)], na.rm = T, 1, sd)) %>% #Compute rowwise SD
  mutate(iMean = rowMeans(dplyr::select(., contains("_")), na.rm = T)) %>% #Compute rowwise means
  mutate(i_enthus_i = (i1_1 - iMean)/iSD, #Ipsatize enthusiastic
         i_excited_i = (i1_7 - iMean)/iSD, #Ipsatize excited
         i_elated_i = (i1_9 - iMean)/iSD, #Ipsatize elated
         i_euphoric_i = (i2_9 - iMean)/iSD, #Ipsatize euphoric
         i_relaxed_i = (i1_6 - iMean)/iSD, #Ipsatize relaxed
         i_calm_i = (i3_3 - iMean)/iSD, #Ipsatize calm
         i_peaceful_i = (i3_9 - iMean)/iSD, #Ipsatize peaceful
         i_serene_i = (i3_10 - iMean)/iSD) %>% #Ipsatize serene
  rowwise %>% 
  mutate(iHAP_i = mean(c(i_enthus_i, i_excited_i, i_elated_i, i_euphoric_i), na.rm = T), #Compute ipsatized HAP
         iLAP_i = mean(c(i_relaxed_i, i_calm_i, i_peaceful_i, i_serene_i), na.rm = T)) %>% #Compute ipsatized LAP
  dplyr::select(pID, iHAP_i, iLAP_i) %>%  #Keep only the ipsatized HAP and LAP scores
  distinct()

Data <- left_join(Data, Ipsatized_Actual, by = "pID") #Add ipsatized actual affect scores to original dataframe
Data <- left_join(Data, Ipsatized_Ideal, by = "pID") #Add ipsatized ideal affect scores to original dataframe

Demographics

#Create dataframe with just demographics vars (so that each participant doesn't get duplicated 72 times for each trial)
Demographics <- Data %>% 
  dplyr::select(pID, Age, Gender, Education, FamSES1, FamSES2, SelfSES1, SelfSES2, iHAP, iLAP, iHAP_i, iLAP_i, aHAP, aLAP) %>% 
  distinct()

#Age
Demographics %>%
  ungroup() %>% 
  summarize(Age_Mean = mean(Age, na.rm = T),
            Age_SD = sd(Age, na.rm = T))
## # A tibble: 1 x 2
##   Age_Mean Age_SD
##      <dbl>  <dbl>
## 1     24.9   3.46
#Gender
Demographics %>%
  ungroup() %>% 
  count(Gender)
## Warning: Factor `Gender` contains implicit NA, consider using
## `forcats::fct_explicit_na`
## # A tibble: 3 x 2
##   Gender     n
##   <fct>  <int>
## 1 Male      25
## 2 Female    58
## 3 <NA>       4
#Education
Demographics %>%
  ungroup() %>% 
  count(Education)
## # A tibble: 6 x 2
##   Education                                 n
##   <fct>                                 <int>
## 1 High School/GED                           2
## 2 Some college (not currently enrolled)     9
## 3 Some college (currently enrolled)        17
## 4 Associates degree                         3
## 5 BA/BS degree                             38
## 6 Master's Degree                          18
#Plot
ggplot(Demographics, aes(x = Education)) +
  geom_bar() +
  xlab("Education")

#SES
Demographics %>%
  ungroup() %>% 
  count(FamSES2)
## Warning: Factor `FamSES2` contains implicit NA, consider using
## `forcats::fct_explicit_na`
## # A tibble: 8 x 2
##   FamSES2     n
##   <fct>   <int>
## 1 <10K        1
## 2 20-30K      3
## 3 30-40K      4
## 4 40-50K      8
## 5 50-75K     18
## 6 75-100K    20
## 7 >100K      32
## 8 <NA>        1
#Plot
ggplot(Demographics, aes(x = FamSES2)) +
  geom_bar() +
  xlab("SES")

#AVI
Demographics %>%
  ungroup() %>% 
  summarize(iHAP_Mean = mean(iHAP, na.rm = T),
            iHAP_SD = sd(iHAP, na.rm = T),
            iLAP_Mean = mean(iLAP, na.rm = T),
            iLAP_SD = sd(iLAP, na.rm = T),
            iHAPi_Mean = mean(iHAP_i, na.rm = T),
            iHAPi_SD = sd(iHAP_i, na.rm = T),
            iLAPi_Mean = mean(iLAP_i, na.rm = T),
            iLAPi_SD = sd(iLAP_i, na.rm = T),
            aHAP_Mean = mean(aHAP, na.rm = T),
            aHAP_SD = sd(aHAP, na.rm = T),
            aLAP_Mean = mean(aLAP, na.rm = T),
            aLAP_SD = sd(aLAP, na.rm = T))
## # A tibble: 1 x 12
##   iHAP_Mean iHAP_SD iLAP_Mean iLAP_SD iHAPi_Mean iHAPi_SD iLAPi_Mean
##       <dbl>   <dbl>     <dbl>   <dbl>      <dbl>    <dbl>      <dbl>
## 1      3.34   0.793      3.96   0.795      0.636    0.382       1.09
## # … with 5 more variables: iLAPi_SD <dbl>, aHAP_Mean <dbl>, aHAP_SD <dbl>,
## #   aLAP_Mean <dbl>, aLAP_SD <dbl>
#To create a bar graph, I have to tidy up the dataframe so that iHAP, iLAP, iHAP_i, iLAP_i, aHAP and aLAP (which are currently individual columns) are now rows under IdealAffect, IpsatizedIdealAffect, and ActualAffect, respectively:
TidyAVI <- Data %>% 
  gather('iHAP', 'iLAP', key = "IdealAffect", value = "Valuation") %>% 
  gather('iHAP_i', 'iLAP_i', key = "IpsatizedIdealAffect", value = "Valuation_i") %>% 
  gather('aHAP', 'aLAP', key = "ActualAffect", value = "Reported") 

#Ideal affect (not ipsatized)
ggplot(TidyAVI, aes(x = IdealAffect, y = Valuation)) +
  geom_bar(position="dodge", stat = "summary", fun.y = "mean", fill="light grey") +
  stat_summary(geom = "errorbar", fun.data = mean_se, position=position_dodge(.9), width = 0.5) +
  scale_y_continuous(limits=c(1,5),oob = rescale_none) +
  theme(text = element_text(size=20, family="serif")) +
  xlab("Ideal Affect")

#Ideal affect (ipsatized)
ggplot(TidyAVI, aes(x = IpsatizedIdealAffect, y = Valuation_i)) +
  geom_bar(position="dodge", stat = "summary", fun.y = "mean", fill="light grey") +
  stat_summary(geom = "errorbar", fun.data = mean_se, position=position_dodge(.9), width = 0.5) +
  theme(text = element_text(size=20, family="serif")) +
  xlab("Ideal Affect (Ipsatized)")
## Warning: Removed 576 rows containing non-finite values (stat_summary).
## Warning: Removed 576 rows containing non-finite values (stat_summary).

#Actual affect
ggplot(TidyAVI, aes(x = ActualAffect, y = Reported)) +
  geom_bar(position="dodge", stat = "summary", fun.y = "mean", fill="light grey") +
  stat_summary(geom = "errorbar", fun.data = mean_se, position=position_dodge(.9), width = 0.5) +
  scale_y_continuous(limits=c(1,5),oob = rescale_none) +
  theme(text = element_text(size=20, family="serif")) +
  xlab("Actual Affect")

Compute Cronbach’s alpha to make sure ideal and actual affect items hang together

#Actual HAP
aHAP_alpha <- Data %>% 
  dplyr::select(a1_1, a1_7, a1_9, a2_9) %>%  
  drop_na()
Alpha <- reliability(cov(data.matrix(aHAP_alpha))) #Convert to matrix and calculate alpha
Alpha$alpha #Output just alpha
##     alpha 
## 0.8259208
#Actual LAP
aLAP_alpha <- Data %>% 
  dplyr::select(a1_6, a3_3, a3_9, a3_10) %>%  
  drop_na()
Alpha <- reliability(cov(data.matrix(aLAP_alpha))) #Convert to matrix and calculate alpha
Alpha$alpha #Output just alpha
##     alpha 
## 0.8339752
#Ideal HAP
iHAP_alpha <- Data %>% 
  dplyr::select(i1_1, i1_7, i1_9, i2_9) %>%  
  drop_na()
Alpha <- reliability(cov(data.matrix(iHAP_alpha))) #Convert to matrix and calculate alpha
Alpha$alpha #Output just alpha
##     alpha 
## 0.7781464
#Ideal LAP
iLAP_alpha <- Data %>% 
  dplyr::select(i1_6, i3_3, i3_9, i3_10) %>%  
  drop_na()
Alpha <- reliability(cov(data.matrix(iLAP_alpha))) #Convert to matrix and calculate alpha
Alpha$alpha #Output just alpha
##  alpha 
## 0.8261

ANALYZE: Confirmatory analysis

#Extract just variables from Data that are relevant for analyses
Data <- Data %>% 
  dplyr::select(pID, email, trial_num, sex, race, identity, expression, reputation, exact_value, rt, response, Age, Gender, aHAP, aLAP, iHAP, iLAP, aHAP_i, aLAP_i, iHAP_i, iLAP_i, responseNoVar, FamSES2)

#Subset data to just expression levels "calm" vs. "excited" (without "neutral")
Data <- Data %>% 
  filter(expression != "neut") 

#Refactor expression so that neut is no longer a level
Data$expression <- factor(Data$expression)

#Check levels
contrasts(Data$expression)
##      exci
## calm    0
## exci    1
#Optional: Take out participants who gave the same amount across all trials using: filter(responseNoVar==0)

Is there an interaction between target expression and target reputation on giving?

Data_noNA <- Data %>% 
  filter(!is.na(FamSES2))

#Model 1: entering Player 2's reputation and expression as predictors for amount given by participants (entering participant (pID) as random effect)
model1 <- lmer(data = Data_noNA, response ~ reputation * expression + (1|pID), REML=FALSE)
summary(model1)
## Linear mixed model fit by maximum likelihood . t-tests use
##   Satterthwaite's method [lmerModLmerTest]
## Formula: response ~ reputation * expression + (1 | pID)
##    Data: Data_noNA
## 
##      AIC      BIC   logLik deviance df.resid 
##  15644.0  15694.6  -7814.0  15628.0     4120 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.8351 -0.5696 -0.0118  0.5860  4.6617 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  pID      (Intercept) 3.712    1.927   
##  Residual             2.357    1.535   
## Number of obs: 4128, groups:  pID, 86
## 
## Fixed effects:
##                                 Estimate Std. Error         df t value
## (Intercept)                    2.555e+00  2.158e-01  9.759e+01  11.839
## reputationmod                  2.307e+00  8.278e-02  4.042e+03  27.864
## reputationhigh                 4.581e+00  8.278e-02  4.042e+03  55.342
## expressionexci                -1.453e-03  8.278e-02  4.042e+03  -0.018
## reputationmod:expressionexci  -1.730e-01  1.171e-01  4.042e+03  -1.477
## reputationhigh:expressionexci -5.087e-02  1.171e-01  4.042e+03  -0.435
##                               Pr(>|t|)    
## (Intercept)                     <2e-16 ***
## reputationmod                   <2e-16 ***
## reputationhigh                  <2e-16 ***
## expressionexci                   0.986    
## reputationmod:expressionexci     0.140    
## reputationhigh:expressionexci    0.664    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) rpttnm rpttnh exprss rpttnm:
## reputatinmd -0.192                             
## reputatnhgh -0.192  0.500                      
## expressinxc -0.192  0.500  0.500               
## rpttnmd:xpr  0.136 -0.707 -0.354 -0.707        
## rpttnhgh:xp  0.136 -0.354 -0.707 -0.707  0.500
#To see all contrasts (not just with reference category), re-level reputation and run again:
Data_noNA$reputation <- relevel(Data_noNA$reputation, ref = "mod")
model1 <- lmer(data = Data_noNA, response ~ reputation * expression + (1|pID), REML=FALSE)
summary(model1)
## Linear mixed model fit by maximum likelihood . t-tests use
##   Satterthwaite's method [lmerModLmerTest]
## Formula: response ~ reputation * expression + (1 | pID)
##    Data: Data_noNA
## 
##      AIC      BIC   logLik deviance df.resid 
##  15644.0  15694.6  -7814.0  15628.0     4120 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.8351 -0.5696 -0.0118  0.5860  4.6617 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  pID      (Intercept) 3.712    1.927   
##  Residual             2.357    1.535   
## Number of obs: 4128, groups:  pID, 86
## 
## Fixed effects:
##                                 Estimate Std. Error         df t value
## (Intercept)                      4.86192    0.21584   97.58856  22.526
## reputationlow                   -2.30669    0.08278 4042.00000 -27.864
## reputationhigh                   2.27471    0.08278 4042.00000  27.478
## expressionexci                  -0.17442    0.08278 4042.00000  -2.107
## reputationlow:expressionexci     0.17297    0.11707 4042.00000   1.477
## reputationhigh:expressionexci    0.12209    0.11707 4042.00000   1.043
##                               Pr(>|t|)    
## (Intercept)                     <2e-16 ***
## reputationlow                   <2e-16 ***
## reputationhigh                  <2e-16 ***
## expressionexci                  0.0352 *  
## reputationlow:expressionexci    0.1396    
## reputationhigh:expressionexci   0.2971    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) rpttnl rpttnh exprss rpttnl:
## reputatinlw -0.192                             
## reputatnhgh -0.192  0.500                      
## expressinxc -0.192  0.500  0.500               
## rpttnlw:xpr  0.136 -0.707 -0.354 -0.707        
## rpttnhgh:xp  0.136 -0.354 -0.707 -0.707  0.500
#Model 2: adding Player 2 race and sex and participant SES as predictors for amount given by participants 
Data_noNA$reputation <- relevel(Data_noNA$reputation, ref = "low") #relevel back to low as reference group
model2 <- lmer(data = Data_noNA, response ~ reputation * expression * race * sex + FamSES2 + (1|pID), REML=FALSE)
summary(model2)
## Linear mixed model fit by maximum likelihood . t-tests use
##   Satterthwaite's method [lmerModLmerTest]
## Formula: response ~ reputation * expression * race * sex + FamSES2 + (1 |  
##     pID)
##    Data: Data_noNA
## 
##      AIC      BIC   logLik deviance df.resid 
##  15622.1  15824.6  -7779.1  15558.1     4096 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.8290 -0.5752 -0.0065  0.5584  4.6085 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  pID      (Intercept) 2.935    1.713   
##  Residual             2.329    1.526   
## Number of obs: 4128, groups:  pID, 86
## 
## Fixed effects:
##                                                   Estimate Std. Error
## (Intercept)                                        7.52980    1.73109
## reputationmod                                      2.72674    0.16455
## reputationhigh                                     4.62209    0.16455
## expressionexci                                     0.09884    0.16455
## racewhite                                          0.29651    0.16455
## sexmale                                            0.20349    0.16455
## FamSES220-30K                                     -7.36111    1.99456
## FamSES230-40K                                     -6.10937    1.93123
## FamSES240-50K                                     -4.43490    1.83212
## FamSES250-75K                                     -5.43981    1.77468
## FamSES275-100K                                    -5.82917    1.77000
## FamSES2>100K                                      -4.67383    1.75412
## reputationmod:expressionexci                      -0.49419    0.23271
## reputationhigh:expressionexci                      0.26163    0.23271
## reputationmod:racewhite                           -0.61047    0.23271
## reputationhigh:racewhite                          -0.17442    0.23271
## expressionexci:racewhite                          -0.40116    0.23271
## reputationmod:sexmale                             -0.34884    0.23271
## reputationhigh:sexmale                            -0.07558    0.23271
## expressionexci:sexmale                             0.10465    0.23271
## racewhite:sexmale                                 -0.15116    0.23271
## reputationmod:expressionexci:racewhite             0.65698    0.32910
## reputationhigh:expressionexci:racewhite           -0.25581    0.32910
## reputationmod:expressionexci:sexmale              -0.13953    0.32910
## reputationhigh:expressionexci:sexmale             -0.30814    0.32910
## reputationmod:racewhite:sexmale                    0.23837    0.32910
## reputationhigh:racewhite:sexmale                   0.33721    0.32910
## expressionexci:racewhite:sexmale                   0.19186    0.32910
## reputationmod:expressionexci:racewhite:sexmale     0.25000    0.46541
## reputationhigh:expressionexci:racewhite:sexmale   -0.12209    0.46541
##                                                         df t value
## (Intercept)                                       86.74949   4.350
## reputationmod                                   4041.99999  16.571
## reputationhigh                                  4041.99999  28.090
## expressionexci                                  4041.99998   0.601
## racewhite                                       4041.99998   1.802
## sexmale                                         4041.99998   1.237
## FamSES220-30K                                     85.99999  -3.691
## FamSES230-40K                                     86.00000  -3.163
## FamSES240-50K                                     86.00000  -2.421
## FamSES250-75K                                     86.00000  -3.065
## FamSES275-100K                                    86.00000  -3.293
## FamSES2>100K                                      86.00000  -2.664
## reputationmod:expressionexci                    4042.00000  -2.124
## reputationhigh:expressionexci                   4042.00000   1.124
## reputationmod:racewhite                         4042.00000  -2.623
## reputationhigh:racewhite                        4042.00000  -0.750
## expressionexci:racewhite                        4042.00000  -1.724
## reputationmod:sexmale                           4042.00000  -1.499
## reputationhigh:sexmale                          4042.00000  -0.325
## expressionexci:sexmale                          4042.00000   0.450
## racewhite:sexmale                               4042.00000  -0.650
## reputationmod:expressionexci:racewhite          4042.00001   1.996
## reputationhigh:expressionexci:racewhite         4042.00001  -0.777
## reputationmod:expressionexci:sexmale            4042.00001  -0.424
## reputationhigh:expressionexci:sexmale           4042.00001  -0.936
## reputationmod:racewhite:sexmale                 4042.00001   0.724
## reputationhigh:racewhite:sexmale                4042.00001   1.025
## expressionexci:racewhite:sexmale                4042.00002   0.583
## reputationmod:expressionexci:racewhite:sexmale  4042.00002   0.537
## reputationhigh:expressionexci:racewhite:sexmale 4042.00002  -0.262
##                                                 Pr(>|t|)    
## (Intercept)                                      3.7e-05 ***
## reputationmod                                    < 2e-16 ***
## reputationhigh                                   < 2e-16 ***
## expressionexci                                  0.548100    
## racewhite                                       0.071623 .  
## sexmale                                         0.216288    
## FamSES220-30K                                   0.000392 ***
## FamSES230-40K                                   0.002155 ** 
## FamSES240-50K                                   0.017597 *  
## FamSES250-75K                                   0.002906 ** 
## FamSES275-100K                                  0.001438 ** 
## FamSES2>100K                                    0.009207 ** 
## reputationmod:expressionexci                    0.033760 *  
## reputationhigh:expressionexci                   0.260958    
## reputationmod:racewhite                         0.008740 ** 
## reputationhigh:racewhite                        0.453585    
## expressionexci:racewhite                        0.084801 .  
## reputationmod:sexmale                           0.133939    
## reputationhigh:sexmale                          0.745354    
## expressionexci:sexmale                          0.652940    
## racewhite:sexmale                               0.515995    
## reputationmod:expressionexci:racewhite          0.045967 *  
## reputationhigh:expressionexci:racewhite         0.437013    
## reputationmod:expressionexci:sexmale            0.671592    
## reputationhigh:expressionexci:sexmale           0.349163    
## reputationmod:racewhite:sexmale                 0.468908    
## reputationhigh:racewhite:sexmale                0.305587    
## expressionexci:racewhite:sexmale                0.559930    
## reputationmod:expressionexci:racewhite:sexmale  0.591187    
## reputationhigh:expressionexci:racewhite:sexmale 0.793078    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation matrix not shown by default, as p = 30 > 12.
## Use print(x, correlation=TRUE)  or
##     vcov(x)        if you need it
#To see all contrasts (not just with reference category), re-level reputation and run again:
Data_noNA$reputation <- relevel(Data_noNA$reputation, ref = "mod")
model2 <- lmer(data = Data_noNA, response ~ reputation * expression * race * sex + FamSES2 + (1|pID), REML=FALSE)
summary(model2)
## Linear mixed model fit by maximum likelihood . t-tests use
##   Satterthwaite's method [lmerModLmerTest]
## Formula: response ~ reputation * expression * race * sex + FamSES2 + (1 |  
##     pID)
##    Data: Data_noNA
## 
##      AIC      BIC   logLik deviance df.resid 
##  15622.1  15824.6  -7779.1  15558.1     4096 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.8290 -0.5752 -0.0065  0.5584  4.6085 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  pID      (Intercept) 2.935    1.713   
##  Residual             2.329    1.526   
## Number of obs: 4128, groups:  pID, 86
## 
## Fixed effects:
##                                                   Estimate Std. Error
## (Intercept)                                       10.25654    1.73109
## reputationlow                                     -2.72674    0.16455
## reputationhigh                                     1.89535    0.16455
## expressionexci                                    -0.39535    0.16455
## racewhite                                         -0.31395    0.16455
## sexmale                                           -0.14535    0.16455
## FamSES220-30K                                     -7.36111    1.99456
## FamSES230-40K                                     -6.10938    1.93123
## FamSES240-50K                                     -4.43490    1.83212
## FamSES250-75K                                     -5.43981    1.77468
## FamSES275-100K                                    -5.82917    1.77000
## FamSES2>100K                                      -4.67383    1.75412
## reputationlow:expressionexci                       0.49419    0.23271
## reputationhigh:expressionexci                      0.75581    0.23271
## reputationlow:racewhite                            0.61047    0.23271
## reputationhigh:racewhite                           0.43605    0.23271
## expressionexci:racewhite                           0.25581    0.23271
## reputationlow:sexmale                              0.34884    0.23271
## reputationhigh:sexmale                             0.27326    0.23271
## expressionexci:sexmale                            -0.03488    0.23271
## racewhite:sexmale                                  0.08721    0.23271
## reputationlow:expressionexci:racewhite            -0.65698    0.32910
## reputationhigh:expressionexci:racewhite           -0.91279    0.32910
## reputationlow:expressionexci:sexmale               0.13953    0.32910
## reputationhigh:expressionexci:sexmale             -0.16860    0.32910
## reputationlow:racewhite:sexmale                   -0.23837    0.32910
## reputationhigh:racewhite:sexmale                   0.09884    0.32910
## expressionexci:racewhite:sexmale                   0.44186    0.32910
## reputationlow:expressionexci:racewhite:sexmale    -0.25000    0.46541
## reputationhigh:expressionexci:racewhite:sexmale   -0.37209    0.46541
##                                                         df t value
## (Intercept)                                       86.74956   5.925
## reputationlow                                   4042.00001 -16.571
## reputationhigh                                  4042.00001  11.519
## expressionexci                                  4042.00001  -2.403
## racewhite                                       4042.00001  -1.908
## sexmale                                         4042.00001  -0.883
## FamSES220-30K                                     86.00005  -3.691
## FamSES230-40K                                     86.00005  -3.163
## FamSES240-50K                                     86.00006  -2.421
## FamSES250-75K                                     86.00007  -3.065
## FamSES275-100K                                    86.00007  -3.293
## FamSES2>100K                                      86.00007  -2.664
## reputationlow:expressionexci                    4042.00001   2.124
## reputationhigh:expressionexci                   4042.00001   3.248
## reputationlow:racewhite                         4042.00001   2.623
## reputationhigh:racewhite                        4042.00001   1.874
## expressionexci:racewhite                        4042.00001   1.099
## reputationlow:sexmale                           4042.00001   1.499
## reputationhigh:sexmale                          4042.00001   1.174
## expressionexci:sexmale                          4042.00001  -0.150
## racewhite:sexmale                               4042.00001   0.375
## reputationlow:expressionexci:racewhite          4042.00001  -1.996
## reputationhigh:expressionexci:racewhite         4042.00001  -2.774
## reputationlow:expressionexci:sexmale            4042.00001   0.424
## reputationhigh:expressionexci:sexmale           4042.00001  -0.512
## reputationlow:racewhite:sexmale                 4042.00001  -0.724
## reputationhigh:racewhite:sexmale                4042.00001   0.300
## expressionexci:racewhite:sexmale                4042.00001   1.343
## reputationlow:expressionexci:racewhite:sexmale  4042.00001  -0.537
## reputationhigh:expressionexci:racewhite:sexmale 4042.00001  -0.799
##                                                 Pr(>|t|)    
## (Intercept)                                     6.16e-08 ***
## reputationlow                                    < 2e-16 ***
## reputationhigh                                   < 2e-16 ***
## expressionexci                                  0.016322 *  
## racewhite                                       0.056465 .  
## sexmale                                         0.377114    
## FamSES220-30K                                   0.000392 ***
## FamSES230-40K                                   0.002155 ** 
## FamSES240-50K                                   0.017597 *  
## FamSES250-75K                                   0.002906 ** 
## FamSES275-100K                                  0.001438 ** 
## FamSES2>100K                                    0.009207 ** 
## reputationlow:expressionexci                    0.033760 *  
## reputationhigh:expressionexci                   0.001172 ** 
## reputationlow:racewhite                         0.008740 ** 
## reputationhigh:racewhite                        0.061029 .  
## expressionexci:racewhite                        0.271702    
## reputationlow:sexmale                           0.133939    
## reputationhigh:sexmale                          0.240362    
## expressionexci:sexmale                          0.880847    
## racewhite:sexmale                               0.707857    
## reputationlow:expressionexci:racewhite          0.045967 *  
## reputationhigh:expressionexci:racewhite         0.005569 ** 
## reputationlow:expressionexci:sexmale            0.671592    
## reputationhigh:expressionexci:sexmale           0.608450    
## reputationlow:racewhite:sexmale                 0.468908    
## reputationhigh:racewhite:sexmale                0.763941    
## expressionexci:racewhite:sexmale                0.179460    
## reputationlow:expressionexci:racewhite:sexmale  0.591187    
## reputationhigh:expressionexci:racewhite:sexmale 0.424052    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation matrix not shown by default, as p = 30 > 12.
## Use print(x, correlation=TRUE)  or
##     vcov(x)        if you need it
#Model comparison
anova(model1, model2)
## Data: Data_noNA
## Models:
## model1: response ~ reputation * expression + (1 | pID)
## model2: response ~ reputation * expression * race * sex + FamSES2 + (1 | 
## model2:     pID)
##        Df   AIC   BIC  logLik deviance  Chisq Chi Df Pr(>Chisq)    
## model1  8 15644 15695 -7814.0    15628                             
## model2 32 15622 15825 -7779.1    15558 69.813     24  2.333e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Plot the above

Data %>% 
  ggplot(aes(x = reputation, y = response, fill = expression)) +
  geom_bar(position="dodge", stat = "summary", fun.y = "mean") +
  stat_summary(geom = "errorbar", fun.data = mean_se, position=position_dodge(.9), width = 0.2) +
  scale_x_discrete(limits=c("low","mod", "high"),
                   labels=c("Low","Moderate", "High")) +
  guides(fill=guide_legend(title="Expression")) +
  scale_fill_manual(values=c("#94B3D7", "#D99594")) +
  xlab("Player 2 Reputation") +
  ylab("Amount Given ($)") +
  ylim(c(0,10))

Individual Differences in Ideal Affect –> Ideal Affect Match –> Giving?

##For now, we only have European American data, so we will test whether there are individual differences in ideal affect:

#First, filter for just moderate reputation ("mod") because that's where it seems ideal affect matters
Data_ModRepOnly <- Data %>% 
  filter(reputation == "mod")

#Model 3: adding participant ideal HAP and Player 2 expression as predictors for amount given by participants, controlling for actual HAP 
model3 <- lmer(data = Data_ModRepOnly, response ~ expression * scale(iHAP, scale = F) + scale(aHAP, scale = F) + (1|pID), REML=FALSE)
summary(model3)
## Linear mixed model fit by maximum likelihood . t-tests use
##   Satterthwaite's method [lmerModLmerTest]
## Formula: response ~ expression * scale(iHAP, scale = F) + scale(aHAP,  
##     scale = F) + (1 | pID)
##    Data: Data_ModRepOnly
## 
##      AIC      BIC   logLik deviance df.resid 
##   4348.3   4384.9  -2167.1   4334.3     1385 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -6.3364 -0.3401  0.0207  0.3579  8.8579 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  pID      (Intercept) 5.1771   2.2753  
##  Residual             0.9989   0.9995  
## Number of obs: 1392, groups:  pID, 87
## 
## Fixed effects:
##                                         Estimate Std. Error         df
## (Intercept)                              4.83908    0.24687   89.08487
## expressionexci                          -0.17816    0.05358 1305.00000
## scale(iHAP, scale = F)                   0.05755    0.35722   88.59362
## scale(aHAP, scale = F)                   0.18962    0.40562   87.00000
## expressionexci:scale(iHAP, scale = F)   -0.03890    0.06792 1305.00000
##                                       t value Pr(>|t|)    
## (Intercept)                            19.602  < 2e-16 ***
## expressionexci                         -3.325 0.000908 ***
## scale(iHAP, scale = F)                  0.161 0.872387    
## scale(aHAP, scale = F)                  0.467 0.641331    
## expressionexci:scale(iHAP, scale = F)  -0.573 0.566924    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##                   (Intr) exprss scale(iHAP,scl=F) scale(aHAP,scl=F)
## expressinxc       -0.109                                           
## scale(iHAP,scl=F)  0.000  0.000                                    
## scale(aHAP,scl=F)  0.000  0.000 -0.482                             
## e:(HAP,s=F)        0.000  0.000 -0.095             0.000
#Without adding participant ID as a random variable
model3 <- lm(data = Data_ModRepOnly, response ~ expression * scale(iHAP, scale = F) + scale(aHAP, scale = F))
summary(model3)
## 
## Call:
## lm(formula = response ~ expression * scale(iHAP, scale = F) + 
##     scale(aHAP, scale = F), data = Data_ModRepOnly)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -4.884 -1.666  0.046  1.203  5.675 
## 
## Coefficients:
##                                       Estimate Std. Error t value Pr(>|t|)
## (Intercept)                            4.83908    0.09437  51.278   <2e-16
## expressionexci                        -0.17816    0.13346  -1.335   0.1821
## scale(iHAP, scale = F)                 0.05755    0.12847   0.448   0.6543
## scale(aHAP, scale = F)                 0.18962    0.11029   1.719   0.0858
## expressionexci:scale(iHAP, scale = F) -0.03890    0.16918  -0.230   0.8182
##                                          
## (Intercept)                           ***
## expressionexci                           
## scale(iHAP, scale = F)                   
## scale(aHAP, scale = F)                .  
## expressionexci:scale(iHAP, scale = F)    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.49 on 1387 degrees of freedom
## Multiple R-squared:  0.004848,   Adjusted R-squared:  0.001978 
## F-statistic: 1.689 on 4 and 1387 DF,  p-value: 0.15
#Model 4: adding participant ideal LAP and Player 2 expression as predictors for amount given by participants, controlling for actual LAP 
model4 <- lmer(data = Data_ModRepOnly, response ~ expression * scale(iLAP, scale = F) + scale(aLAP, scale = F) + (1|pID), REML=FALSE)
summary(model4)
## Linear mixed model fit by maximum likelihood . t-tests use
##   Satterthwaite's method [lmerModLmerTest]
## Formula: response ~ expression * scale(iLAP, scale = F) + scale(aLAP,  
##     scale = F) + (1 | pID)
##    Data: Data_ModRepOnly
## 
##      AIC      BIC   logLik deviance df.resid 
##   4341.9   4378.5  -2163.9   4327.9     1385 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -6.3350 -0.3465  0.0289  0.3530  8.8789 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  pID      (Intercept) 4.7954   2.1898  
##  Residual             0.9991   0.9996  
## Number of obs: 1392, groups:  pID, 87
## 
## Fixed effects:
##                                         Estimate Std. Error         df
## (Intercept)                              4.83908    0.23781   89.25003
## expressionexci                          -0.17816    0.05358 1305.00000
## scale(iLAP, scale = F)                  -0.72887    0.30867   89.13547
## scale(aLAP, scale = F)                   0.57662    0.31642   87.00000
## expressionexci:scale(iLAP, scale = F)    0.02417    0.06779 1305.00000
##                                       t value Pr(>|t|)    
## (Intercept)                            20.348  < 2e-16 ***
## expressionexci                         -3.325 0.000909 ***
## scale(iLAP, scale = F)                 -2.361 0.020391 *  
## scale(aLAP, scale = F)                  1.822 0.071840 .  
## expressionexci:scale(iLAP, scale = F)   0.357 0.721460    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##                   (Intr) exprss scale(iLAP,scl=F) scale(aLAP,scl=F)
## expressinxc       -0.113                                           
## scale(iLAP,scl=F)  0.000  0.000                                    
## scale(aLAP,scl=F)  0.000  0.000 -0.224                             
## e:(LAP,s=F)        0.000  0.000 -0.110             0.000
#Without adding participant ID as a random variable
model4 <- lm(data = Data_ModRepOnly, response ~ expression * scale(iLAP, scale = F) + scale(aLAP, scale = F))
summary(model4)
## 
## Call:
## lm(formula = response ~ expression * scale(iLAP, scale = F) + 
##     scale(aLAP, scale = F), data = Data_ModRepOnly)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.1427 -1.4899 -0.1555  0.9565  5.7253 
## 
## Coefficients:
##                                       Estimate Std. Error t value Pr(>|t|)
## (Intercept)                            4.83908    0.09141  52.939  < 2e-16
## expressionexci                        -0.17816    0.12927  -1.378    0.168
## scale(iLAP, scale = F)                -0.72887    0.11717  -6.221 6.55e-10
## scale(aLAP, scale = F)                 0.57662    0.08655   6.662 3.88e-11
## expressionexci:scale(iLAP, scale = F)  0.02417    0.16354   0.148    0.883
##                                          
## (Intercept)                           ***
## expressionexci                           
## scale(iLAP, scale = F)                ***
## scale(aLAP, scale = F)                ***
## expressionexci:scale(iLAP, scale = F)    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.412 on 1387 degrees of freedom
## Multiple R-squared:  0.06633,    Adjusted R-squared:  0.06364 
## F-statistic: 24.64 on 4 and 1387 DF,  p-value: < 2.2e-16
#Plot
expr_colors=c("#94B3D7","#D99594") #Set correct colors for "expression" variable for the jittered points in the graphs below

#iHAP
Data_ModRepOnly %>% 
  ggplot(aes(x = iHAP, y = response, fill = expression)) +
  geom_jitter(aes(colour = expression, alpha=0.01), width = 0.2, height = 0.4) + 
  geom_smooth(method=lm, color='#2C3E50') +
  guides(fill=guide_legend(title="Player 2 Expression")) +
  scale_fill_manual(values=c("#94B3D7", "#D99594")) + #Set correct ribbon colors
  scale_color_manual(values = expr_colors) + #Set correct jitter (point) colors
  xlab("Participant ideal HAP") +
  ylab("Amount Given ($)") +
  ylim(c(0,10))
## Warning: Removed 93 rows containing missing values (geom_point).

#iLAP
Data_ModRepOnly %>% 
  ggplot(aes(x = iLAP, y = response, fill = expression)) +
  geom_jitter(aes(colour = expression, alpha=0.01), width = 0.2, height = 0.4) + 
  geom_smooth(method=lm, color='#2C3E50') +
  guides(fill=guide_legend(title="Player 2 Expression")) +
  scale_fill_manual(values=c("#94B3D7", "#D99594")) + #Set correct ribbon colors
  scale_color_manual(values = expr_colors) + #Set correct jitter (point) colors
  xlab("Participant ideal LAP") +
  ylab("Amount Given ($)") +
  ylim(c(0,10))
## Warning: Removed 88 rows containing missing values (geom_point).

Gender analysis:

#Separate dataframe into male only vs. female only (not enough males to use as covariate)

Data_Males <- Data_noNA %>% 
  filter(Gender == "Male")

Data_Females <- Data_noNA %>% 
  filter(Gender == "Female")

#For males only:
#Model 1: entering Player 2's reputation and expression as predictors for amount given by participants (entering participant (pID) as random effect)
model1 <- lmer(data = Data_Males, response ~ reputation * expression + (1|pID), REML=FALSE)
summary(model1)
## Linear mixed model fit by maximum likelihood . t-tests use
##   Satterthwaite's method [lmerModLmerTest]
## Formula: response ~ reputation * expression + (1 | pID)
##    Data: Data_Males
## 
##      AIC      BIC   logLik deviance df.resid 
##   4688.3   4729.0  -2336.1   4672.3     1192 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.2927 -0.7028 -0.0222  0.5561  4.1566 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  pID      (Intercept) 4.462    2.112   
##  Residual             2.621    1.619   
## Number of obs: 1200, groups:  pID, 25
## 
## Fixed effects:
##                                Estimate Std. Error        df t value
## (Intercept)                      4.9050     0.4377   28.1121  11.206
## reputationlow                   -1.9600     0.1619 1175.0000 -12.106
## reputationhigh                   1.7200     0.1619 1175.0000  10.623
## expressionexci                  -0.2250     0.1619 1175.0000  -1.390
## reputationlow:expressionexci     0.2700     0.2290 1175.0000   1.179
## reputationhigh:expressionexci    0.1050     0.2290 1175.0000   0.459
##                               Pr(>|t|)    
## (Intercept)                   6.99e-12 ***
## reputationlow                  < 2e-16 ***
## reputationhigh                 < 2e-16 ***
## expressionexci                   0.165    
## reputationlow:expressionexci     0.239    
## reputationhigh:expressionexci    0.647    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) rpttnl rpttnh exprss rpttnl:
## reputatinlw -0.185                             
## reputatnhgh -0.185  0.500                      
## expressinxc -0.185  0.500  0.500               
## rpttnlw:xpr  0.131 -0.707 -0.354 -0.707        
## rpttnhgh:xp  0.131 -0.354 -0.707 -0.707  0.500
#To see all contrasts (not just with reference category), re-level reputation and run again:
Data_Males$reputation <- relevel(Data_Males$reputation, ref = "mod")
model1 <- lmer(data = Data_Males, response ~ reputation * expression + (1|pID), REML=FALSE)
summary(model1)
## Linear mixed model fit by maximum likelihood . t-tests use
##   Satterthwaite's method [lmerModLmerTest]
## Formula: response ~ reputation * expression + (1 | pID)
##    Data: Data_Males
## 
##      AIC      BIC   logLik deviance df.resid 
##   4688.3   4729.0  -2336.1   4672.3     1192 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.2927 -0.7028 -0.0222  0.5561  4.1566 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  pID      (Intercept) 4.462    2.112   
##  Residual             2.621    1.619   
## Number of obs: 1200, groups:  pID, 25
## 
## Fixed effects:
##                                Estimate Std. Error        df t value
## (Intercept)                      4.9050     0.4377   28.1121  11.206
## reputationlow                   -1.9600     0.1619 1175.0000 -12.106
## reputationhigh                   1.7200     0.1619 1175.0000  10.623
## expressionexci                  -0.2250     0.1619 1175.0000  -1.390
## reputationlow:expressionexci     0.2700     0.2290 1175.0000   1.179
## reputationhigh:expressionexci    0.1050     0.2290 1175.0000   0.459
##                               Pr(>|t|)    
## (Intercept)                   6.99e-12 ***
## reputationlow                  < 2e-16 ***
## reputationhigh                 < 2e-16 ***
## expressionexci                   0.165    
## reputationlow:expressionexci     0.239    
## reputationhigh:expressionexci    0.647    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) rpttnl rpttnh exprss rpttnl:
## reputatinlw -0.185                             
## reputatnhgh -0.185  0.500                      
## expressinxc -0.185  0.500  0.500               
## rpttnlw:xpr  0.131 -0.707 -0.354 -0.707        
## rpttnhgh:xp  0.131 -0.354 -0.707 -0.707  0.500
#Model 2: adding Player 2 race and sex and participant SES as predictors for amount given by participants 
Data_Males$reputation <- relevel(Data_Males$reputation, ref = "low") #relevel back to low as reference group
model2 <- lmer(data = Data_Males, response ~ reputation * expression * race * sex + FamSES2 + (1|pID), REML=FALSE)
summary(model2)
## Linear mixed model fit by maximum likelihood . t-tests use
##   Satterthwaite's method [lmerModLmerTest]
## Formula: response ~ reputation * expression * race * sex + FamSES2 + (1 |  
##     pID)
##    Data: Data_Males
## 
##      AIC      BIC   logLik deviance df.resid 
##   4709.3   4867.1  -2323.6   4647.3     1169 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.2211 -0.6970 -0.0109  0.5791  4.0851 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  pID      (Intercept) 3.501    1.871   
##  Residual             2.579    1.606   
## Number of obs: 1200, groups:  pID, 25
## 
## Fixed effects:
##                                                  Estimate Std. Error
## (Intercept)                                        0.7439     1.1111
## reputationmod                                      2.2000     0.3212
## reputationhigh                                     3.7200     0.3212
## expressionexci                                     0.1000     0.3212
## racewhite                                          0.0800     0.3212
## sexmale                                           -0.0600     0.3212
## FamSES230-40K                                      2.5903     1.7212
## FamSES240-50K                                      2.1736     2.1772
## FamSES250-75K                                      2.1944     1.3332
## FamSES275-100K                                     1.8075     1.3011
## FamSES2>100K                                       3.3715     1.3332
## reputationmod:expressionexci                      -0.4000     0.4542
## reputationhigh:expressionexci                      0.0800     0.4542
## reputationmod:racewhite                           -0.3800     0.4542
## reputationhigh:racewhite                          -0.1400     0.4542
## expressionexci:racewhite                          -0.3800     0.4542
## reputationmod:sexmale                              0.0200     0.4542
## reputationhigh:sexmale                            -0.0800     0.4542
## expressionexci:sexmale                             0.2800     0.4542
## racewhite:sexmale                                  0.2200     0.4542
## reputationmod:expressionexci:racewhite             0.4400     0.6424
## reputationhigh:expressionexci:racewhite           -0.1000     0.6424
## reputationmod:expressionexci:sexmale              -0.7200     0.6424
## reputationhigh:expressionexci:sexmale             -0.2200     0.6424
## reputationmod:racewhite:sexmale                   -0.2400     0.6424
## reputationhigh:racewhite:sexmale                   0.2800     0.6424
## expressionexci:racewhite:sexmale                  -0.0200     0.6424
## reputationmod:expressionexci:racewhite:sexmale     1.0800     0.9085
## reputationhigh:expressionexci:racewhite:sexmale   -0.3400     0.9085
##                                                        df t value Pr(>|t|)
## (Intercept)                                       27.1284   0.670   0.5088
## reputationmod                                   1175.0000   6.849 1.19e-11
## reputationhigh                                  1175.0000  11.581  < 2e-16
## expressionexci                                  1175.0000   0.311   0.7556
## racewhite                                       1175.0000   0.249   0.8034
## sexmale                                         1175.0000  -0.187   0.8519
## FamSES230-40K                                     25.0000   1.505   0.1449
## FamSES240-50K                                     25.0000   0.998   0.3277
## FamSES250-75K                                     25.0000   1.646   0.1123
## FamSES275-100K                                    25.0000   1.389   0.1770
## FamSES2>100K                                      25.0000   2.529   0.0181
## reputationmod:expressionexci                    1175.0000  -0.881   0.3787
## reputationhigh:expressionexci                   1175.0000   0.176   0.8602
## reputationmod:racewhite                         1175.0000  -0.837   0.4030
## reputationhigh:racewhite                        1175.0000  -0.308   0.7580
## expressionexci:racewhite                        1175.0000  -0.837   0.4030
## reputationmod:sexmale                           1175.0000   0.044   0.9649
## reputationhigh:sexmale                          1175.0000  -0.176   0.8602
## expressionexci:sexmale                          1175.0000   0.616   0.5378
## racewhite:sexmale                               1175.0000   0.484   0.6283
## reputationmod:expressionexci:racewhite          1175.0000   0.685   0.4935
## reputationhigh:expressionexci:racewhite         1175.0000  -0.156   0.8763
## reputationmod:expressionexci:sexmale            1175.0000  -1.121   0.2626
## reputationhigh:expressionexci:sexmale           1175.0000  -0.342   0.7321
## reputationmod:racewhite:sexmale                 1175.0000  -0.374   0.7088
## reputationhigh:racewhite:sexmale                1175.0000   0.436   0.6630
## expressionexci:racewhite:sexmale                1175.0000  -0.031   0.9752
## reputationmod:expressionexci:racewhite:sexmale  1175.0000   1.189   0.2348
## reputationhigh:expressionexci:racewhite:sexmale 1175.0000  -0.374   0.7083
##                                                    
## (Intercept)                                        
## reputationmod                                   ***
## reputationhigh                                  ***
## expressionexci                                     
## racewhite                                          
## sexmale                                            
## FamSES230-40K                                      
## FamSES240-50K                                      
## FamSES250-75K                                      
## FamSES275-100K                                     
## FamSES2>100K                                    *  
## reputationmod:expressionexci                       
## reputationhigh:expressionexci                      
## reputationmod:racewhite                            
## reputationhigh:racewhite                           
## expressionexci:racewhite                           
## reputationmod:sexmale                              
## reputationhigh:sexmale                             
## expressionexci:sexmale                             
## racewhite:sexmale                                  
## reputationmod:expressionexci:racewhite             
## reputationhigh:expressionexci:racewhite            
## reputationmod:expressionexci:sexmale               
## reputationhigh:expressionexci:sexmale              
## reputationmod:racewhite:sexmale                    
## reputationhigh:racewhite:sexmale                   
## expressionexci:racewhite:sexmale                   
## reputationmod:expressionexci:racewhite:sexmale     
## reputationhigh:expressionexci:racewhite:sexmale    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation matrix not shown by default, as p = 29 > 12.
## Use print(x, correlation=TRUE)  or
##     vcov(x)        if you need it
#To see all contrasts (not just with reference category), re-level reputation and run again:
Data_Males$reputation <- relevel(Data_Males$reputation, ref = "mod")
model2 <- lmer(data = Data_Males, response ~ reputation * expression * race * sex + FamSES2 + (1|pID), REML=FALSE)
summary(model2)
## Linear mixed model fit by maximum likelihood . t-tests use
##   Satterthwaite's method [lmerModLmerTest]
## Formula: response ~ reputation * expression * race * sex + FamSES2 + (1 |  
##     pID)
##    Data: Data_Males
## 
##      AIC      BIC   logLik deviance df.resid 
##   4709.3   4867.1  -2323.6   4647.3     1169 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.2211 -0.6970 -0.0109  0.5791  4.0851 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  pID      (Intercept) 3.501    1.871   
##  Residual             2.579    1.606   
## Number of obs: 1200, groups:  pID, 25
## 
## Fixed effects:
##                                                  Estimate Std. Error
## (Intercept)                                        2.9439     1.1111
## reputationlow                                     -2.2000     0.3212
## reputationhigh                                     1.5200     0.3212
## expressionexci                                    -0.3000     0.3212
## racewhite                                         -0.3000     0.3212
## sexmale                                           -0.0400     0.3212
## FamSES230-40K                                      2.5903     1.7212
## FamSES240-50K                                      2.1736     2.1772
## FamSES250-75K                                      2.1944     1.3332
## FamSES275-100K                                     1.8075     1.3011
## FamSES2>100K                                       3.3715     1.3332
## reputationlow:expressionexci                       0.4000     0.4542
## reputationhigh:expressionexci                      0.4800     0.4542
## reputationlow:racewhite                            0.3800     0.4542
## reputationhigh:racewhite                           0.2400     0.4542
## expressionexci:racewhite                           0.0600     0.4542
## reputationlow:sexmale                             -0.0200     0.4542
## reputationhigh:sexmale                            -0.1000     0.4542
## expressionexci:sexmale                            -0.4400     0.4542
## racewhite:sexmale                                 -0.0200     0.4542
## reputationlow:expressionexci:racewhite            -0.4400     0.6424
## reputationhigh:expressionexci:racewhite           -0.5400     0.6424
## reputationlow:expressionexci:sexmale               0.7200     0.6424
## reputationhigh:expressionexci:sexmale              0.5000     0.6424
## reputationlow:racewhite:sexmale                    0.2400     0.6424
## reputationhigh:racewhite:sexmale                   0.5200     0.6424
## expressionexci:racewhite:sexmale                   1.0600     0.6424
## reputationlow:expressionexci:racewhite:sexmale    -1.0800     0.9085
## reputationhigh:expressionexci:racewhite:sexmale   -1.4200     0.9085
##                                                        df t value Pr(>|t|)
## (Intercept)                                       27.1284   2.650   0.0133
## reputationlow                                   1175.0000  -6.849 1.19e-11
## reputationhigh                                  1175.0000   4.732 2.49e-06
## expressionexci                                  1175.0000  -0.934   0.3505
## racewhite                                       1175.0000  -0.934   0.3505
## sexmale                                         1175.0000  -0.125   0.9009
## FamSES230-40K                                     25.0000   1.505   0.1449
## FamSES240-50K                                     25.0000   0.998   0.3277
## FamSES250-75K                                     25.0000   1.646   0.1123
## FamSES275-100K                                    25.0000   1.389   0.1770
## FamSES2>100K                                      25.0000   2.529   0.0181
## reputationlow:expressionexci                    1175.0000   0.881   0.3787
## reputationhigh:expressionexci                   1175.0000   1.057   0.2909
## reputationlow:racewhite                         1175.0000   0.837   0.4030
## reputationhigh:racewhite                        1175.0000   0.528   0.5974
## expressionexci:racewhite                        1175.0000   0.132   0.8949
## reputationlow:sexmale                           1175.0000  -0.044   0.9649
## reputationhigh:sexmale                          1175.0000  -0.220   0.8258
## expressionexci:sexmale                          1175.0000  -0.969   0.3329
## racewhite:sexmale                               1175.0000  -0.044   0.9649
## reputationlow:expressionexci:racewhite          1175.0000  -0.685   0.4935
## reputationhigh:expressionexci:racewhite         1175.0000  -0.841   0.4008
## reputationlow:expressionexci:sexmale            1175.0000   1.121   0.2626
## reputationhigh:expressionexci:sexmale           1175.0000   0.778   0.4365
## reputationlow:racewhite:sexmale                 1175.0000   0.374   0.7088
## reputationhigh:racewhite:sexmale                1175.0000   0.809   0.4184
## expressionexci:racewhite:sexmale                1175.0000   1.650   0.0992
## reputationlow:expressionexci:racewhite:sexmale  1175.0000  -1.189   0.2348
## reputationhigh:expressionexci:racewhite:sexmale 1175.0000  -1.563   0.1183
##                                                    
## (Intercept)                                     *  
## reputationlow                                   ***
## reputationhigh                                  ***
## expressionexci                                     
## racewhite                                          
## sexmale                                            
## FamSES230-40K                                      
## FamSES240-50K                                      
## FamSES250-75K                                      
## FamSES275-100K                                     
## FamSES2>100K                                    *  
## reputationlow:expressionexci                       
## reputationhigh:expressionexci                      
## reputationlow:racewhite                            
## reputationhigh:racewhite                           
## expressionexci:racewhite                           
## reputationlow:sexmale                              
## reputationhigh:sexmale                             
## expressionexci:sexmale                             
## racewhite:sexmale                                  
## reputationlow:expressionexci:racewhite             
## reputationhigh:expressionexci:racewhite            
## reputationlow:expressionexci:sexmale               
## reputationhigh:expressionexci:sexmale              
## reputationlow:racewhite:sexmale                    
## reputationhigh:racewhite:sexmale                   
## expressionexci:racewhite:sexmale                .  
## reputationlow:expressionexci:racewhite:sexmale     
## reputationhigh:expressionexci:racewhite:sexmale    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation matrix not shown by default, as p = 29 > 12.
## Use print(x, correlation=TRUE)  or
##     vcov(x)        if you need it
#Model comparison
anova(model1, model2)
## Data: Data_Males
## Models:
## model1: response ~ reputation * expression + (1 | pID)
## model2: response ~ reputation * expression * race * sex + FamSES2 + (1 | 
## model2:     pID)
##        Df    AIC    BIC  logLik deviance  Chisq Chi Df Pr(>Chisq)
## model1  8 4688.3 4729.0 -2336.1   4672.3                         
## model2 31 4709.3 4867.1 -2323.6   4647.3 24.997     23     0.3504
#######################################################################
#For females only:
#Model 1: entering Player 2's reputation and expression as predictors for amount given by participants (entering participant (pID) as random effect)
model1 <- lmer(data = Data_Females, response ~ reputation * expression + (1|pID), REML=FALSE)
summary(model1)
## Linear mixed model fit by maximum likelihood . t-tests use
##   Satterthwaite's method [lmerModLmerTest]
## Formula: response ~ reputation * expression + (1 | pID)
##    Data: Data_Females
## 
##      AIC      BIC   logLik deviance df.resid 
##  10017.3  10064.6  -5000.7  10001.3     2728 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.0953 -0.5015 -0.0309  0.5217  4.7204 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  pID      (Intercept) 2.630    1.622   
##  Residual             2.079    1.442   
## Number of obs: 2736, groups:  pID, 57
## 
## Fixed effects:
##                                 Estimate Std. Error         df t value
## (Intercept)                      4.66447    0.22515   66.59952  20.718
## reputationlow                   -2.53509    0.09548 2679.00001 -26.551
## reputationhigh                   2.52851    0.09548 2679.00001  26.482
## expressionexci                  -0.17544    0.09548 2679.00001  -1.837
## reputationlow:expressionexci     0.17763    0.13503 2679.00001   1.315
## reputationhigh:expressionexci    0.14254    0.13503 2679.00001   1.056
##                               Pr(>|t|)    
## (Intercept)                     <2e-16 ***
## reputationlow                   <2e-16 ***
## reputationhigh                  <2e-16 ***
## expressionexci                  0.0663 .  
## reputationlow:expressionexci    0.1885    
## reputationhigh:expressionexci   0.2912    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) rpttnl rpttnh exprss rpttnl:
## reputatinlw -0.212                             
## reputatnhgh -0.212  0.500                      
## expressinxc -0.212  0.500  0.500               
## rpttnlw:xpr  0.150 -0.707 -0.354 -0.707        
## rpttnhgh:xp  0.150 -0.354 -0.707 -0.707  0.500
#To see all contrasts (not just with reference category), re-level reputation and run again:
Data_Females$reputation <- relevel(Data_Females$reputation, ref = "mod")
model1 <- lmer(data = Data_Females, response ~ reputation * expression + (1|pID), REML=FALSE)
summary(model1)
## Linear mixed model fit by maximum likelihood . t-tests use
##   Satterthwaite's method [lmerModLmerTest]
## Formula: response ~ reputation * expression + (1 | pID)
##    Data: Data_Females
## 
##      AIC      BIC   logLik deviance df.resid 
##  10017.3  10064.6  -5000.7  10001.3     2728 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.0953 -0.5015 -0.0309  0.5217  4.7204 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  pID      (Intercept) 2.630    1.622   
##  Residual             2.079    1.442   
## Number of obs: 2736, groups:  pID, 57
## 
## Fixed effects:
##                                 Estimate Std. Error         df t value
## (Intercept)                      4.66447    0.22515   66.59952  20.718
## reputationlow                   -2.53509    0.09548 2679.00001 -26.551
## reputationhigh                   2.52851    0.09548 2679.00001  26.482
## expressionexci                  -0.17544    0.09548 2679.00001  -1.837
## reputationlow:expressionexci     0.17763    0.13503 2679.00001   1.315
## reputationhigh:expressionexci    0.14254    0.13503 2679.00001   1.056
##                               Pr(>|t|)    
## (Intercept)                     <2e-16 ***
## reputationlow                   <2e-16 ***
## reputationhigh                  <2e-16 ***
## expressionexci                  0.0663 .  
## reputationlow:expressionexci    0.1885    
## reputationhigh:expressionexci   0.2912    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) rpttnl rpttnh exprss rpttnl:
## reputatinlw -0.212                             
## reputatnhgh -0.212  0.500                      
## expressinxc -0.212  0.500  0.500               
## rpttnlw:xpr  0.150 -0.707 -0.354 -0.707        
## rpttnhgh:xp  0.150 -0.354 -0.707 -0.707  0.500
#Model 2: adding Player 2 race and sex and participant SES as predictors for amount given by participants 
Data_Females$reputation <- relevel(Data_Females$reputation, ref = "low") #relevel back to low as reference group
model2 <- lmer(data = Data_Females, response ~ reputation * expression * race * sex + FamSES2 + (1|pID), REML=FALSE)
summary(model2)
## Linear mixed model fit by maximum likelihood . t-tests use
##   Satterthwaite's method [lmerModLmerTest]
## Formula: response ~ reputation * expression * race * sex + FamSES2 + (1 |  
##     pID)
##    Data: Data_Females
## 
##      AIC      BIC   logLik deviance df.resid 
##  10011.6  10189.0  -4975.8   9951.6     2706 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.9127 -0.5205 -0.0172  0.5160  4.6117 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  pID      (Intercept) 2.181    1.477   
##  Residual             2.048    1.431   
## Number of obs: 2736, groups:  pID, 57
## 
## Fixed effects:
##                                                   Estimate Std. Error
## (Intercept)                                       -0.22496    1.06254
## reputationmod                                      3.03509    0.18957
## reputationhigh                                     5.09649    0.18957
## expressionexci                                     0.11404    0.18957
## racewhite                                          0.39474    0.18957
## sexmale                                            0.31579    0.18957
## FamSES240-50K                                      3.12054    1.19559
## FamSES250-75K                                      1.67917    1.15505
## FamSES275-100K                                     1.47035    1.13262
## FamSES2>100K                                       2.42292    1.09577
## reputationmod:expressionexci                      -0.61404    0.26809
## reputationhigh:expressionexci                      0.33333    0.26809
## reputationmod:racewhite                           -0.71053    0.26809
## reputationhigh:racewhite                          -0.18421    0.26809
## expressionexci:racewhite                          -0.40351    0.26809
## reputationmod:sexmale                             -0.50000    0.26809
## reputationhigh:sexmale                            -0.05263    0.26809
## expressionexci:sexmale                             0.05263    0.26809
## racewhite:sexmale                                 -0.30702    0.26809
## reputationmod:expressionexci:racewhite             0.82456    0.37914
## reputationhigh:expressionexci:racewhite           -0.35965    0.37914
## reputationmod:expressionexci:sexmale               0.10526    0.37914
## reputationhigh:expressionexci:sexmale             -0.39474    0.37914
## reputationmod:racewhite:sexmale                    0.42105    0.37914
## reputationhigh:racewhite:sexmale                   0.34211    0.37914
## expressionexci:racewhite:sexmale                   0.25439    0.37914
## reputationmod:expressionexci:racewhite:sexmale    -0.11404    0.53618
## reputationhigh:expressionexci:racewhite:sexmale    0.03509    0.53618
##                                                         df t value
## (Intercept)                                       58.77902  -0.212
## reputationmod                                   2678.99999  16.011
## reputationhigh                                  2678.99999  26.885
## expressionexci                                  2678.99999   0.602
## racewhite                                       2678.99999   2.082
## sexmale                                         2678.99999   1.666
## FamSES240-50K                                     57.00002   2.610
## FamSES250-75K                                     57.00002   1.454
## FamSES275-100K                                    57.00002   1.298
## FamSES2>100K                                      57.00002   2.211
## reputationmod:expressionexci                    2678.99999  -2.290
## reputationhigh:expressionexci                   2678.99999   1.243
## reputationmod:racewhite                         2678.99999  -2.650
## reputationhigh:racewhite                        2678.99999  -0.687
## expressionexci:racewhite                        2678.99999  -1.505
## reputationmod:sexmale                           2678.99999  -1.865
## reputationhigh:sexmale                          2678.99999  -0.196
## expressionexci:sexmale                          2678.99999   0.196
## racewhite:sexmale                               2678.99999  -1.145
## reputationmod:expressionexci:racewhite          2678.99999   2.175
## reputationhigh:expressionexci:racewhite         2678.99999  -0.949
## reputationmod:expressionexci:sexmale            2678.99999   0.278
## reputationhigh:expressionexci:sexmale           2678.99999  -1.041
## reputationmod:racewhite:sexmale                 2678.99999   1.111
## reputationhigh:racewhite:sexmale                2678.99999   0.902
## expressionexci:racewhite:sexmale                2678.99999   0.671
## reputationmod:expressionexci:racewhite:sexmale  2679.00000  -0.213
## reputationhigh:expressionexci:racewhite:sexmale 2678.99999   0.065
##                                                 Pr(>|t|)    
## (Intercept)                                      0.83306    
## reputationmod                                    < 2e-16 ***
## reputationhigh                                   < 2e-16 ***
## expressionexci                                   0.54752    
## racewhite                                        0.03741 *  
## sexmale                                          0.09586 .  
## FamSES240-50K                                    0.01155 *  
## FamSES250-75K                                    0.15150    
## FamSES275-100K                                   0.19945    
## FamSES2>100K                                     0.03105 *  
## reputationmod:expressionexci                     0.02207 *  
## reputationhigh:expressionexci                    0.21384    
## reputationmod:racewhite                          0.00809 ** 
## reputationhigh:racewhite                         0.49206    
## expressionexci:racewhite                         0.13241    
## reputationmod:sexmale                            0.06228 .  
## reputationhigh:sexmale                           0.84437    
## expressionexci:sexmale                           0.84437    
## racewhite:sexmale                                0.25223    
## reputationmod:expressionexci:racewhite           0.02973 *  
## reputationhigh:expressionexci:racewhite          0.34291    
## reputationmod:expressionexci:sexmale             0.78131    
## reputationhigh:expressionexci:sexmale            0.29790    
## reputationmod:racewhite:sexmale                  0.26686    
## reputationhigh:racewhite:sexmale                 0.36696    
## expressionexci:racewhite:sexmale                 0.50230    
## reputationmod:expressionexci:racewhite:sexmale   0.83159    
## reputationhigh:expressionexci:racewhite:sexmale  0.94783    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation matrix not shown by default, as p = 28 > 12.
## Use print(x, correlation=TRUE)  or
##     vcov(x)        if you need it
#To see all contrasts (not just with reference category), re-level reputation and run again:
Data_Females$reputation <- relevel(Data_Females$reputation, ref = "mod")
model2 <- lmer(data = Data_Females, response ~ reputation * expression * race * sex + FamSES2 + (1|pID), REML=FALSE)
summary(model2)
## Linear mixed model fit by maximum likelihood . t-tests use
##   Satterthwaite's method [lmerModLmerTest]
## Formula: response ~ reputation * expression * race * sex + FamSES2 + (1 |  
##     pID)
##    Data: Data_Females
## 
##      AIC      BIC   logLik deviance df.resid 
##  10011.6  10189.0  -4975.8   9951.6     2706 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.9127 -0.5205 -0.0172  0.5160  4.6117 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  pID      (Intercept) 2.181    1.477   
##  Residual             2.048    1.431   
## Number of obs: 2736, groups:  pID, 57
## 
## Fixed effects:
##                                                   Estimate Std. Error
## (Intercept)                                        2.81012    1.06254
## reputationlow                                     -3.03509    0.18957
## reputationhigh                                     2.06140    0.18957
## expressionexci                                    -0.50000    0.18957
## racewhite                                         -0.31579    0.18957
## sexmale                                           -0.18421    0.18957
## FamSES240-50K                                      3.12054    1.19559
## FamSES250-75K                                      1.67917    1.15505
## FamSES275-100K                                     1.47035    1.13262
## FamSES2>100K                                       2.42292    1.09577
## reputationlow:expressionexci                       0.61404    0.26809
## reputationhigh:expressionexci                      0.94737    0.26809
## reputationlow:racewhite                            0.71053    0.26809
## reputationhigh:racewhite                           0.52632    0.26809
## expressionexci:racewhite                           0.42105    0.26809
## reputationlow:sexmale                              0.50000    0.26809
## reputationhigh:sexmale                             0.44737    0.26809
## expressionexci:sexmale                             0.15789    0.26809
## racewhite:sexmale                                  0.11404    0.26809
## reputationlow:expressionexci:racewhite            -0.82456    0.37914
## reputationhigh:expressionexci:racewhite           -1.18421    0.37914
## reputationlow:expressionexci:sexmale              -0.10526    0.37914
## reputationhigh:expressionexci:sexmale             -0.50000    0.37914
## reputationlow:racewhite:sexmale                   -0.42105    0.37914
## reputationhigh:racewhite:sexmale                  -0.07895    0.37914
## expressionexci:racewhite:sexmale                   0.14035    0.37914
## reputationlow:expressionexci:racewhite:sexmale     0.11404    0.53618
## reputationhigh:expressionexci:racewhite:sexmale    0.14912    0.53618
##                                                         df t value
## (Intercept)                                       58.77901   2.645
## reputationlow                                   2679.00001 -16.011
## reputationhigh                                  2679.00001  10.874
## expressionexci                                  2679.00001  -2.638
## racewhite                                       2679.00001  -1.666
## sexmale                                         2679.00001  -0.972
## FamSES240-50K                                     57.00000   2.610
## FamSES250-75K                                     57.00000   1.454
## FamSES275-100K                                    57.00000   1.298
## FamSES2>100K                                      57.00000   2.211
## reputationlow:expressionexci                    2679.00001   2.290
## reputationhigh:expressionexci                   2679.00001   3.534
## reputationlow:racewhite                         2679.00001   2.650
## reputationhigh:racewhite                        2679.00000   1.963
## expressionexci:racewhite                        2679.00001   1.571
## reputationlow:sexmale                           2679.00001   1.865
## reputationhigh:sexmale                          2679.00000   1.669
## expressionexci:sexmale                          2679.00001   0.589
## racewhite:sexmale                               2679.00001   0.425
## reputationlow:expressionexci:racewhite          2679.00000  -2.175
## reputationhigh:expressionexci:racewhite         2679.00000  -3.123
## reputationlow:expressionexci:sexmale            2679.00000  -0.278
## reputationhigh:expressionexci:sexmale           2679.00000  -1.319
## reputationlow:racewhite:sexmale                 2679.00000  -1.111
## reputationhigh:racewhite:sexmale                2679.00000  -0.208
## expressionexci:racewhite:sexmale                2679.00000   0.370
## reputationlow:expressionexci:racewhite:sexmale  2679.00000   0.213
## reputationhigh:expressionexci:racewhite:sexmale 2679.00000   0.278
##                                                 Pr(>|t|)    
## (Intercept)                                     0.010469 *  
## reputationlow                                    < 2e-16 ***
## reputationhigh                                   < 2e-16 ***
## expressionexci                                  0.008398 ** 
## racewhite                                       0.095862 .  
## sexmale                                         0.331267    
## FamSES240-50K                                   0.011546 *  
## FamSES250-75K                                   0.151496    
## FamSES275-100K                                  0.199451    
## FamSES2>100K                                    0.031052 *  
## reputationlow:expressionexci                    0.022075 *  
## reputationhigh:expressionexci                   0.000417 ***
## reputationlow:racewhite                         0.008088 ** 
## reputationhigh:racewhite                        0.049725 *  
## expressionexci:racewhite                        0.116400    
## reputationlow:sexmale                           0.062283 .  
## reputationhigh:sexmale                          0.095287 .  
## expressionexci:sexmale                          0.555935    
## racewhite:sexmale                               0.670606    
## reputationlow:expressionexci:racewhite          0.029729 *  
## reputationhigh:expressionexci:racewhite         0.001807 ** 
## reputationlow:expressionexci:sexmale            0.781310    
## reputationhigh:expressionexci:sexmale           0.187352    
## reputationlow:racewhite:sexmale                 0.266857    
## reputationhigh:racewhite:sexmale                0.835065    
## expressionexci:racewhite:sexmale                0.711272    
## reputationlow:expressionexci:racewhite:sexmale  0.831592    
## reputationhigh:expressionexci:racewhite:sexmale 0.780940    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation matrix not shown by default, as p = 28 > 12.
## Use print(x, correlation=TRUE)  or
##     vcov(x)        if you need it
#Model comparison
anova(model1, model2)
## Data: Data_Females
## Models:
## model1: response ~ reputation * expression + (1 | pID)
## model2: response ~ reputation * expression * race * sex + FamSES2 + (1 | 
## model2:     pID)
##        Df   AIC   BIC  logLik deviance  Chisq Chi Df Pr(>Chisq)    
## model1  8 10017 10065 -5000.7  10001.3                             
## model2 30 10012 10189 -4975.8   9951.6 49.749     22   0.000634 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1