logTrails A Regression Model 2 Three-Way Interaction Plots Stratified by Gender

## Loading required package: Matrix
## Loading required package: mvtnorm
## Loading required package: TH.data
## Warning: number of observations <= rank(Z); variance-covariance matrix
## will be unidentifiable
## Linear mixed model fit by REML ['lmerMod']
## Formula: log(TrailsAtestSec) ~ Age + IPVstatus + PovStat + CES1 + (Age |      HNDid) + (1 | subclass) + Age:IPVstatus + Age:PovStat + Age:CES1 +      IPVstatus:PovStat + IPVstatus:CES1 + PovStat:CES1 + Age:IPVstatus:PovStat +      Age:IPVstatus:CES1 
##    Data: WomenlogTrailsA 
## REML criterion at convergence: 72.71 
## Random effects:
##  Groups   Name        Std.Dev. Corr
##  HNDid    (Intercept) 0.307        
##           Age         0.019    1.00
##  subclass (Intercept) 0.252        
##  Residual             0.206        
## Number of obs: 72, groups: HNDid, 36; subclass, 19
## Fixed Effects:
##                 (Intercept)                          Age  
##                      3.3549                       0.0108  
##                  IPVstatus1                 PovStatBelow  
##                      0.5179                      -0.0470  
##                       CES11               Age:IPVstatus1  
##                      0.5437                       0.0457  
##            Age:PovStatBelow                    Age:CES11  
##                     -0.0195                       0.0263  
##     IPVstatus1:PovStatBelow             IPVstatus1:CES11  
##                      1.1428                      -1.1419  
##          PovStatBelow:CES11  Age:IPVstatus1:PovStatBelow  
##                     -0.3517                       0.1122  
##        Age:IPVstatus1:CES11  
##                     -0.1001
## 
##   Simultaneous Tests for General Linear Hypotheses
## 
## Fit: lmer(formula = log(TrailsAtestSec) ~ Age + IPVstatus + PovStat + 
##     CES1 + (Age | HNDid) + (1 | subclass) + Age:IPVstatus + Age:PovStat + 
##     Age:CES1 + IPVstatus:PovStat + IPVstatus:CES1 + PovStat:CES1 + 
##     Age:IPVstatus:PovStat + Age:IPVstatus:CES1, data = WomenlogTrailsA, 
##     na.action = na.omit)
## 
## Linear Hypotheses:
##                                  Estimate Std. Error z value Pr(>|z|)
## (Intercept) == 0                   3.3549     0.1673   20.05   <2e-16
## Age == 0                           0.0108     0.0124    0.87   0.3823
## IPVstatus1 == 0                    0.5179     0.2980    1.74   0.0822
## PovStatBelow == 0                 -0.0470     0.2542   -0.19   0.8532
## CES11 == 0                         0.5437     0.2359    2.30   0.0212
## Age:IPVstatus1 == 0                0.0457     0.0253    1.81   0.0703
## Age:PovStatBelow == 0             -0.0195     0.0180   -1.09   0.2774
## Age:CES11 == 0                     0.0263     0.0174    1.51   0.1314
## IPVstatus1:PovStatBelow == 0       1.1428     0.4827    2.37   0.0179
## IPVstatus1:CES11 == 0             -1.1419     0.3943   -2.90   0.0038
## PovStatBelow:CES11 == 0           -0.3517     0.1655   -2.12   0.0336
## Age:IPVstatus1:PovStatBelow == 0   0.1122     0.0427    2.63   0.0085
## Age:IPVstatus1:CES11 == 0         -0.1001     0.0331   -3.02   0.0025
## (Univariate p values reported)

Age/IPV/Depression Note: Age/IPV/Depression interaction was significant for women

hatIPVcog1 = zMixHat(WomenlogTrailsA, mm2, vary = "Age=pAge, CES1=zQ(0,1),IPVstatus=zQ(0,1)", 
    fixedCov = c("PovStat"))

head(hatIPVcog1)
##   Age CES1 IPVstatus log TrailsAtestSec PovStat   hat
## 1  30    0         0   0              0  0.3333 3.468
## 2  31    0         0   0              0  0.3333 3.472
## 3  32    0         0   0              0  0.3333 3.476
## 4  33    0         0   0              0  0.3333 3.481
## 5  34    0         0   0              0  0.3333 3.485
## 6  35    0         0   0              0  0.3333 3.489

par(mar = c(4, 4, 0.5, 2), las = 1, lwd = 2)

HNDcolors = HNDpltColors()

with(hatIPVcog1[hatIPVcog1$CES1 == "0" & hatIPVcog1$IPVstatus == "0", ], plot(pAge, 
    hat, lty = 1, col = "black", type = "l", ylim = c(2, 12), ylab = "log(Trails A)", 
    xlab = "Age"))
with(hatIPVcog1[hatIPVcog1$CES1 == "0" & hatIPVcog1$IPVstatus == "1", ], lines(pAge, 
    hat, lty = 2, col = "red"))
with(hatIPVcog1[hatIPVcog1$CES1 == "1" & hatIPVcog1$IPVstatus == "0", ], lines(pAge, 
    hat, lty = 3, col = "black"))
with(hatIPVcog1[hatIPVcog1$CES1 == "1" & hatIPVcog1$IPVstatus == "1", ], lines(pAge, 
    hat, lty = 4, col = "red"))


legend(30, 12, zQ(nonDepressednoIPV, nonDepressedIPV, DepressednoIPV, DepressedIPV), 
    lty = 1:4, col = "black", cex = 0.95)
text(30, 2.5, "IPV in red", adj = c(0, 0), col = "red", cex = 0.95)
text(30, 2, "No IPV in black", adj = c(0, 0), col = "black", cex = 0.95)

plot of chunk unnamed-chunk-1

library("lme4")
library("multcomp")
library("zStat")

load(file = "~/Desktop/Megan/Research/IPV and Cognition Paper/IPV R Output/MenlogTrailsA.rda")


(mm3 = lmer(log(TrailsAtestSec) ~ (Age + PovStat + IPVstatus + CES1)^4 + (Age | 
    HNDid) + (1 | subclass), data = MenlogTrailsA, na.action = na.omit))
## Warning: number of observations <= rank(Z); variance-covariance matrix
## will be unidentifiable
## Linear mixed model fit by REML ['lmerMod']
## Formula: log(TrailsAtestSec) ~ (Age + PovStat + IPVstatus + CES1)^4 +      (Age | HNDid) + (1 | subclass) 
##    Data: MenlogTrailsA 
## REML criterion at convergence: 43.18 
## Random effects:
##  Groups   Name        Std.Dev. Corr
##  HNDid    (Intercept) 0.3157       
##           Age         0.0132   0.73
##  subclass (Intercept) 0.0000       
##  Residual             0.1391       
## Number of obs: 54, groups: HNDid, 27; subclass, 17
## Fixed Effects:
##                       (Intercept)                                Age  
##                          3.447849                           0.012913  
##                      PovStatBelow                         IPVstatus1  
##                          0.260888                           0.189737  
##                             CES11                   Age:PovStatBelow  
##                         -0.192804                          -0.000304  
##                    Age:IPVstatus1                          Age:CES11  
##                         -0.012913                          -0.008476  
##           PovStatBelow:IPVstatus1                 PovStatBelow:CES11  
##                         -0.235889                           0.015006  
##                  IPVstatus1:CES11        Age:PovStatBelow:IPVstatus1  
##                          0.072469                           0.010065  
##            Age:PovStatBelow:CES11               Age:IPVstatus1:CES11  
##                          0.015395                           0.039516  
##     PovStatBelow:IPVstatus1:CES11  Age:PovStatBelow:IPVstatus1:CES11  
##                          0.466554                          -0.010697

cftest(mm3)
## 
##   Simultaneous Tests for General Linear Hypotheses
## 
## Fit: lmer(formula = log(TrailsAtestSec) ~ (Age + PovStat + IPVstatus + 
##     CES1)^4 + (Age | HNDid) + (1 | subclass), data = MenlogTrailsA, 
##     na.action = na.omit)
## 
## Linear Hypotheses:
##                                         Estimate Std. Error z value
## (Intercept) == 0                        3.447849   0.133653   25.80
## Age == 0                                0.012913   0.010736    1.20
## PovStatBelow == 0                       0.260888   0.235508    1.11
## IPVstatus1 == 0                         0.189737   0.908793    0.21
## CES11 == 0                             -0.192804   0.299159   -0.64
## Age:PovStatBelow == 0                  -0.000304   0.021713   -0.01
## Age:IPVstatus1 == 0                    -0.012913   0.052026   -0.25
## Age:CES11 == 0                         -0.008476   0.024836   -0.34
## PovStatBelow:IPVstatus1 == 0           -0.235889   0.970372   -0.24
## PovStatBelow:CES11 == 0                 0.015006   0.434551    0.03
## IPVstatus1:CES11 == 0                   0.072469   0.972183    0.07
## Age:PovStatBelow:IPVstatus1 == 0        0.010065   0.058693    0.17
## Age:PovStatBelow:CES11 == 0             0.015395   0.044577    0.35
## Age:IPVstatus1:CES11 == 0               0.039516   0.060233    0.66
## PovStatBelow:IPVstatus1:CES11 == 0      0.466554   1.085133    0.43
## Age:PovStatBelow:IPVstatus1:CES11 == 0 -0.010697   0.078571   -0.14
##                                        Pr(>|z|)
## (Intercept) == 0                         <2e-16
## Age == 0                                   0.23
## PovStatBelow == 0                          0.27
## IPVstatus1 == 0                            0.83
## CES11 == 0                                 0.52
## Age:PovStatBelow == 0                      0.99
## Age:IPVstatus1 == 0                        0.80
## Age:CES11 == 0                             0.73
## PovStatBelow:IPVstatus1 == 0               0.81
## PovStatBelow:CES11 == 0                    0.97
## IPVstatus1:CES11 == 0                      0.94
## Age:PovStatBelow:IPVstatus1 == 0           0.86
## Age:PovStatBelow:CES11 == 0                0.73
## Age:IPVstatus1:CES11 == 0                  0.51
## PovStatBelow:IPVstatus1:CES11 == 0         0.67
## Age:PovStatBelow:IPVstatus1:CES11 == 0     0.89
## (Univariate p values reported)

pAge = seq(30, 70)

Age/IPV/Depression Note: Age/IPV/Depression interaction was NOT significant for Men

hatIPVcog1 = zMixHat(MenlogTrailsA, mm3, vary = "Age=pAge, CES1=zQ(0,1),IPVstatus=zQ(0,1)", 
    fixedCov = c("PovStat"))

head(hatIPVcog1)
##   Age CES1 IPVstatus log TrailsAtestSec PovStat   hat
## 1  30    0         0   0              0  0.3333 3.919
## 2  31    0         0   0              0  0.3333 3.932
## 3  32    0         0   0              0  0.3333 3.945
## 4  33    0         0   0              0  0.3333 3.958
## 5  34    0         0   0              0  0.3333 3.970
## 6  35    0         0   0              0  0.3333 3.983

par(mar = c(4, 4, 0.5, 2), las = 1, lwd = 2)

HNDcolors = HNDpltColors()

with(hatIPVcog1[hatIPVcog1$CES1 == "0" & hatIPVcog1$IPVstatus == "0", ], plot(pAge, 
    hat, lty = 1, col = "black", type = "l", ylim = c(2, 12), ylab = "log(Trails A)", 
    xlab = "Age"))
with(hatIPVcog1[hatIPVcog1$CES1 == "0" & hatIPVcog1$IPVstatus == "1", ], lines(pAge, 
    hat, lty = 2, col = "red"))
with(hatIPVcog1[hatIPVcog1$CES1 == "1" & hatIPVcog1$IPVstatus == "0", ], lines(pAge, 
    hat, lty = 3, col = "black"))
with(hatIPVcog1[hatIPVcog1$CES1 == "1" & hatIPVcog1$IPVstatus == "1", ], lines(pAge, 
    hat, lty = 4, col = "red"))


legend(30, 12, zQ(nonDepressednoIPV, nonDepressedIPV, DepressednoIPV, DepressedIPV), 
    lty = 1:4, col = "black", cex = 0.95)
text(30, 2.5, "IPV in red", adj = c(0, 0), col = "red", cex = 0.95)
text(30, 2, "No IPV in black", adj = c(0, 0), col = "black", cex = 0.95)

plot of chunk unnamed-chunk-3