## 
## Attaching package: 'ggplot2'
## The following objects are masked from 'package:psych':
## 
##     %+%, alpha
## Loading required package: Matrix
## 
## Attaching package: 'lmerTest'
## The following object is masked from 'package:lme4':
## 
##     lmer
## The following object is masked from 'package:stats':
## 
##     step
## 
## Attaching package: 'plyr'
## The following object is masked from 'package:ggpubr':
## 
##     mutate
## 
## Attaching package: 'tidyr'
## The following objects are masked from 'package:Matrix':
## 
##     expand, pack, unpack
## Registered S3 methods overwritten by 'parameters':
##   method                           from      
##   as.double.parameters_kurtosis    datawizard
##   as.double.parameters_skewness    datawizard
##   as.double.parameters_smoothness  datawizard
##   as.numeric.parameters_kurtosis   datawizard
##   as.numeric.parameters_skewness   datawizard
##   as.numeric.parameters_smoothness datawizard
##   print.parameters_distribution    datawizard
##   print.parameters_kurtosis        datawizard
##   print.parameters_skewness        datawizard
##   summary.parameters_kurtosis      datawizard
##   summary.parameters_skewness      datawizard
## Loading required package: carData
## 
## Attaching package: 'car'
## The following object is masked from 'package:psych':
## 
##     logit
## Number of categories should be increased  in order to count frequencies.
## 
## Reliability analysis   
## Call: psych::alpha(x = d2[c("trustworthy", "moral", "ethical", "helpful", 
##     "honest", "sincere")])
## 
##   raw_alpha std.alpha G6(smc) average_r S/N     ase mean   sd median_r
##       0.98      0.98    0.97      0.88  45 0.00024    3 0.45     0.88
## 
##  lower alpha upper     95% confidence boundaries
## 0.98 0.98 0.98 
## 
##  Reliability if an item is dropped:
##             raw_alpha std.alpha G6(smc) average_r S/N alpha se   var.r med.r
## trustworthy      0.97      0.97    0.97      0.87  35  0.00032 0.00019  0.87
## moral            0.97      0.97    0.97      0.88  37  0.00030 0.00026  0.88
## ethical          0.97      0.97    0.97      0.88  38  0.00029 0.00029  0.88
## helpful          0.97      0.98    0.97      0.89  39  0.00028 0.00029  0.89
## honest           0.97      0.97    0.97      0.88  37  0.00030 0.00038  0.88
## sincere          0.97      0.97    0.97      0.89  39  0.00029 0.00021  0.88
## 
##  Item statistics 
##                 n raw.r std.r r.cor r.drop mean   sd
## trustworthy 18900  0.96  0.96  0.96   0.95  3.2 0.52
## moral       18900  0.95  0.95  0.94   0.93  3.0 0.43
## ethical     18900  0.94  0.95  0.93   0.92  3.0 0.43
## helpful     18900  0.94  0.94  0.92   0.91  2.9 0.48
## honest      18900  0.95  0.95  0.94   0.93  3.1 0.49
## sincere     18900  0.94  0.94  0.93   0.92  3.0 0.47
## 
## When a personâ\200\231s attention is drawn to a new personâ\200\231s face, they are more likely to find that person trustworthy compared with someone their attention is not drawn to. 
##                                                                                                                                                                       4025 
##               When a personâ\200\231s attention is drawn to an attractive personâ\200\231s face, the person will trust the attractive person more quickly than an unattractive person. 
##                                                                                                                                                                       1425 
##        When making evaluations of trustworthiness about others, people are more likely to judge attractive individuals are more trustworthy than unattractive individuals. 
##                                                                                                                                                                       2475 
##  When people are asked to evaluate trustworthiness of strangers, people are more likely to trust individuals with child-like facial traits (i.e., round face, large eyes). 
##                                                                                                                                                                       1875
## [1] 0.4107143

1. cft ~ 1 + (1|pt)

m1 <- glmer(cuedFaceTrusted_1 ~ 1 +
              (1 | participant), family = binomial(), data = d)
summary(m1)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: cuedFaceTrusted_1 ~ 1 + (1 | participant)
##    Data: d
## 
##      AIC      BIC   logLik deviance df.resid 
##  13584.3  13598.7  -6790.1  13580.3     9798 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.1064 -1.0044  0.9136  0.9850  1.0966 
## 
## Random effects:
##  Groups      Name        Variance Std.Dev.
##  participant (Intercept) 0.0248   0.1575  
## Number of obs: 9800, groups:  participant, 392
## 
## Fixed effects:
##             Estimate Std. Error z value Pr(>|z|)
## (Intercept)  0.02259    0.02177   1.038    0.299
beta <- exp(0.02259)
pTrust <-(beta/(1+beta))
beta
## [1] 1.022847
pTrust
## [1] 0.5056473
pNotTrust <- (1-pTrust)
g <- cbind(pTrust, pNotTrust)

barplot(g, ylim = c(.48,.52), col = "yellow")

#graphing
plot_new <- data.frame(
  choice = c("trusted","not trusted"), 
  probFaceTrusted = c( pTrust, pNotTrust))

ggplot(data = plot_new, aes(x = choice, y = probFaceTrusted, fill = choice)) + 
  geom_bar(stat="identity", position = position_dodge()) + 
  geom_text(aes(label = round(probFaceTrusted, digits = 4)), vjust=1.6, color="black", position = position_dodge(0.9), size=3.5) + 
  theme_minimal() + 
  ylab("probability of cued face...") +
  coord_cartesian(ylim = c(0.48, .52)) 


Interpretation: \(\beta_0\): collapsing across conditions, there is no difference between trusting cued and uncued face, p_trust = .506, p_nottrust = .494, p = .299 ***

m2 <- glmer(cuedFaceTrusted_1 ~ trust_.5 + 
              (1 | participant), family = binomial("logit"), data = d)

summary(m2)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: cuedFaceTrusted_1 ~ trust_.5 + (1 | participant)
##    Data: d
## 
##      AIC      BIC   logLik deviance df.resid 
##  13585.7  13607.2  -6789.8  13579.7     9797 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.1133 -1.0074  0.9079  0.9822  1.0924 
## 
## Random effects:
##  Groups      Name        Variance Std.Dev.
##  participant (Intercept) 0.02452  0.1566  
## Number of obs: 9800, groups:  participant, 392
## 
## Fixed effects:
##             Estimate Std. Error z value Pr(>|z|)
## (Intercept)  0.02181    0.02178   1.002    0.317
## trust_.5     0.03416    0.04356   0.784    0.433
## 
## Correlation of Fixed Effects:
##          (Intr)
## trust_.5 -0.046
m2t <- glmer(cuedFaceTrusted_1 ~ trustYes_0 + 
              (1 | participant), family = binomial("logit"), data = d)

summary(m2t)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: cuedFaceTrusted_1 ~ trustYes_0 + (1 | participant)
##    Data: d
## 
##      AIC      BIC   logLik deviance df.resid 
##  13585.7  13607.2  -6789.8  13579.7     9797 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.1133 -1.0074  0.9079  0.9822  1.0924 
## 
## Random effects:
##  Groups      Name        Variance Std.Dev.
##  participant (Intercept) 0.02452  0.1566  
## Number of obs: 9800, groups:  participant, 392
## 
## Fixed effects:
##             Estimate Std. Error z value Pr(>|z|)
## (Intercept)  0.03889    0.03009   1.293    0.196
## trustYes_0  -0.03416    0.04356  -0.784    0.433
## 
## Correlation of Fixed Effects:
##            (Intr)
## trustYes_0 -0.691
m2nt <- glmer(cuedFaceTrusted_1 ~ trustNo_0 + 
              (1 | participant), family = binomial("logit"), data = d)

summary(m2nt)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: cuedFaceTrusted_1 ~ trustNo_0 + (1 | participant)
##    Data: d
## 
##      AIC      BIC   logLik deviance df.resid 
##  13585.7  13607.2  -6789.8  13579.7     9797 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.1133 -1.0074  0.9079  0.9822  1.0924 
## 
## Random effects:
##  Groups      Name        Variance Std.Dev.
##  participant (Intercept) 0.02452  0.1566  
## Number of obs: 9800, groups:  participant, 392
## 
## Fixed effects:
##             Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.004731   0.031494   0.150    0.881
## trustNo_0   0.034159   0.043557   0.784    0.433
## 
## Correlation of Fixed Effects:
##           (Intr)
## trustNo_0 -0.723
#trust condition
beta <- exp(0.03889)
pTtrust <-(beta/(1+beta))
beta
## [1] 1.039656
pTtrust
## [1] 0.5097213
pTnottrust <- (1-pTtrust)

#not trust condition
beta <- exp(0.004731)
pNTtrust <-(beta/(1+beta))
beta
## [1] 1.004742
pNTtrust
## [1] 0.5011827
pNTnottrust <- (1-pNTtrust)

#graphing
plot_new2 <- data.frame(
  condition = c("trust", "trust", "not trust", "not trust"), 
  probFaceTrusted = c( pTtrust, pTnottrust, pNTtrust, pNTnottrust),
  attention = c("cued", "uncued", "cued", "uncued"))

ggplot(data = plot_new2, aes(x = condition, y = probFaceTrusted, fill = attention)) + 
  geom_bar(stat="identity", position = position_dodge()) + 
  geom_text(aes(label = round(probFaceTrusted, digits = 4)), vjust=1.6, color="black", position = position_dodge(0.9), size=3.5) + 
  theme_minimal() + 
  ylab("probability of face trusted") +
  coord_cartesian(ylim = c(0.48, .52)) 

3. cft ~ trust_condition + stim_gender + side_cued + (1|pt)

m3 <- glmer(cuedFaceTrusted_1 ~ trust_.5 + sideCuedRight_.5 + stim_female_.5 +
              (1 | participant), family = binomial, data = d)
summary(m3)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: cuedFaceTrusted_1 ~ trust_.5 + sideCuedRight_.5 + stim_female_.5 +  
##     (1 | participant)
##    Data: d
## 
##      AIC      BIC   logLik deviance df.resid 
##  13587.3  13623.3  -6788.7  13577.3     9795 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.1304 -1.0041  0.9025  0.9856  1.1088 
## 
## Random effects:
##  Groups      Name        Variance Std.Dev.
##  participant (Intercept) 0.02441  0.1562  
## Number of obs: 9800, groups:  participant, 392
## 
## Fixed effects:
##                  Estimate Std. Error z value Pr(>|z|)
## (Intercept)      0.020895   0.022365   0.934    0.350
## trust_.5         0.034151   0.043549   0.784    0.433
## sideCuedRight_.5 0.061711   0.040634   1.519    0.129
## stim_female_.5   0.006156   0.041871   0.147    0.883
## 
## Correlation of Fixed Effects:
##             (Intr) trs_.5 sCR_.5
## trust_.5    -0.045              
## sdCdRght_.5 -0.005  0.000       
## stim_fml_.5 -0.228  0.003  0.001
tab_model(m3)
  cuedFaceTrusted_1
Predictors Odds Ratios CI p
(Intercept) 1.02 0.98 – 1.07 0.350
trust_.5 1.03 0.95 – 1.13 0.433
sideCuedRight_.5 1.06 0.98 – 1.15 0.129
stim_female_.5 1.01 0.93 – 1.09 0.883
Random Effects
σ2 3.29
τ00 participant 0.02
ICC 0.01
N participant 392
Observations 9800
Marginal R2 / Conditional R2 0.000 / 0.008
plot(ggpredict(m3, "trust_.5"))

beta<-exp(0.034151)
beta/(1+beta) #[1] 0.5085369
## [1] 0.5085369

4. cft ~ trust + sim_gender + side cued + (side cued | pt) | & || singular

m4 <- glmer(cuedFaceTrusted_1 ~ trust_.5 + stim_female_.5 + sideCuedRight_.5 +
              (sideCuedRight_.5 | participant), family=binomial, data=d)
## boundary (singular) fit: see ?isSingular
summary(m4)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: cuedFaceTrusted_1 ~ trust_.5 + stim_female_.5 + sideCuedRight_.5 +  
##     (sideCuedRight_.5 | participant)
##    Data: d
## 
##      AIC      BIC   logLik deviance df.resid 
##  13590.7  13641.0  -6788.3  13576.7     9793 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.1599 -1.0014  0.8886  0.9865  1.1106 
## 
## Random effects:
##  Groups      Name             Variance Std.Dev. Corr
##  participant (Intercept)      0.02553  0.15979      
##              sideCuedRight_.5 0.00374  0.06115  1.00
## Number of obs: 9800, groups:  participant, 392
## 
## Fixed effects:
##                  Estimate Std. Error z value Pr(>|z|)
## (Intercept)      0.020915   0.022435   0.932    0.351
## trust_.5         0.034121   0.043677   0.781    0.435
## stim_female_.5   0.006377   0.041885   0.152    0.879
## sideCuedRight_.5 0.061903   0.040763   1.519    0.129
## 
## Correlation of Fixed Effects:
##             (Intr) trs_.5 st__.5
## trust_.5    -0.045              
## stim_fml_.5 -0.228  0.004       
## sdCdRght_.5  0.025  0.000  0.001
## optimizer (Nelder_Mead) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
plot(ggpredict(m3, "trust_.5"))

5. cft ~ trust + side cued + stim gender + (1|pt) + (1 | faceLeft) + (1 | face Right) | & || singular

m5 <- glmer(cuedFaceTrusted_1 ~ trust_.5 + sideCuedRight_.5 + stim_female_.5 + 
              (1 | participant) + (1 | faceRight) + (1 | faceLeft), family = binomial, data = d)
## boundary (singular) fit: see ?isSingular
summary(m5) 
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: cuedFaceTrusted_1 ~ trust_.5 + sideCuedRight_.5 + stim_female_.5 +  
##     (1 | participant) + (1 | faceRight) + (1 | faceLeft)
##    Data: d
## 
##      AIC      BIC   logLik deviance df.resid 
##  13591.3  13641.7  -6788.7  13577.3     9793 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.1301 -1.0041  0.9020  0.9851  1.1089 
## 
## Random effects:
##  Groups      Name        Variance  Std.Dev.
##  participant (Intercept) 0.0243943 0.15619 
##  faceRight   (Intercept) 0.0005001 0.02236 
##  faceLeft    (Intercept) 0.0000000 0.00000 
## Number of obs: 9800, groups:  participant, 392; faceRight, 93; faceLeft, 93
## 
## Fixed effects:
##                  Estimate Std. Error z value Pr(>|z|)
## (Intercept)      0.020909   0.022504   0.929    0.353
## trust_.5         0.034173   0.043551   0.785    0.433
## sideCuedRight_.5 0.061709   0.040637   1.519    0.129
## stim_female_.5   0.006167   0.042171   0.146    0.884
## 
## Correlation of Fixed Effects:
##             (Intr) trs_.5 sCR_.5
## trust_.5    -0.045              
## sdCdRght_.5 -0.005  0.000       
## stim_fml_.5 -0.230  0.003  0.001
## optimizer (Nelder_Mead) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular

cft ~ trust + (1|pt) + (1|face)

m7 <- glmer(cuedFaceTrusted_1 ~ trust_.5 + 
              (1|pt) + 
              (1 | face), family = binomial("logit"), data = d2)
summary(m7)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: cuedFaceTrusted_1 ~ trust_.5 + (1 | pt) + (1 | face)
##    Data: d2
## 
##      AIC      BIC   logLik deviance df.resid 
##  26985.2  27016.8 -13488.6  26977.2    19596 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.5280 -0.9811  0.6905  0.9726  1.5812 
## 
## Random effects:
##  Groups Name        Variance  Std.Dev.
##  pt     (Intercept) 0.1133255 0.33664 
##  face   (Intercept) 0.0006741 0.02596 
## Number of obs: 19600, groups:  pt, 392; face, 93
## 
## Fixed effects:
##             Estimate Std. Error z value Pr(>|z|)
## (Intercept)  0.02263    0.02253   1.005    0.315
## trust_.5     0.03591    0.04472   0.803    0.422
## 
## Correlation of Fixed Effects:
##          (Intr)
## trust_.5 -0.044
tab_model(m7)
  cuedFaceTrusted_1
Predictors Odds Ratios CI p
(Intercept) 1.02 0.98 – 1.07 0.315
trust_.5 1.04 0.95 – 1.13 0.422
Random Effects
σ2 3.29
τ00 pt 0.11
τ00 face 0.00
ICC 0.03
N pt 392
N face 93
Observations 19600
Marginal R2 / Conditional R2 0.000 / 0.034
ggpredict(m7, "trust_.5")

cft ~ trust + (1|pt) + (trustworthy | face) | & || isSingular

trustworthy.m <- glmer(cuedFaceTrusted_1 ~ trust_.5 + 
              (1|pt) + 
              (trustworthy | face), family = binomial("logit"), data = d2)
## boundary (singular) fit: see ?isSingular
summary(trustworthy.m)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: cuedFaceTrusted_1 ~ trust_.5 + (1 | pt) + (trustworthy | face)
##    Data: d2
## 
##      AIC      BIC   logLik deviance df.resid 
##  26031.5  26078.6 -13009.7  26019.5    18894 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.5633 -0.9816  0.6936  0.9770  1.6063 
## 
## Random effects:
##  Groups Name        Variance Std.Dev. Corr 
##  pt     (Intercept) 0.111673 0.33417       
##  face   (Intercept) 0.008707 0.09331       
##         trustworthy 0.001754 0.04188  -1.00
## Number of obs: 18900, groups:  pt, 392; face, 90
## 
## Fixed effects:
##             Estimate Std. Error z value Pr(>|z|)
## (Intercept)  0.01963    0.02298   0.854    0.393
## trust_.5     0.04727    0.04488   1.053    0.292
## 
## Correlation of Fixed Effects:
##          (Intr)
## trust_.5 -0.044
## optimizer (Nelder_Mead) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
ggpredict(trustworthy.m, "trust_.5")

cft ~ trust + (1|pt) + ( overallTrust | face) | & || Singular

overall.m <- glmer(cuedFaceTrusted_1 ~ trust_.5 + 
              (1|pt) + 
              (overallTrust || face), family = binomial("logit"), data = d2)
## boundary (singular) fit: see ?isSingular
summary(overall.m)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: cuedFaceTrusted_1 ~ trust_.5 + (1 | pt) + (overallTrust || face)
##    Data: d2
## 
##      AIC      BIC   logLik deviance df.resid 
##  26029.8  26069.0 -13009.9  26019.8    18895 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.5635 -0.9810  0.6945  0.9756  1.5829 
## 
## Random effects:
##  Groups Name         Variance  Std.Dev. 
##  pt     (Intercept)  1.117e-01 3.342e-01
##  face   (Intercept)  1.277e-09 3.573e-05
##  face.1 overallTrust 2.046e-04 1.430e-02
## Number of obs: 18900, groups:  pt, 392; face, 90
## 
## Fixed effects:
##             Estimate Std. Error z value Pr(>|z|)
## (Intercept)  0.02020    0.02294   0.881    0.379
## trust_.5     0.04719    0.04489   1.051    0.293
## 
## Correlation of Fixed Effects:
##          (Intr)
## trust_.5 -0.043
## optimizer (Nelder_Mead) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
tab_model(overall.m)
  cuedFaceTrusted_1
Predictors Odds Ratios CI p
(Intercept) 1.02 0.98 – 1.07 0.379
trust_.5 1.05 0.96 – 1.14 0.293
Random Effects
σ2 3.29
τ00 pt 0.11
τ00 face 0.00
τ11 face.overallTrust 0.00
ρ01  
ρ01  
ICC 0.03
N pt 392
N face 90
Observations 18900
Marginal R2 / Conditional R2 0.000 / 0.033
ggpredict(overall.m, "trust_.5")