load(file="/Users/meganwilliams/Desktop/Dissertation/StroopMixed.rdata")
load(file="/Users/meganwilliams/Desktop/Dissertation/Allvars.rdata")
library(effects)
library(interactions)
library(rcompanion)
library(car)
SCWTlog1 <- glm(PsychAggress ~ StroopMixed + WRATtotal, data=StroopMixed,family = "binomial")
summary(SCWTlog1)
##
## Call:
## glm(formula = PsychAggress ~ StroopMixed + WRATtotal, family = "binomial",
## data = StroopMixed)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.3162 0.4310 0.5141 0.5971 0.8945
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.12669 0.73270 0.173 0.86273
## StroopMixed 0.03578 0.01327 2.695 0.00704 **
## WRATtotal 0.01227 0.01803 0.680 0.49637
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 452.04 on 547 degrees of freedom
## Residual deviance: 440.90 on 545 degrees of freedom
## AIC: 446.9
##
## Number of Fisher Scoring iterations: 4
confint(SCWTlog1)
## 2.5 % 97.5 %
## (Intercept) -1.286570015 1.59571559
## StroopMixed 0.009907112 0.06205782
## WRATtotal -0.023723023 0.04716155
exp(cbind(OR = coef(SCWTlog1), confint(SCWTlog1)))
## OR 2.5 % 97.5 %
## (Intercept) 1.135063 0.2762166 4.931857
## StroopMixed 1.036423 1.0099563 1.064024
## WRATtotal 1.012341 0.9765562 1.048291
#Wald chi-square Test
Anova(SCWTlog1, type="II", test="Wald")
## Analysis of Deviance Table (Type II tests)
##
## Response: PsychAggress
## Df Chisq Pr(>Chisq)
## StroopMixed 1 7.2637 0.007036 **
## WRATtotal 1 0.4627 0.496372
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Plots
plot(predictorEffect("StroopMixed",SCWTlog1))
########Compare to null model
#Difference in Deviance
with(SCWTlog1,null.deviance - deviance)
## [1] 11.14145
#Degrees of freedom for the difference between two models
with(SCWTlog1,df.null - df.residual)
## [1] 2
#p-value
with(SCWTlog1,pchisq(null.deviance-deviance,df.null-df.residual,lower.tail=FALSE))
## [1] 0.003807722
#Pseudo R-Squared
nagelkerke(SCWTlog1)
## $Models
##
## Model: "glm, PsychAggress ~ StroopMixed + WRATtotal, binomial, StroopMixed"
## Null: "glm, PsychAggress ~ 1, binomial, StroopMixed"
##
## $Pseudo.R.squared.for.model.vs.null
## Pseudo.R.squared
## McFadden 0.0246471
## Cox and Snell (ML) 0.0201258
## Nagelkerke (Cragg and Uhler) 0.0358291
##
## $Likelihood.ratio.test
## Df.diff LogLik.diff Chisq p.value
## -2 -5.5707 11.141 0.0038077
##
## $Number.of.observations
##
## Model: 548
## Null: 548
##
## $Messages
## [1] "Note: For models fit with REML, these statistics are based on refitting with ML"
##
## $Warnings
## [1] "None"
SCWTlog3 <- glm(PsychAggress ~ (StroopMixed + Sex + PovStat)^3 + Age + WRATtotal, data = StroopMixed, family = "binomial")
summary(SCWTlog3)
##
## Call:
## glm(formula = PsychAggress ~ (StroopMixed + Sex + PovStat)^3 +
## Age + WRATtotal, family = "binomial", data = StroopMixed)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.3828 0.3929 0.5067 0.6024 0.9833
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.51878 1.25468 0.413 0.6793
## StroopMixed 0.04568 0.02265 2.016 0.0438 *
## SexMen 0.36679 0.92214 0.398 0.6908
## PovStatBelow 0.47415 1.32994 0.357 0.7215
## Age -0.01746 0.01506 -1.159 0.2463
## WRATtotal 0.01894 0.01836 1.032 0.3022
## StroopMixed:SexMen -0.02635 0.02888 -0.912 0.3615
## StroopMixed:PovStatBelow -0.01309 0.04323 -0.303 0.7621
## SexMen:PovStatBelow -0.12800 1.76637 -0.072 0.9422
## StroopMixed:SexMen:PovStatBelow 0.01670 0.05833 0.286 0.7747
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 452.04 on 547 degrees of freedom
## Residual deviance: 434.45 on 538 degrees of freedom
## AIC: 454.45
##
## Number of Fisher Scoring iterations: 5
confint(SCWTlog3)
## 2.5 % 97.5 %
## (Intercept) -1.933308023 2.99882242
## StroopMixed 0.002187172 0.09153845
## SexMen -1.446357087 2.18326044
## PovStatBelow -2.110003807 3.15042319
## Age -0.047217545 0.01196513
## WRATtotal -0.017581384 0.05460431
## StroopMixed:SexMen -0.083643507 0.02999360
## StroopMixed:PovStatBelow -0.096984597 0.07394836
## SexMen:PovStatBelow -3.603769499 3.36101186
## StroopMixed:SexMen:PovStatBelow -0.098817961 0.13091968
exp(cbind(OR = coef(SCWTlog3), confint(SCWTlog3)))
## OR 2.5 % 97.5 %
## (Intercept) 1.6799779 0.14466884 20.061899
## StroopMixed 1.0467372 1.00218957 1.095859
## SexMen 1.4430962 0.23542637 8.875196
## PovStatBelow 1.6066418 0.12123750 23.345942
## Age 0.9826880 0.95387986 1.012037
## WRATtotal 1.0191218 0.98257227 1.056123
## StroopMixed:SexMen 0.9739945 0.91975909 1.030448
## StroopMixed:PovStatBelow 0.9869981 0.90756999 1.076751
## SexMen:PovStatBelow 0.8798572 0.02722092 28.818336
## StroopMixed:SexMen:PovStatBelow 1.0168376 0.90590760 1.139876
#Wald chi-square Test
Anova(SCWTlog3, type="II", test="Wald")
## Analysis of Deviance Table (Type II tests)
##
## Response: PsychAggress
## Df Chisq Pr(>Chisq)
## StroopMixed 1 4.4237 0.03544 *
## Sex 1 1.6402 0.20030
## PovStat 1 0.8183 0.36567
## Age 1 1.3443 0.24627
## WRATtotal 1 1.0645 0.30220
## StroopMixed:Sex 1 0.7881 0.37469
## StroopMixed:PovStat 1 0.0182 0.89275
## Sex:PovStat 1 0.3890 0.53283
## StroopMixed:Sex:PovStat 1 0.0819 0.77470
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##Plots
plot(predictorEffect("StroopMixed",SCWTlog3))
########Compare to null model
#Difference in Deviance
with(SCWTlog3,null.deviance - deviance)
## [1] 17.58857
#Degrees of freedom for the difference between two models
with(SCWTlog3,df.null - df.residual)
## [1] 9
#p-value
with(SCWTlog3,pchisq(null.deviance-deviance,df.null-df.residual,lower.tail=FALSE))
## [1] 0.04025829
#Pseudo R-Squared
nagelkerke(SCWTlog3)
## $Models
##
## Model: "glm, PsychAggress ~ (StroopMixed + Sex + PovStat)^3 + Age + WRATtotal, binomial, StroopMixed"
## Null: "glm, PsychAggress ~ 1, binomial, StroopMixed"
##
## $Pseudo.R.squared.for.model.vs.null
## Pseudo.R.squared
## McFadden 0.0389094
## Cox and Snell (ML) 0.0315863
## Nagelkerke (Cragg and Uhler) 0.0562318
##
## $Likelihood.ratio.test
## Df.diff LogLik.diff Chisq p.value
## -9 -8.7943 17.589 0.040258
##
## $Number.of.observations
##
## Model: 548
## Null: 548
##
## $Messages
## [1] "Note: For models fit with REML, these statistics are based on refitting with ML"
##
## $Warnings
## [1] "None"
anova(SCWTlog1,SCWTlog3,test = "LR")
## Analysis of Deviance Table
##
## Model 1: PsychAggress ~ StroopMixed + WRATtotal
## Model 2: PsychAggress ~ (StroopMixed + Sex + PovStat)^3 + Age + WRATtotal
## Resid. Df Resid. Dev Df Deviance Pr(>Chi)
## 1 545 440.90
## 2 538 434.45 7 6.4471 0.4886
SCWTlog1 <- glm(PhysAssault ~ StroopMixed + WRATtotal, data=StroopMixed,family = "binomial")
summary(SCWTlog1)
##
## Call:
## glm(formula = PhysAssault ~ StroopMixed + WRATtotal, family = "binomial",
## data = StroopMixed)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.5774 -0.5127 -0.4892 -0.4591 2.1881
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -2.857230 0.879721 -3.248 0.00116 **
## StroopMixed 0.006762 0.014340 0.472 0.63727
## WRATtotal 0.013278 0.021393 0.621 0.53481
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 391.02 on 547 degrees of freedom
## Residual deviance: 389.95 on 545 degrees of freedom
## AIC: 395.95
##
## Number of Fisher Scoring iterations: 4
confint(SCWTlog1)
## 2.5 % 97.5 %
## (Intercept) -4.66188126 -1.20130341
## StroopMixed -0.02126234 0.03505183
## WRATtotal -0.02756450 0.05653464
exp(cbind(OR = coef(SCWTlog1), confint(SCWTlog1)))
## OR 2.5 % 97.5 %
## (Intercept) 0.05742761 0.00944867 0.3008019
## StroopMixed 1.00678464 0.97896211 1.0356734
## WRATtotal 1.01336672 0.97281194 1.0581633
#Wald chi-square Test
Anova(SCWTlog1, type="II", test="Wald")
## Analysis of Deviance Table (Type II tests)
##
## Response: PhysAssault
## Df Chisq Pr(>Chisq)
## StroopMixed 1 0.2223 0.6373
## WRATtotal 1 0.3853 0.5348
########Compare to null model
#Difference in Deviance
with(SCWTlog1,null.deviance - deviance)
## [1] 1.070213
#Degrees of freedom for the difference between two models
with(SCWTlog1,df.null - df.residual)
## [1] 2
#p-value
with(SCWTlog1,pchisq(null.deviance-deviance,df.null-df.residual,lower.tail=FALSE))
## [1] 0.5856069
#Pseudo R-Squared
nagelkerke(SCWTlog1)
## $Models
##
## Model: "glm, PhysAssault ~ StroopMixed + WRATtotal, binomial, StroopMixed"
## Null: "glm, PhysAssault ~ 1, binomial, StroopMixed"
##
## $Pseudo.R.squared.for.model.vs.null
## Pseudo.R.squared
## McFadden 0.00273699
## Cox and Snell (ML) 0.00195104
## Nagelkerke (Cragg and Uhler) 0.00382488
##
## $Likelihood.ratio.test
## Df.diff LogLik.diff Chisq p.value
## -2 -0.53511 1.0702 0.58561
##
## $Number.of.observations
##
## Model: 548
## Null: 548
##
## $Messages
## [1] "Note: For models fit with REML, these statistics are based on refitting with ML"
##
## $Warnings
## [1] "None"
SCWTlog3 <- glm(PhysAssault ~ (StroopMixed + Sex + PovStat)^3 + Age + WRATtotal, data = StroopMixed, family = "binomial")
summary(SCWTlog3)
##
## Call:
## glm(formula = PhysAssault ~ (StroopMixed + Sex + PovStat)^3 +
## Age + WRATtotal, family = "binomial", data = StroopMixed)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.8174 -0.5564 -0.4236 -0.3232 2.5111
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -2.78652 1.43745 -1.939 0.0526 .
## StroopMixed 0.02099 0.02257 0.930 0.3524
## SexMen 1.84015 1.24297 1.480 0.1388
## PovStatBelow 1.24604 1.35126 0.922 0.3565
## Age -0.02924 0.01667 -1.754 0.0794 .
## WRATtotal 0.02940 0.02237 1.314 0.1888
## StroopMixed:SexMen -0.07248 0.03617 -2.004 0.0451 *
## StroopMixed:PovStatBelow -0.02215 0.03823 -0.579 0.5623
## SexMen:PovStatBelow -2.03683 1.95253 -1.043 0.2969
## StroopMixed:SexMen:PovStatBelow 0.07915 0.05825 1.359 0.1742
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 391.02 on 547 degrees of freedom
## Residual deviance: 371.47 on 538 degrees of freedom
## AIC: 391.47
##
## Number of Fisher Scoring iterations: 5
confint(SCWTlog3)
## 2.5 % 97.5 %
## (Intercept) -5.66663487 -0.016991478
## StroopMixed -0.02299517 0.065885642
## SexMen -0.63428162 4.271705151
## PovStatBelow -1.46094828 3.874539036
## Age -0.06242361 0.003099514
## WRATtotal -0.01319397 0.074756970
## StroopMixed:SexMen -0.14463657 -0.002266140
## StroopMixed:PovStatBelow -0.09735843 0.053418320
## SexMen:PovStatBelow -5.89405066 1.798465502
## StroopMixed:SexMen:PovStatBelow -0.03451700 0.194549935
exp(cbind(OR = coef(SCWTlog3), confint(SCWTlog3)))
## OR 2.5 % 97.5 %
## (Intercept) 0.06163505 0.003459487 0.9831521
## StroopMixed 1.02121051 0.977267205 1.0681046
## SexMen 6.29748378 0.530316321 71.6436948
## PovStatBelow 3.47654803 0.232016154 48.1604929
## Age 0.97118439 0.939484830 1.0031043
## WRATtotal 1.02983659 0.986892686 1.0776222
## StroopMixed:SexMen 0.93008782 0.865336727 0.9977364
## StroopMixed:PovStatBelow 0.97809470 0.907230769 1.0548708
## SexMen:PovStatBelow 0.13044162 0.002755791 6.0403714
## StroopMixed:SexMen:PovStatBelow 1.08236894 0.966071912 1.2147641
#Wald chi-square Test
Anova(SCWTlog3, type="II", test="Wald")
## Analysis of Deviance Table (Type II tests)
##
## Response: PhysAssault
## Df Chisq Pr(>Chisq)
## StroopMixed 1 0.0095 0.92233
## Sex 1 0.8907 0.34528
## PovStat 1 5.3218 0.02106 *
## Age 1 3.0774 0.07939 .
## WRATtotal 1 1.7272 0.18877
## StroopMixed:Sex 1 2.1901 0.13890
## StroopMixed:PovStat 1 0.1705 0.67966
## Sex:PovStat 1 0.7309 0.39260
## StroopMixed:Sex:PovStat 1 1.8464 0.17420
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##Plots
interact_plot(model = SCWTlog3, pred = StroopMixed, modx = Sex)
sim_slopes(SCWTlog3, pred = StroopMixed, modx = Sex, centered = "all",jnplot = TRUE)
## Warning: Johnson-Neyman intervals are not available for factor moderators.
## SIMPLE SLOPES ANALYSIS
##
## Slope of StroopMixed when Sex = Men:
##
## Est. S.E. z val. p
## ------- ------ -------- ------
## -0.03 0.02 -1.42 0.16
##
## Slope of StroopMixed when Sex = Women:
##
## Est. S.E. z val. p
## ------ ------ -------- ------
## 0.01 0.02 0.74 0.46
########Compare to null model
#Difference in Deviance
with(SCWTlog3,null.deviance - deviance)
## [1] 19.55291
#Degrees of freedom for the difference between two models
with(SCWTlog3,df.null - df.residual)
## [1] 9
#p-value
with(SCWTlog3,pchisq(null.deviance-deviance,df.null-df.residual,lower.tail=FALSE))
## [1] 0.02088115
#Pseudo R-Squared
nagelkerke(SCWTlog3)
## $Models
##
## Model: "glm, PhysAssault ~ (StroopMixed + Sex + PovStat)^3 + Age + WRATtotal, binomial, StroopMixed"
## Null: "glm, PhysAssault ~ 1, binomial, StroopMixed"
##
## $Pseudo.R.squared.for.model.vs.null
## Pseudo.R.squared
## McFadden 0.0500051
## Cox and Snell (ML) 0.0350515
## Nagelkerke (Cragg and Uhler) 0.0687160
##
## $Likelihood.ratio.test
## Df.diff LogLik.diff Chisq p.value
## -9 -9.7765 19.553 0.020881
##
## $Number.of.observations
##
## Model: 548
## Null: 548
##
## $Messages
## [1] "Note: For models fit with REML, these statistics are based on refitting with ML"
##
## $Warnings
## [1] "None"
anova(SCWTlog1,SCWTlog3,test = "LR")
## Analysis of Deviance Table
##
## Model 1: PhysAssault ~ StroopMixed + WRATtotal
## Model 2: PhysAssault ~ (StroopMixed + Sex + PovStat)^3 + Age + WRATtotal
## Resid. Df Resid. Dev Df Deviance Pr(>Chi)
## 1 545 389.95
## 2 538 371.47 7 18.483 0.009972 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1