Dyadic Analysis workshop, Zurich Nov. 24: T&B Model

Author

Eran Bar-Kalifa, Ben-Gurion Univ. Israel

Truth & Bias Model

Libraries

pacman::p_load(dplyr, rio,ggplot2,psych, nlme,GGally,lavaan,tidyr,sjPlot,lavaanPlot,osfr) 

Loading the data from OSF

#Retrieve the file using its ID
file <- osf_retrieve_file("671645fab93a400661a5e041")
setwd("C:\\Users\\97254\\Downloads")
osf_download(file, progress = T,conflicts = "overwrigt") 
temp1 <- import("TBData.csv")

Descriptive stats

Number of completed diaries

descriptive <- temp1 %>% group_by(ID,Female) %>% 
  summarise(n=n())
describeBy(descriptive$n,descriptive$Female)

 Descriptive statistics by group 
group: 0
   vars  n  mean   sd median trimmed  mad min max range  skew kurtosis   se
X1    1 76 23.76 4.28     25   24.23 4.45   8  29    21 -1.03     0.88 0.49
------------------------------------------------------------ 
group: 1
   vars  n  mean   sd median trimmed  mad min max range  skew kurtosis   se
X1    1 76 24.84 3.68     26   25.37 2.97  13  29    16 -1.12     0.49 0.42

Correlation matrix

ggpairs(temp1 %>% select(Self_Pos_Mood:Sex), title="Corr Matrix")

Scatter plot for each individual

ggplot(temp1 %>% filter(Male==1), aes(x = Partner_Pos_Mood, y = Judg_Pos_Mood)) +
  geom_point() +
  facet_wrap(~ID) + # Create separate plots for each individual
  geom_smooth(method = "lm", se = FALSE) +# Regression line without confidence interval
  labs(title = "Scatter Plot for Males",
       x = "Truth Value",
       y = "Judgment Value") +
  theme_minimal()

ggplot(temp1 %>% filter(Female==1), aes(x = Partner_Pos_Mood, y = Judg_Pos_Mood)) +
  geom_point() +
  facet_wrap(~ID) + # Create separate plots for each individual
  geom_smooth(method = "lm", se = FALSE) +# Regression line without confidence interval
  labs(title = "Scatter Plot for Females",
       x = "Truth Value",
       y = "Judgment Value") +
  theme_minimal()

Spaghetti plot

ggplot(temp1, aes(x = Partner_Pos_Mood, y = Judg_Pos_Mood)) +
  # Individual regression lines
  geom_smooth(method = "lm", se = FALSE, aes(color = as.factor(ID)), show.legend = FALSE,, size = 0.5) +
  # Overall regression line (thicker)
  geom_smooth(method = "lm", se = FALSE, color = "red", size = 1.5) +
  labs(title = "Spaghetti Plot with Individual and Overall Regression Lines",
       x = "Truth Value",
       y = "Judgment Value") +
  theme_minimal()

Cross-Sectional T&B

Using variables’ averages

CS1 <- temp1 %>%group_by(Couple,ID,Female,Male) %>% 
  summarise(Judg_Pos_Mood=mean(Judg_Pos_Mood,na.rm=T),
            Partner_Pos_Mood=mean(Partner_Pos_Mood,na.rm=T),
            Self_Pos_Mood=mean(Self_Pos_Mood,na.rm=T)
            )

Centering variables on the truth variable

AvgTruth=mean(CS1$Partner_Pos_Mood,na.rm=T)
CS1 <- CS1 %>% mutate(Judg_Pos_MoodMC=Judg_Pos_Mood-AvgTruth,
              Partner_Pos_MoodMC=Partner_Pos_Mood-AvgTruth,
              Self_Pos_MoodMC=Self_Pos_Mood-AvgTruth,
              Gender=Female-0.5
              )

Models

Model 1: Only Truth - Dyadic two intercepts/slopes model

TB_CS_Model1 <- gls(Judg_Pos_MoodMC~
                      -1+
                      Male+Male:Partner_Pos_MoodMC+
                      Female+Female:Partner_Pos_MoodMC,
                      correlation = corSymm(form=~1|Couple), #estimate partners' non-independence
                      weights = varIdent(form=~1|Gender), #allows for different error terms for the two variables
                      data = CS1, na.action=na.exclude
                      
                      )
summary(TB_CS_Model1)
Generalized least squares fit by REML
  Model: Judg_Pos_MoodMC ~ -1 + Male + Male:Partner_Pos_MoodMC + Female +      Female:Partner_Pos_MoodMC 
  Data: CS1 
       AIC      BIC   logLik
  1168.388 1189.369 -577.194

Correlation Structure: General
 Formula: ~1 | Couple 
 Parameter estimate(s):
 Correlation: 
  1     
2 -0.899
Variance function:
 Structure: Different standard deviations per stratum
 Formula: ~1 | Gender 
 Parameter estimates:
    -0.5      0.5 
1.000000 1.145675 

Coefficients:
                              Value Std.Error   t-value p-value
Male                       1.060655 1.7523675  0.605270  0.5459
Female                    -3.787339 2.0088232 -1.885352  0.0613
Male:Partner_Pos_MoodMC    0.801133 0.0476422 16.815623  0.0000
Partner_Pos_MoodMC:Female  1.046936 0.0599488 17.463854  0.0000

 Correlation: 
                          Male   Female M:P_P_
Female                    -0.891              
Male:Partner_Pos_MoodMC    0.075  0.023       
Partner_Pos_MoodMC:Female -0.021 -0.083 -0.283

Standardized residuals:
        Min          Q1         Med          Q3         Max 
-2.53772592 -0.74097678  0.01049945  0.65667294  2.53873557 

Residual standard error: 15.23323 
Degrees of freedom: 152 total; 148 residual
tab_model(TB_CS_Model1,show.r2=F)
  Judg Pos Mood MC
Predictors Estimates CI p
Male 1.06 -2.40 – 4.52 0.546
Female -3.79 -7.76 – 0.18 0.061
Male × Partner Pos MoodMC 0.80 0.71 – 0.90 <0.001
Partner Pos MoodMC ×
Female
1.05 0.93 – 1.17 <0.001
Observations 152

Model 2: Bias (assumed similarity)

TB_CS_Model2 <- gls(Judg_Pos_MoodMC~
                      -1+
                      Male+Male:Partner_Pos_MoodMC+Male:Self_Pos_MoodMC+
                      Female+Female:Partner_Pos_MoodMC+Female:Self_Pos_MoodMC,
                    correlation = corSymm(form=~1|Couple), #estimate partners' non-independence
                    weights = varIdent(form=~1|Female), #allows for different error terms for the two variables
                    data = CS1, na.action=na.exclude
                    
)
summary(TB_CS_Model2)
Generalized least squares fit by REML
  Model: Judg_Pos_MoodMC ~ -1 + Male + Male:Partner_Pos_MoodMC + Male:Self_Pos_MoodMC +      Female + Female:Partner_Pos_MoodMC + Female:Self_Pos_MoodMC 
  Data: CS1 
       AIC      BIC    logLik
  1027.293 1054.145 -504.6465

Correlation Structure: General
 Formula: ~1 | Couple 
 Parameter estimate(s):
 Correlation: 
  1     
2 -0.489
Variance function:
 Structure: Different standard deviations per stratum
 Formula: ~1 | Female 
 Parameter estimates:
      0       1 
1.00000 1.14516 

Coefficients:
                               Value Std.Error   t-value p-value
Male                      -2.9711522 0.7787850 -3.815112  0.0002
Female                     1.3058664 0.8992917  1.452105  0.1486
Male:Partner_Pos_MoodMC    0.1143463 0.0468142  2.442558  0.0158
Male:Self_Pos_MoodMC       0.7808744 0.0517753 15.082000  0.0000
Partner_Pos_MoodMC:Female  0.2103531 0.0588848  3.572281  0.0005
Self_Pos_MoodMC:Female     0.8417496 0.0541363 15.548698  0.0000

 Correlation: 
                          Male   Female M:P_P_ M:S_P_ P_P_MM
Female                    -0.488                            
Male:Partner_Pos_MoodMC    0.224 -0.124                     
Male:Self_Pos_MoodMC      -0.234  0.119 -0.315              
Partner_Pos_MoodMC:Female  0.113 -0.244  0.152 -0.487       
Self_Pos_MoodMC:Female    -0.109  0.255 -0.485  0.152 -0.313

Standardized residuals:
        Min          Q1         Med          Q3         Max 
-3.55982536 -0.61382646  0.06485507  0.54897542  3.08489059 

Residual standard error: 6.513399 
Degrees of freedom: 152 total; 146 residual
tab_model(TB_CS_Model1,TB_CS_Model2,show.r2=F)
  Judg Pos Mood MC Judg Pos Mood MC
Predictors Estimates CI p Estimates CI p
Male 1.06 -2.40 – 4.52 0.546 -2.97 -4.51 – -1.43 <0.001
Female -3.79 -7.76 – 0.18 0.061 1.31 -0.47 – 3.08 0.149
Male × Partner Pos MoodMC 0.80 0.71 – 0.90 <0.001 0.11 0.02 – 0.21 0.016
Partner Pos MoodMC ×
Female
1.05 0.93 – 1.17 <0.001 0.21 0.09 – 0.33 <0.001
Male × Self Pos MoodMC 0.78 0.68 – 0.88 <0.001
Self Pos MoodMC × Female 0.84 0.73 – 0.95 <0.001
Observations 152 152

Model 3: Moderated T&B model

Are happy people (>avg above 50) biased?

CS1 <- CS1 %>% mutate(Happy=ifelse(Self_Pos_Mood>50,1,0))
table(CS1$Happy)

 0  1 
94 58 
TB_CS_Model3 <- gls(Judg_Pos_MoodMC~
                      -1+
                      Male+Male:Partner_Pos_MoodMC+
                      Male:Happy+Male:Happy:Partner_Pos_MoodMC+
                      Female+Female:Partner_Pos_MoodMC+
                      Female:Happy+Female:Happy:Partner_Pos_MoodMC,
                    correlation = corSymm(form=~1|Couple), #estimate partners' non-independence
                    weights = varIdent(form=~1|Female), #allows for different error terms for the two variables
                    data = CS1, na.action=na.exclude
                    
)
summary(TB_CS_Model3)
Generalized least squares fit by REML
  Model: Judg_Pos_MoodMC ~ -1 + Male + Male:Partner_Pos_MoodMC + Male:Happy +      Male:Happy:Partner_Pos_MoodMC + Female + Female:Partner_Pos_MoodMC +      Female:Happy + Female:Happy:Partner_Pos_MoodMC 
  Data: CS1 
       AIC      BIC    logLik
  1167.659 1200.327 -572.8297

Correlation Structure: General
 Formula: ~1 | Couple 
 Parameter estimate(s):
 Correlation: 
  1     
2 -0.427
Variance function:
 Structure: Different standard deviations per stratum
 Formula: ~1 | Female 
 Parameter estimates:
       0        1 
1.000000 1.167893 

Coefficients:
                                    Value Std.Error   t-value p-value
Male                            -5.444977 1.6281064 -3.344362  0.0011
Female                          -8.428235 1.7354335 -4.856559  0.0000
Male:Partner_Pos_MoodMC          0.444143 0.0961729  4.618172  0.0000
Male:Happy                      13.711638 2.4003901  5.712254  0.0000
Partner_Pos_MoodMC:Female        0.465803 0.1207762  3.856747  0.0002
Happy:Female                    16.948182 3.1162481  5.438650  0.0000
Male:Partner_Pos_MoodMC:Happy   -0.129834 0.1385068 -0.937386  0.3501
Partner_Pos_MoodMC:Happy:Female  0.069680 0.1862237  0.374176  0.7088

 Correlation: 
                                Male   Female Ml:P_P_MMC Ml:Hpp P_P_MMC:F
Female                          -0.243                                   
Male:Partner_Pos_MoodMC          0.323  0.120                            
Male:Happy                      -0.641  0.006 -0.207                     
Partner_Pos_MoodMC:Female        0.105  0.055 -0.114     -0.222          
Happy:Female                    -0.084 -0.525 -0.257      0.065 -0.029   
Male:Partner_Pos_MoodMC:Happy   -0.224  0.027 -0.681      0.101  0.194   
Partner_Pos_MoodMC:Happy:Female  0.052 -0.043  0.183     -0.013 -0.642   
                                Hppy:F M:P_P_MMC:
Female                                           
Male:Partner_Pos_MoodMC                          
Male:Happy                                       
Partner_Pos_MoodMC:Female                        
Happy:Female                                     
Male:Partner_Pos_MoodMC:Happy    0.050           
Partner_Pos_MoodMC:Happy:Female -0.301 -0.271    

Standardized residuals:
        Min          Q1         Med          Q3         Max 
-2.27412428 -0.67857938 -0.05022552  0.66481701  2.21178297 

Residual standard error: 10.52934 
Degrees of freedom: 152 total; 144 residual
tab_model(TB_CS_Model1,TB_CS_Model2,TB_CS_Model3,show.r2=F)
  Judg Pos Mood MC Judg Pos Mood MC Judg Pos Mood MC
Predictors Estimates CI p Estimates CI p Estimates CI p
Male 1.06 -2.40 – 4.52 0.546 -2.97 -4.51 – -1.43 <0.001 -5.44 -8.66 – -2.23 0.001
Female -3.79 -7.76 – 0.18 0.061 1.31 -0.47 – 3.08 0.149 -8.43 -11.86 – -5.00 <0.001
Male × Partner Pos MoodMC 0.80 0.71 – 0.90 <0.001 0.11 0.02 – 0.21 0.016 0.44 0.25 – 0.63 <0.001
Partner Pos MoodMC ×
Female
1.05 0.93 – 1.17 <0.001 0.21 0.09 – 0.33 <0.001 0.47 0.23 – 0.70 <0.001
Male × Self Pos MoodMC 0.78 0.68 – 0.88 <0.001
Self Pos MoodMC × Female 0.84 0.73 – 0.95 <0.001
Male × Happy 13.71 8.97 – 18.46 <0.001
Happy × Female 16.95 10.79 – 23.11 <0.001
Male × Partner Pos MoodMC
× Happy
-0.13 -0.40 – 0.14 0.350
Partner Pos MoodMC ×
Happy × Female
0.07 -0.30 – 0.44 0.709
Observations 152 152 152

Model 4: Full moderated T&B model

Is this explained by assumed similarity?

TB_CS_Model4 <- gls(Judg_Pos_MoodMC~
                      -1+
                      Male+Male:Partner_Pos_MoodMC+
                      Male:Happy+Male:Happy:Partner_Pos_MoodMC+Male:Self_Pos_MoodMC+
                      Female+Female:Partner_Pos_MoodMC+
                      Female:Happy+Female:Happy:Partner_Pos_MoodMC+Female:Self_Pos_MoodMC,
                    correlation = corSymm(form=~1|Couple), #estimate partners' non-independence
                    weights = varIdent(form=~1|Female), #allows for different error terms for the two variables
                    data = CS1, na.action=na.exclude
                    
)
summary(TB_CS_Model4)
Generalized least squares fit by REML
  Model: Judg_Pos_MoodMC ~ -1 + Male + Male:Partner_Pos_MoodMC + Male:Happy +      Male:Happy:Partner_Pos_MoodMC + Male:Self_Pos_MoodMC + Female +      Female:Partner_Pos_MoodMC + Female:Happy + Female:Happy:Partner_Pos_MoodMC +      Female:Self_Pos_MoodMC 
  Data: CS1 
       AIC      BIC    logLik
  1030.417 1068.843 -502.2085

Correlation Structure: General
 Formula: ~1 | Couple 
 Parameter estimate(s):
 Correlation: 
  1     
2 -0.531
Variance function:
 Structure: Different standard deviations per stratum
 Formula: ~1 | Female 
 Parameter estimates:
       0        1 
1.000000 1.144816 

Coefficients:
                                    Value Std.Error   t-value p-value
Male                            -2.437242 1.0528521 -2.314895  0.0221
Female                           3.135126 1.3934181  2.249953  0.0260
Male:Partner_Pos_MoodMC          0.142537 0.0624647  2.281884  0.0240
Male:Happy                      -1.202497 1.9586122 -0.613954  0.5402
Male:Self_Pos_MoodMC             0.806444 0.0708970 11.374866  0.0000
Partner_Pos_MoodMC:Female        0.206549 0.0752866  2.743509  0.0069
Happy:Female                    -4.583098 2.5642983 -1.787272  0.0760
Self_Pos_MoodMC:Female           0.936852 0.0774254 12.100068  0.0000
Male:Partner_Pos_MoodMC:Happy   -0.057791 0.0835694 -0.691531  0.4904
Partner_Pos_MoodMC:Happy:Female  0.036695 0.1099233  0.333821  0.7390

 Correlation: 
                                Male   Female Ml:P_P_MMC Ml:Hpp M:S_P_
Female                          -0.275                                
Male:Partner_Pos_MoodMC          0.238 -0.097                         
Male:Happy                      -0.638  0.009 -0.001                  
Male:Self_Pos_MoodMC             0.283  0.060 -0.228     -0.667       
Partner_Pos_MoodMC:Female        0.046 -0.039 -0.036     -0.012 -0.286
Happy:Female                     0.005 -0.730 -0.017     -0.013  0.010
Self_Pos_MoodMC:Female          -0.078  0.651 -0.307      0.014  0.081
Male:Partner_Pos_MoodMC:Happy   -0.191  0.054 -0.649      0.035  0.055
Partner_Pos_MoodMC:Happy:Female  0.048 -0.036  0.218      0.014 -0.036
                                P_P_MMC:F Hppy:F S_P_MM M:P_P_MMC:
Female                                                            
Male:Partner_Pos_MoodMC                                           
Male:Happy                                                        
Male:Self_Pos_MoodMC                                              
Partner_Pos_MoodMC:Female                                         
Happy:Female                     0.041                            
Self_Pos_MoodMC:Female          -0.112    -0.688                  
Male:Partner_Pos_MoodMC:Happy    0.211     0.018  0.042           
Partner_Pos_MoodMC:Happy:Female -0.602    -0.211 -0.003 -0.338    

Standardized residuals:
        Min          Q1         Med          Q3         Max 
-3.63130383 -0.73774505  0.09535328  0.53694180  3.30232054 

Residual standard error: 6.61251 
Degrees of freedom: 152 total; 142 residual
tab_model(TB_CS_Model3,TB_CS_Model4,show.r2=F)
  Judg Pos Mood MC Judg Pos Mood MC
Predictors Estimates CI p Estimates CI p
Male -5.44 -8.66 – -2.23 0.001 -2.44 -4.52 – -0.36 0.022
Female -8.43 -11.86 – -5.00 <0.001 3.14 0.38 – 5.89 0.026
Male × Partner Pos MoodMC 0.44 0.25 – 0.63 <0.001 0.14 0.02 – 0.27 0.024
Male × Happy 13.71 8.97 – 18.46 <0.001 -1.20 -5.07 – 2.67 0.540
Partner Pos MoodMC ×
Female
0.47 0.23 – 0.70 <0.001 0.21 0.06 – 0.36 0.007
Happy × Female 16.95 10.79 – 23.11 <0.001 -4.58 -9.65 – 0.49 0.076
Male × Partner Pos MoodMC
× Happy
-0.13 -0.40 – 0.14 0.350 -0.06 -0.22 – 0.11 0.490
Partner Pos MoodMC ×
Happy × Female
0.07 -0.30 – 0.44 0.709 0.04 -0.18 – 0.25 0.739
Male × Self Pos MoodMC 0.81 0.67 – 0.95 <0.001
Self Pos MoodMC × Female 0.94 0.78 – 1.09 <0.001
Observations 152 152

Model 5: Mediated T&B model

We use lavaan - easier to estimate bootstrapping CI for indirect effects

Transforming data into wide dataframe

CS2 <- CS1 %>% ungroup() %>% select(Couple,Female,Judg_Pos_MoodMC,Partner_Pos_MoodMC,Self_Pos_MoodMC) %>% 
  pivot_wider(id_cols = Couple,
              names_from = Female,
              values_from = Judg_Pos_MoodMC:Self_Pos_MoodMC)

CS2 <- CS2 %>%
  rename_with(~ gsub("_0", "_Male", .)) %>%
  rename_with(~ gsub("_1", "_Female", .))

Define the basic model and run it:

model <- '
  
  
  # intercepts/means
  Judg_Pos_MoodMC_Male ~ 1
  Judg_Pos_MoodMC_Female ~ 1
  Partner_Pos_MoodMC_Male~1
  Partner_Pos_MoodMC_Female~1
  
  #regression
  Judg_Pos_MoodMC_Male~Truth_M*Partner_Pos_MoodMC_Male
  Judg_Pos_MoodMC_Female~Truth_F*Partner_Pos_MoodMC_Female
  
  #variances/residuals
  Judg_Pos_MoodMC_Male ~~ resid_M*Judg_Pos_MoodMC_Male
  Judg_Pos_MoodMC_Female ~~ resid_W*Judg_Pos_MoodMC_Female
  Partner_Pos_MoodMC_Male~~Partner_Pos_MoodMC_Male
  Partner_Pos_MoodMC_Female~~Partner_Pos_MoodMC_Female
  
  #covariance
  Judg_Pos_MoodMC_Male~~Judg_Pos_MoodMC_Female
  Partner_Pos_MoodMC_Male~~Partner_Pos_MoodMC_Female
'
fit <- sem(model, data = CS2, fixed.x = FALSE)
summary(fit,standardized = TRUE)
lavaan 0.6.16 ended normally after 87 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        12

  Number of observations                            76

Model Test User Model:
                                                      
  Test statistic                               151.464
  Degrees of freedom                                 2
  P-value (Chi-square)                           0.000

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Expected
  Information saturated (h1) model          Structured

Regressions:
                           Estimate  Std.Err  z-value  P(>|z|)   Std.lv
  Judg_Pos_MoodMC_Male ~                                               
    P_P_MMC (Tr_M)            0.802    0.047   17.163    0.000    0.802
  Judg_Pos_MoodMC_Female ~                                             
    P_P_MMC (Tr_F)            1.048    0.059   17.817    0.000    1.048
  Std.all
         
    0.665
         
    0.679

Covariances:
                             Estimate  Std.Err  z-value  P(>|z|)   Std.lv
 .Judg_Pos_MoodMC_Male ~~                                                
   .Jdg_Ps_MdMC_Fm           -235.992   40.440   -5.836    0.000 -235.992
  Partner_Pos_MoodMC_Male ~~                                             
    Prtnr_Ps_MMC_F             80.939   30.858    2.623    0.009   80.939
  Std.all
         
   -0.901
         
    0.315

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .Jdg_Ps_MdMC_Ml    1.064    1.740    0.612    0.541    1.064    0.053
   .Jdg_Ps_MdMC_Fm   -3.790    1.993   -1.901    0.057   -3.790   -0.161
    Prtnr_Ps_MMC_M   -2.776    1.926   -1.441    0.149   -2.776   -0.165
    Prtnr_Ps_MMC_F    2.776    1.753    1.583    0.113    2.776    0.182

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .J_P_MMC (rs_M)  228.691   37.099    6.164    0.000  228.691    0.558
   .J_P_MMC (rs_W)  299.961   48.660    6.164    0.000  299.961    0.539
    P_P_MMC         281.774   45.710    6.164    0.000  281.774    1.000
    P_P_MMC         233.586   37.893    6.164    0.000  233.586    1.000

Now the Mediation model:

model_mediation <- '
  
  
  # intercepts/means
  Judg_Pos_MoodMC_Male ~ 1
  Judg_Pos_MoodMC_Female ~ 1
  Partner_Pos_MoodMC_Male~1
  Partner_Pos_MoodMC_Female~1
  Self_Pos_MoodMC_Male~1
  Self_Pos_MoodMC_Female~1
  
  #regression X+M->Y
  #Direct effect and Mediated effects
  Judg_Pos_MoodMC_Male~Truth_M*Partner_Pos_MoodMC_Male+Bias_M*Self_Pos_MoodMC_Male
  Judg_Pos_MoodMC_Female~Truth_F*Partner_Pos_MoodMC_Female+Bias_F*Self_Pos_MoodMC_Female
  
  #a paths X->M
  Self_Pos_MoodMC_Male~Similarity_M*Partner_Pos_MoodMC_Male
  Self_Pos_MoodMC_Female~Similarity_F*Partner_Pos_MoodMC_Female
  
  #variances/residuals
  Judg_Pos_MoodMC_Male ~~ resid_M*Judg_Pos_MoodMC_Male
  Judg_Pos_MoodMC_Female ~~ resid_W*Judg_Pos_MoodMC_Female
  Partner_Pos_MoodMC_Male~~Partner_Pos_MoodMC_Male
  Partner_Pos_MoodMC_Female~~Partner_Pos_MoodMC_Female
  Self_Pos_MoodMC_Male~~Self_Pos_MoodMC_Male
  Self_Pos_MoodMC_Female~~Self_Pos_MoodMC_Female
  
  
  #covariance
  Judg_Pos_MoodMC_Male~~Judg_Pos_MoodMC_Female
  Partner_Pos_MoodMC_Male~~Partner_Pos_MoodMC_Female
  Self_Pos_MoodMC_Male~~Self_Pos_MoodMC_Female
  
  
  # indirect effect (a*b)
             Indirect_M := Similarity_M*Bias_M
             Indirect_F := Similarity_F*Bias_F
             

           # total effect
             total_M := Truth_M + (Similarity_M*Bias_M)
             total_F := Truth_F + (Similarity_F*Bias_F)
             
'
fit2 <- sem(model_mediation, data = CS2, fixed.x = FALSE,se = "bootstrap",
            bootstrap = 100,
           parallel = "snow", ncpus = 4)
summary(fit2,standardized = TRUE)
lavaan 0.6.16 ended normally after 177 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        21

  Number of observations                            76

Model Test User Model:
                                                      
  Test statistic                               454.511
  Degrees of freedom                                 6
  P-value (Chi-square)                           0.000

Parameter Estimates:

  Standard errors                            Bootstrap
  Number of requested bootstrap draws              100
  Number of successful bootstrap draws             100

Regressions:
                           Estimate  Std.Err  z-value  P(>|z|)   Std.lv
  Judg_Pos_MoodMC_Male ~                                               
    P_P_MMC (Tr_M)            0.114    0.042    2.746    0.006    0.114
    S_P_MMC (Bs_M)            0.781    0.050   15.570    0.000    0.781
  Judg_Pos_MoodMC_Female ~                                             
    P_P_MMC (Tr_F)            0.210    0.046    4.546    0.000    0.210
    S_P_MMC (Bs_F)            0.842    0.056   14.954    0.000    0.842
  Self_Pos_MoodMC_Male ~                                               
    P_P_MMC (Sm_M)            0.771    0.084    9.179    0.000    0.771
  Self_Pos_MoodMC_Female ~                                             
    P_P_MMC (Sm_F)            1.258    0.129    9.754    0.000    1.258
  Std.all
         
    0.102
    0.874
         
    0.118
    0.880
         
    0.616
         
    0.674

Covariances:
                             Estimate  Std.Err  z-value  P(>|z|)   Std.lv
 .Judg_Pos_MoodMC_Male ~~                                                
   .Jdg_Ps_MdMC_Fm            -22.818    8.002   -2.852    0.004  -22.818
  Partner_Pos_MoodMC_Male ~~                                             
    Prtnr_Ps_MMC_F             80.939   35.759    2.263    0.024   80.939
 .Self_Pos_MoodMC_Male ~~                                                
   .Slf_Ps_MdMC_Fm           -347.188   65.962   -5.263    0.000 -347.188
  Std.all
         
   -0.489
         
    0.315
         
   -0.994

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .Jdg_Ps_MdMC_Ml   -2.971    0.708   -4.198    0.000   -2.971   -0.158
   .Jdg_Ps_MdMC_Fm    1.306    0.902    1.447    0.148    1.306    0.048
    Prtnr_Ps_MMC_M   -2.776    1.888   -1.470    0.142   -2.776   -0.165
    Prtnr_Ps_MMC_F    2.776    1.590    1.746    0.081    2.776    0.182
   .Slf_Ps_MdMC_Ml    4.862    1.767    2.752    0.006    4.862    0.231
   .Slf_Ps_MdMC_Fm   -6.785    2.063   -3.289    0.001   -6.785   -0.238

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .J_P_MMC (rs_M)   40.753    8.269    4.929    0.000   40.753    0.116
   .J_P_MMC (rs_W)   53.443    9.726    5.495    0.000   53.443    0.072
    P_P_MMC         281.774   42.255    6.668    0.000  281.774    1.000
    P_P_MMC         233.586   39.512    5.912    0.000  233.586    1.000
   .S_P_MMC         273.976   53.826    5.090    0.000  273.976    0.621
   .S_P_MMC         445.462  106.576    4.180    0.000  445.462    0.546

Defined Parameters:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    Indirect_M        0.602    0.075    8.024    0.000    0.602    0.538
    Indirect_F        1.059    0.128    8.250    0.000    1.059    0.593
    total_M           0.716    0.078    9.227    0.000    0.716    0.641
    total_F           1.270    0.121   10.459    0.000    1.270    0.711
#CI
est <- parameterEstimates(fit2)
est[22:25,]
          lhs op                           rhs      label   est    se      z
22 Indirect_M :=           Similarity_M*Bias_M Indirect_M 0.602 0.075  8.024
23 Indirect_F :=           Similarity_F*Bias_F Indirect_F 1.059 0.128  8.250
24    total_M := Truth_M+(Similarity_M*Bias_M)    total_M 0.716 0.078  9.227
25    total_F := Truth_F+(Similarity_F*Bias_F)    total_F 1.270 0.121 10.459
   pvalue ci.lower ci.upper
22      0    0.448    0.744
23      0    0.815    1.368
24      0    0.547    0.837
25      0    1.014    1.572
#% of mediated effect
paste0("% of mediated effect for males: ",round(est[22,5]/est[24,5]*100,3),"%")
[1] "% of mediated effect for males: 84.038%"
paste0("% of mediated effect for females: ",round(est[23,5]/est[25,5]*100,3),"%")
[1] "% of mediated effect for females: 83.433%"

Within-person Longitudinal T&B

Centering variables on the truth variable

AvgTruth=mean(temp1$Partner_Pos_Mood,na.rm=T)
Long1 <- temp1 %>% mutate(Judg_Pos_MoodMC=Judg_Pos_Mood-AvgTruth,
                      Partner_Pos_MoodMC=Partner_Pos_Mood-AvgTruth,
                      Self_Pos_MoodMC=Self_Pos_Mood-AvgTruth,
                      Gender=Female-0.5
)

Models

Model 1: Only Truth

TB_Long_Model1<- lme(Judg_Pos_MoodMC ~ -1 + 
                       Male+ Male:Partner_Pos_MoodMC+
                       Female+ Female:Partner_Pos_MoodMC,
           random = ~ -1 + Male+Male:Partner_Pos_MoodMC+ 
                           Female+Female:Partner_Pos_MoodMC| Couple,
           weights = varIdent(form=~1|Gender),
           # corr=corAR1(form = ~1 | Couple/DiaryDay),
           correlation = corCompSymm(form = ~1|Couple/DiaryDay),
           data = Long1,na.action = na.exclude)
summary(TB_Long_Model1)
Linear mixed-effects model fit by REML
  Data: Long1 
       AIC      BIC    logLik
  27082.74 27186.57 -13524.37

Random effects:
 Formula: ~-1 + Male + Male:Partner_Pos_MoodMC + Female + Female:Partner_Pos_MoodMC | Couple
 Structure: General positive-definite, Log-Cholesky parametrization
                          StdDev     Corr                
Male                      12.5294642 Male   Female M:P_P_
Female                    15.5964920 -0.189              
Male:Partner_Pos_MoodMC    0.2098416 -0.215 -0.239       
Partner_Pos_MoodMC:Female  0.1733956 -0.086 -0.171  0.458
Residual                  12.8247507                     

Correlation Structure: Compound symmetry
 Formula: ~1 | Couple/DiaryDay 
 Parameter estimate(s):
        Rho 
-0.09541552 
Variance function:
 Structure: Different standard deviations per stratum
 Formula: ~1 | Gender 
 Parameter estimates:
    -0.5      0.5 
1.000000 1.028375 
Fixed effects:  Judg_Pos_MoodMC ~ -1 + Male + Male:Partner_Pos_MoodMC + Female +      Female:Partner_Pos_MoodMC 
                               Value Std.Error   DF   t-value p-value
Male                       0.2361687 1.5008399 3245  0.157358  0.8750
Female                    -1.4270326 1.8369016 3245 -0.776869  0.4373
Male:Partner_Pos_MoodMC    0.3253314 0.0335198 3245  9.705644  0.0000
Partner_Pos_MoodMC:Female  0.2792401 0.0326877 3245  8.542659  0.0000
 Correlation: 
                          Male   Female M:P_P_
Female                    -0.178              
Male:Partner_Pos_MoodMC   -0.115 -0.167       
Partner_Pos_MoodMC:Female -0.053 -0.132  0.193

Standardized Within-Group Residuals:
       Min         Q1        Med         Q3        Max 
-4.4021060 -0.6017420  0.0260356  0.5899257  3.6305571 

Number of Observations: 3324
Number of Groups: 76 
tab_model(TB_Long_Model1,show.r2=F)
  Judg Pos Mood MC
Predictors Estimates CI p
Male 0.24 -2.71 – 3.18 0.875
Female -1.43 -5.03 – 2.17 0.437
Male × Partner Pos MoodMC 0.33 0.26 – 0.39 <0.001
Partner Pos MoodMC ×
Female
0.28 0.22 – 0.34 <0.001
Random Effects
σ2 164.47
τ00  
τ00  
τ11 Couple.Female 243.25
τ11 Couple.Male:Partner_Pos_MoodMC 0.04
τ11 Couple.Partner_Pos_MoodMC:Female 0.03
ρ01 -0.19
-0.21
-0.09
ICC 0.57
N Couple 76
Observations 3324

Extracting the empirical Bayes estimates of the random effects to examine between-person associations

Random <- as.data.frame(TB_Long_Model1$coefficients$random$Couple)
ggpairs(Random, title="Corr Matrix of Random Effects")

Model 2: Adding bias

TB_Long_Model2<- lme(Judg_Pos_MoodMC ~ -1 + 
                       Male+ Male:Partner_Pos_MoodMC+Male:Self_Pos_MoodMC+
                       Female+ Female:Partner_Pos_MoodMC+Female:Self_Pos_MoodMC,
                     # random = ~ -1 + Male+Male:Partner_Pos_MoodMC+Male:Self_Pos_MoodMC+ 
                     #   Female+Female:Partner_Pos_MoodMC+Female:Self_Pos_MoodMC| Couple,
                     # Didn't converge with adding bias effects into random effect, so I moved to the simpler model
                     random = ~ -1 + Male+Male:Partner_Pos_MoodMC+ 
                       Female+Female:Partner_Pos_MoodMC| Couple,

                     weights = varIdent(form=~1|Gender),
                     # corr=corAR1(form = ~1 | Couple/DiaryDay),
                     correlation = corCompSymm(form = ~1|Couple/DiaryDay),
                     data = Long1,na.action = na.exclude)
summary(TB_Long_Model2)
Linear mixed-effects model fit by REML
  Data: Long1 
       AIC      BIC    logLik
  26275.82 26391.86 -13118.91

Random effects:
 Formula: ~-1 + Male + Male:Partner_Pos_MoodMC + Female + Female:Partner_Pos_MoodMC | Couple
 Structure: General positive-definite, Log-Cholesky parametrization
                          StdDev     Corr                
Male                       7.1534681 Male   Female M:P_P_
Female                     9.3978323 -0.448              
Male:Partner_Pos_MoodMC    0.1582051 -0.185 -0.283       
Partner_Pos_MoodMC:Female  0.1744764  0.176 -0.341  0.199
Residual                  11.6520210                     

Correlation Structure: Compound symmetry
 Formula: ~1 | Couple/DiaryDay 
 Parameter estimate(s):
        Rho 
-0.01550273 
Variance function:
 Structure: Different standard deviations per stratum
 Formula: ~1 | Gender 
 Parameter estimates:
    -0.5      0.5 
1.000000 1.008277 
Fixed effects:  Judg_Pos_MoodMC ~ -1 + Male + Male:Partner_Pos_MoodMC + Male:Self_Pos_MoodMC +      Female + Female:Partner_Pos_MoodMC + Female:Self_Pos_MoodMC 
                               Value Std.Error   DF   t-value p-value
Male                      -1.4276853 0.9015429 3243 -1.583602  0.1134
Female                     0.0835905 1.1447070 3243  0.073024  0.9418
Male:Partner_Pos_MoodMC    0.2112275 0.0272099 3243  7.762881  0.0000
Male:Self_Pos_MoodMC       0.4770385 0.0211961 3243 22.505972  0.0000
Partner_Pos_MoodMC:Female  0.1680286 0.0304955 3243  5.509943  0.0000
Self_Pos_MoodMC:Female     0.4752247 0.0203876 3243 23.309518  0.0000
 Correlation: 
                          Male   Female M:P_P_ M:S_P_ P_P_MM
Female                    -0.387                            
Male:Partner_Pos_MoodMC   -0.060 -0.181                     
Male:Self_Pos_MoodMC      -0.072  0.013 -0.146              
Partner_Pos_MoodMC:Female  0.106 -0.262  0.092 -0.046       
Self_Pos_MoodMC:Female    -0.025  0.064 -0.052  0.010 -0.142

Standardized Within-Group Residuals:
         Min           Q1          Med           Q3          Max 
-5.063013015 -0.564336214  0.005797968  0.584927716  3.534207774 

Number of Observations: 3324
Number of Groups: 76 
tab_model(TB_Long_Model1,TB_Long_Model2,show.r2=F)
  Judg Pos Mood MC Judg Pos Mood MC
Predictors Estimates CI p Estimates CI p
Male 0.24 -2.71 – 3.18 0.875 -1.43 -3.20 – 0.34 0.113
Female -1.43 -5.03 – 2.17 0.437 0.08 -2.16 – 2.33 0.942
Male × Partner Pos MoodMC 0.33 0.26 – 0.39 <0.001 0.21 0.16 – 0.26 <0.001
Partner Pos MoodMC ×
Female
0.28 0.22 – 0.34 <0.001 0.17 0.11 – 0.23 <0.001
Male × Self Pos MoodMC 0.48 0.44 – 0.52 <0.001
Self Pos MoodMC × Female 0.48 0.44 – 0.52 <0.001
Random Effects
σ2 164.47 135.77
τ00    
τ00    
τ11 243.25 Couple.Female 88.32 Couple.Female
0.04 Couple.Male:Partner_Pos_MoodMC 0.03 Couple.Male:Partner_Pos_MoodMC
0.03 Couple.Partner_Pos_MoodMC:Female 0.03 Couple.Partner_Pos_MoodMC:Female
ρ01 -0.19 -0.45
-0.21 -0.18
-0.09 0.18
ICC 0.57 0.37
N 76 Couple 76 Couple
Observations 3324 3324

Model 3: Moderated T&B

Does daily sex affect perceptions?

TB_Long_Model3<- lme(Judg_Pos_MoodMC ~ -1 + 
                       Male+ Male:Partner_Pos_MoodMC+Male:Self_Pos_MoodMC+
                       Female+ Female:Partner_Pos_MoodMC+Female:Self_Pos_MoodMC+
                       Male:Sex+ Male:Sex:Partner_Pos_MoodMC+Male:Sex:Self_Pos_MoodMC+
                       Female:Sex+ Female:Sex:Partner_Pos_MoodMC+Female:Sex:Self_Pos_MoodMC,
                     # random = ~ -1 + Male+Male:Partner_Pos_MoodMC+Male:Self_Pos_MoodMC+ 
                     #   Female+Female:Partner_Pos_MoodMC+Female:Self_Pos_MoodMC| Couple,
                     # Didn't converge with adding bias effects into random effect, so I moved to the simpler model
                     random = ~ -1 + Male+Male:Partner_Pos_MoodMC+ 
                       Female+Female:Partner_Pos_MoodMC| Couple,
                     
                     weights = varIdent(form=~1|Gender),
                     # corr=corAR1(form = ~1 | Couple/DiaryDay),
                     correlation = corCompSymm(form = ~1|Couple/DiaryDay),
                     data = Long1,
                     # data = Long1 %>% mutate(Sex=1-Sex)#activate for simple slope analysis
                     ,na.action = na.exclude)
summary(TB_Long_Model3)
Linear mixed-effects model fit by REML
  Data: Long1 
       AIC      BIC    logLik
  26271.37 26423.98 -13110.68

Random effects:
 Formula: ~-1 + Male + Male:Partner_Pos_MoodMC + Female + Female:Partner_Pos_MoodMC | Couple
 Structure: General positive-definite, Log-Cholesky parametrization
                          StdDev     Corr                
Male                       7.2021284 Male   Female M:P_P_
Female                     9.4920994 -0.428              
Male:Partner_Pos_MoodMC    0.1596882 -0.166 -0.271       
Partner_Pos_MoodMC:Female  0.1789004  0.161 -0.362  0.201
Residual                  11.6202646                     

Correlation Structure: Compound symmetry
 Formula: ~1 | Couple/DiaryDay 
 Parameter estimate(s):
        Rho 
-0.02067036 
Variance function:
 Structure: Different standard deviations per stratum
 Formula: ~1 | Gender 
 Parameter estimates:
    -0.5      0.5 
1.000000 1.008277 
Fixed effects:  Judg_Pos_MoodMC ~ -1 + Male + Male:Partner_Pos_MoodMC + Male:Self_Pos_MoodMC +      Female + Female:Partner_Pos_MoodMC + Female:Self_Pos_MoodMC +      Male:Sex + Male:Sex:Partner_Pos_MoodMC + Male:Sex:Self_Pos_MoodMC +      Female:Sex + Female:Sex:Partner_Pos_MoodMC + Female:Sex:Self_Pos_MoodMC 
                                   Value Std.Error   DF   t-value p-value
Male                          -1.9633663 0.9259569 3235 -2.120365  0.0341
Female                        -0.0476715 1.1707216 3235 -0.040720  0.9675
Male:Partner_Pos_MoodMC        0.2056630 0.0288405 3235  7.131046  0.0000
Male:Self_Pos_MoodMC           0.4790217 0.0229066 3235 20.911994  0.0000
Partner_Pos_MoodMC:Female      0.1623210 0.0322049 3235  5.040264  0.0000
Self_Pos_MoodMC:Female         0.4481544 0.0223236 3235 20.075371  0.0000
Male:Sex                       2.1749659 0.7224935 3235  3.010360  0.0026
Female:Sex                     0.2719124 0.7344201 3235  0.370241  0.7112
Male:Partner_Pos_MoodMC:Sex   -0.0017094 0.0341627 3235 -0.050038  0.9601
Male:Self_Pos_MoodMC:Sex      -0.0358208 0.0374766 3235 -0.955820  0.3392
Partner_Pos_MoodMC:Female:Sex  0.0146349 0.0380211 3235  0.384914  0.7003
Self_Pos_MoodMC:Female:Sex     0.0936723 0.0337561 3235  2.774976  0.0056
 Correlation: 
                              Male   Female Ml:P_P_MMC Ml:S_P_MMC Pr_P_MMC:F
Female                        -0.359                                        
Male:Partner_Pos_MoodMC       -0.017 -0.164                                 
Male:Self_Pos_MoodMC          -0.057  0.009 -0.132                          
Partner_Pos_MoodMC:Female      0.091 -0.256  0.085     -0.041               
Self_Pos_MoodMC:Female        -0.024  0.083 -0.049      0.007     -0.135    
Male:Sex                      -0.196  0.003 -0.087     -0.001      0.003    
Female:Sex                     0.006 -0.156  0.006      0.004     -0.006    
Male:Partner_Pos_MoodMC:Sex   -0.040  0.002 -0.306      0.064      0.001    
Male:Self_Pos_MoodMC:Sex       0.023  0.001  0.053     -0.370      0.000    
Partner_Pos_MoodMC:Female:Sex  0.002  0.010  0.000      0.006     -0.279    
Self_Pos_MoodMC:Female:Sex     0.003 -0.023  0.008      0.000      0.059    
                              Sl_P_MMC:F Mal:Sx Fml:Sx M:P_P_MMC: M:S_P_MMC:
Female                                                                      
Male:Partner_Pos_MoodMC                                                     
Male:Self_Pos_MoodMC                                                        
Partner_Pos_MoodMC:Female                                                   
Self_Pos_MoodMC:Female                                                      
Male:Sex                       0.009                                        
Female:Sex                    -0.115     -0.022                             
Male:Partner_Pos_MoodMC:Sex    0.010      0.057 -0.006                      
Male:Self_Pos_MoodMC:Sex      -0.001     -0.204  0.006 -0.252               
Partner_Pos_MoodMC:Female:Sex  0.073      0.005 -0.216  0.006     -0.019    
Self_Pos_MoodMC:Female:Sex    -0.390     -0.004  0.014 -0.019      0.005    
                              P_P_MMC:F:
Female                                  
Male:Partner_Pos_MoodMC                 
Male:Self_Pos_MoodMC                    
Partner_Pos_MoodMC:Female               
Self_Pos_MoodMC:Female                  
Male:Sex                                
Female:Sex                              
Male:Partner_Pos_MoodMC:Sex             
Male:Self_Pos_MoodMC:Sex                
Partner_Pos_MoodMC:Female:Sex           
Self_Pos_MoodMC:Female:Sex    -0.207    

Standardized Within-Group Residuals:
         Min           Q1          Med           Q3          Max 
-5.192535859 -0.575570734  0.004970308  0.565885729  3.500104291 

Number of Observations: 3322
Number of Groups: 76 
tab_model(TB_Long_Model1,TB_Long_Model2,TB_Long_Model3,show.r2=F)
  Judg Pos Mood MC Judg Pos Mood MC Judg Pos Mood MC
Predictors Estimates CI p Estimates CI p Estimates CI p
Male 0.24 -2.71 – 3.18 0.875 -1.43 -3.20 – 0.34 0.113 -1.96 -3.78 – -0.15 0.034
Female -1.43 -5.03 – 2.17 0.437 0.08 -2.16 – 2.33 0.942 -0.05 -2.34 – 2.25 0.968
Male × Partner Pos MoodMC 0.33 0.26 – 0.39 <0.001 0.21 0.16 – 0.26 <0.001 0.21 0.15 – 0.26 <0.001
Partner Pos MoodMC ×
Female
0.28 0.22 – 0.34 <0.001 0.17 0.11 – 0.23 <0.001 0.16 0.10 – 0.23 <0.001
Male × Self Pos MoodMC 0.48 0.44 – 0.52 <0.001 0.48 0.43 – 0.52 <0.001
Self Pos MoodMC × Female 0.48 0.44 – 0.52 <0.001 0.45 0.40 – 0.49 <0.001
Male × Sex 2.17 0.76 – 3.59 0.003
Female × Sex 0.27 -1.17 – 1.71 0.711
Male × Partner Pos MoodMC
× Sex
-0.00 -0.07 – 0.07 0.960
Male × Self Pos MoodMC ×
Sex
-0.04 -0.11 – 0.04 0.339
Partner Pos MoodMC ×
Female × Sex
0.01 -0.06 – 0.09 0.700
Self Pos MoodMC × Female
× Sex
0.09 0.03 – 0.16 0.006
Random Effects
σ2 164.47 135.77 135.03
τ00      
τ00      
τ11 243.25 Couple.Female 88.32 Couple.Female 90.10 Couple.Female
0.04 Couple.Male:Partner_Pos_MoodMC 0.03 Couple.Male:Partner_Pos_MoodMC 0.03 Couple.Male:Partner_Pos_MoodMC
0.03 Couple.Partner_Pos_MoodMC:Female 0.03 Couple.Partner_Pos_MoodMC:Female 0.03 Couple.Partner_Pos_MoodMC:Female
ρ01 -0.19 -0.45 -0.43
-0.21 -0.18 -0.17
-0.09 0.18 0.16
ICC 0.57 0.37 0.38
N 76 Couple 76 Couple 76 Couple
Observations 3324 3324 3322

Model 4: Mediated T&B

for simplicity I use here different models for men and women # Using the method by Bauer, D. J., Preacher, K. J., & Gil, K. M. (2006)

https://quantdev.ssri.psu.edu/sites/qdev/files/ILD_Ch07_2017_Within-PersonMedationWithMLM.html

https://quantpsy.org/medmc/medmc111.htm

For Men:
Men_Long1 <- Long1 %>% filter(Male==1)
Men_Long1 <- Men_Long1 %>% select(ID,DiaryDay,x=Partner_Pos_MoodMC,m2=Self_Pos_MoodMC,m=Self_Pos_MoodMC,y=Judg_Pos_MoodMC)
#multivariate structure
Men_Long2 <- Men_Long1 %>% pivot_longer(cols=c(m:y), names_to="dv",values_to="z") %>% rename(m=m2)

#Adding the dummy indicators
Men_Long2 <- Men_Long2 %>% mutate(dy=ifelse(dv=="y",1,0),
                                  dm=ifelse(dv=="m",1,0),
                                  dvnum=ifelse(dv=="m",1,0))


Men_Model <- lme(fixed = z ~ -1 +
                   dm+dm:x +  #a path
                   dy+dy:m+dy:x ,#b+c paths
                 random = ~ -1+dm+dm:x +
                   dy+dy:m+dy:x | ID, 
                 weights = varIdent(form = ~ 1 | dvnum), #this invokes separate sigma^{2}_{e} for each outcome
                 corr=corSymm(form = ~1 | ID/DiaryDay),# this invokes the off-diaginal sigma_{e1e2}
                 data=Men_Long2,
                 na.action=na.exclude,
                 control=lmeControl(opt="optim",maxIter = 200, msMaxIter = 200, niterEM = 50, msMaxEval = 400))
summary(Men_Model)
Linear mixed-effects model fit by REML
  Data: Men_Long2 
       AIC      BIC    logLik
  26602.04 26742.54 -13278.02

Random effects:
 Formula: ~-1 + dm + dm:x + dy + dy:m + dy:x | ID
 Structure: General positive-definite, Log-Cholesky parametrization
         StdDev     Corr                       
dm       14.4562005 dm     dy     dm:x   dy:m  
dy        7.8532652  0.647                     
dm:x      0.1267200 -0.253 -0.146              
dy:m      0.1204881 -0.264 -0.163  0.560       
x:dy      0.1554505 -0.281 -0.288  0.724  0.232
Residual 12.8668307                            

Correlation Structure: General
 Formula: ~1 | ID/DiaryDay 
 Parameter estimate(s):
 Correlation: 
  1     
2 -0.055
Variance function:
 Structure: Different standard deviations per stratum
 Formula: ~1 | dvnum 
 Parameter estimates:
        1         0 
1.0000000 0.8929567 
Fixed effects:  z ~ -1 + dm + dm:x + dy + dy:m + dy:x 
          Value Std.Error   DF   t-value p-value
dm    2.9957656 1.7014415 3247  1.760722  0.0784
dy   -1.2214638 0.9870576 3247 -1.237480  0.2160
dm:x  0.1755245 0.0269896 3247  6.503404  0.0000
dy:m  0.4595154 0.0256117 3247 17.941634  0.0000
x:dy  0.1866255 0.0268265 3247  6.956767  0.0000
 Correlation: 
     dm     dy     dm:x   dy:m  
dy    0.588                     
dm:x -0.096 -0.074              
dy:m -0.139 -0.133  0.169       
x:dy -0.176 -0.121  0.293 -0.040

Standardized Within-Group Residuals:
        Min          Q1         Med          Q3         Max 
-3.93379612 -0.56238525  0.03358847  0.56692955  4.09769126 

Number of Observations: 3327
Number of Groups: 76 

Extracting model’s estimates

(medmodelsummary <- summary(Men_Model))
Linear mixed-effects model fit by REML
  Data: Men_Long2 
       AIC      BIC    logLik
  26602.04 26742.54 -13278.02

Random effects:
 Formula: ~-1 + dm + dm:x + dy + dy:m + dy:x | ID
 Structure: General positive-definite, Log-Cholesky parametrization
         StdDev     Corr                       
dm       14.4562005 dm     dy     dm:x   dy:m  
dy        7.8532652  0.647                     
dm:x      0.1267200 -0.253 -0.146              
dy:m      0.1204881 -0.264 -0.163  0.560       
x:dy      0.1554505 -0.281 -0.288  0.724  0.232
Residual 12.8668307                            

Correlation Structure: General
 Formula: ~1 | ID/DiaryDay 
 Parameter estimate(s):
 Correlation: 
  1     
2 -0.055
Variance function:
 Structure: Different standard deviations per stratum
 Formula: ~1 | dvnum 
 Parameter estimates:
        1         0 
1.0000000 0.8929567 
Fixed effects:  z ~ -1 + dm + dm:x + dy + dy:m + dy:x 
          Value Std.Error   DF   t-value p-value
dm    2.9957656 1.7014415 3247  1.760722  0.0784
dy   -1.2214638 0.9870576 3247 -1.237480  0.2160
dm:x  0.1755245 0.0269896 3247  6.503404  0.0000
dy:m  0.4595154 0.0256117 3247 17.941634  0.0000
x:dy  0.1866255 0.0268265 3247  6.956767  0.0000
 Correlation: 
     dm     dy     dm:x   dy:m  
dy    0.588                     
dm:x -0.096 -0.074              
dy:m -0.139 -0.133  0.169       
x:dy -0.176 -0.121  0.293 -0.040

Standardized Within-Group Residuals:
        Min          Q1         Med          Q3         Max 
-3.93379612 -0.56238525  0.03358847  0.56692955  4.09769126 

Number of Observations: 3327
Number of Groups: 76 
(medmodelsummary <- summary(Men_Model))
Linear mixed-effects model fit by REML
  Data: Men_Long2 
       AIC      BIC    logLik
  26602.04 26742.54 -13278.02

Random effects:
 Formula: ~-1 + dm + dm:x + dy + dy:m + dy:x | ID
 Structure: General positive-definite, Log-Cholesky parametrization
         StdDev     Corr                       
dm       14.4562005 dm     dy     dm:x   dy:m  
dy        7.8532652  0.647                     
dm:x      0.1267200 -0.253 -0.146              
dy:m      0.1204881 -0.264 -0.163  0.560       
x:dy      0.1554505 -0.281 -0.288  0.724  0.232
Residual 12.8668307                            

Correlation Structure: General
 Formula: ~1 | ID/DiaryDay 
 Parameter estimate(s):
 Correlation: 
  1     
2 -0.055
Variance function:
 Structure: Different standard deviations per stratum
 Formula: ~1 | dvnum 
 Parameter estimates:
        1         0 
1.0000000 0.8929567 
Fixed effects:  z ~ -1 + dm + dm:x + dy + dy:m + dy:x 
          Value Std.Error   DF   t-value p-value
dm    2.9957656 1.7014415 3247  1.760722  0.0784
dy   -1.2214638 0.9870576 3247 -1.237480  0.2160
dm:x  0.1755245 0.0269896 3247  6.503404  0.0000
dy:m  0.4595154 0.0256117 3247 17.941634  0.0000
x:dy  0.1866255 0.0268265 3247  6.956767  0.0000
 Correlation: 
     dm     dy     dm:x   dy:m  
dy    0.588                     
dm:x -0.096 -0.074              
dy:m -0.139 -0.133  0.169       
x:dy -0.176 -0.121  0.293 -0.040

Standardized Within-Group Residuals:
        Min          Q1         Med          Q3         Max 
-3.93379612 -0.56238525  0.03358847  0.56692955  4.09769126 

Number of Observations: 3327
Number of Groups: 76 
(FEmatrix <- coef(medmodelsummary))
          Value  Std.Error   DF   t-value      p-value
dm    2.9957656 1.70144152 3247  1.760722 7.837959e-02
dy   -1.2214638 0.98705760 3247 -1.237480 2.159985e-01
dm:x  0.1755245 0.02698964 3247  6.503404 9.058942e-11
dy:m  0.4595154 0.02561168 3247 17.941634 1.044056e-68
x:dy  0.1866255 0.02682647 3247  6.956767 4.193019e-12
#Fixed effects (a,b,c')
a <- FEmatrix[3]
b <- FEmatrix[4]
cprime <- FEmatrix[5]

#random effects
REmatrix <- VarCorr(Men_Model)
sig2_a <- as.numeric(REmatrix[3])
sig2_b <- as.numeric(REmatrix[4])
sig2_cprime <- as.numeric(REmatrix[5])

CovMatrix <- getVarCov(Men_Model)
covajbj <- CovMatrix[3,4]

indirecteffect <- a*b + covajbj 
totaleffect <- cprime + a*b + covajbj   
(percentmediated <- 100*(indirecteffect/totaleffect)  )
[1] 32.34258
#Pulling the asymptotic covariances for the fixed effects of interest
(ACM_FE <- vcov(Men_Model))
               dm           dy          dm:x          dy:m          x:dy
dm    2.894903233  0.988250742 -0.0044262108 -6.063692e-03 -8.039964e-03
dy    0.988250742  0.974282710 -0.0019674809 -3.360059e-03 -3.191336e-03
dm:x -0.004426211 -0.001967481  0.0007284406  1.170198e-04  2.124116e-04
dy:m -0.006063692 -0.003360059  0.0001170198  6.559582e-04 -2.750916e-05
x:dy -0.008039964 -0.003191336  0.0002124116 -2.750916e-05  7.196593e-04
vara <- ACM_FE[3,3]
varb <- ACM_FE[4,4]
covab <- ACM_FE[3,4]

#Pulling the asymptotic covariances for the random effects
#Using the vcov_vc() in the bootmlm library
# (ACM_RE <- bootmlm::vcov_vc(Men_Model, sd_cor = FALSE, print_names = TRUE))#work only with lmer models
# remotes::install_github("marklhc/bootmlm")
# varcovajbj=ACM_RE[2,2]
varcovajbj=0

running Monte Carlo simulation

a=a 
b=b 
covajbj=covajbj 
vara=vara 
varb=varb 
covab=covab 
varcovajbj=varcovajbj 
rep=20000
conf=95
dvec=rnorm(rep)
avec=dvec*sqrt(vara)+a
bvec=dvec*covab/sqrt(vara)+sqrt(varb)*rnorm(rep,sd=sqrt(1-(covab^2)/(vara*varb)))+b
cvec=rnorm(rep)*sqrt(varcovajbj)+covajbj
ab=avec*bvec+cvec
low=(1-conf/100)/2
upp=((1-conf/100)/2)+(conf/100)
LL=quantile(ab,low)
UL=quantile(ab,upp)
LL4=format(LL,digits=4)
UL4=format(UL,digits=4)

hist(ab,breaks='FD',col='skyblue',xlab=paste(conf,'% Confidence Interval ','LL',LL4,'  UL',UL4),
     main='Distribution of Indirect Effect')

For Women:
#For Females:
Women_Long1 <- Long1 %>% filter(Female==1)
Women_Long1 <- Women_Long1 %>% select(ID,DiaryDay,x=Partner_Pos_MoodMC,m2=Self_Pos_MoodMC,m=Self_Pos_MoodMC,y=Judg_Pos_MoodMC)
#multivariate structure
Women_Long2 <- Women_Long1 %>% pivot_longer(cols=c(m:y), names_to="dv",values_to="z") %>% rename(m=m2)

#Adding the dummy indicators
Women_Long2 <- Women_Long2 %>% mutate(dy=ifelse(dv=="y",1,0),
                                  dm=ifelse(dv=="m",1,0),
                                  dvnum=ifelse(dv=="m",1,0))


Women_Model <- lme(fixed = z ~ -1 +
                   dm+dm:x +  #a path
                   dy+dy:m+dy:x ,#b+c paths
                 random = ~ -1+dm+dm:x +
                   dy+dy:m+dy:x | ID, 
                 weights = varIdent(form = ~ 1 | dvnum), #this invokes separate sigma^{2}_{e} for each outcome
                 corr=corSymm(form = ~1 | ID/DiaryDay),# this invokes the off-diaginal sigma_{e1e2}
                 data=Women_Long2,
                 na.action=na.exclude,
                 control=lmeControl(opt="optim",maxIter = 200, msMaxIter = 200, niterEM = 50, msMaxEval = 400))
summary(Women_Model)
Linear mixed-effects model fit by REML
  Data: Women_Long2 
       AIC      BIC    logLik
  26882.02 27022.52 -13418.01

Random effects:
 Formula: ~-1 + dm + dm:x + dy + dy:m + dy:x | ID
 Structure: General positive-definite, Log-Cholesky parametrization
         StdDev      Corr                       
dm       16.11733638 dm     dy     dm:x   dy:m  
dy        9.65533742  0.657                     
dm:x      0.13098990 -0.083  0.067              
dy:m      0.08285679 -0.395 -0.508 -0.186       
x:dy      0.15565274  0.086 -0.344  0.024  0.220
Residual 13.74045801                            

Correlation Structure: General
 Formula: ~1 | ID/DiaryDay 
 Parameter estimate(s):
 Correlation: 
  1     
2 -0.043
Variance function:
 Structure: Different standard deviations per stratum
 Formula: ~1 | dvnum 
 Parameter estimates:
        1         0 
1.0000000 0.8503061 
Fixed effects:  z ~ -1 + dm + dm:x + dy + dy:m + dy:x 
         Value Std.Error   DF   t-value p-value
dm   -3.715616 1.8934998 3247 -1.962300  0.0498
dy    0.733774 1.1760408 3247  0.623936  0.5327
dm:x  0.189320 0.0302398 3247  6.260635  0.0000
dy:m  0.473689 0.0222007 3247 21.336684  0.0000
x:dy  0.156641 0.0285439 3247  5.487721  0.0000
 Correlation: 
     dm     dy     dm:x   dy:m  
dy    0.604                     
dm:x -0.072  0.035              
dy:m -0.165 -0.157 -0.037       
x:dy  0.053 -0.261  0.033 -0.076

Standardized Within-Group Residuals:
        Min          Q1         Med          Q3         Max 
-5.15723228 -0.58020893  0.01072805  0.58355766  3.89646755 

Number of Observations: 3327
Number of Groups: 76 
#viewing and putting model summary into an object
(medmodelsummary <- summary(Women_Model))
Linear mixed-effects model fit by REML
  Data: Women_Long2 
       AIC      BIC    logLik
  26882.02 27022.52 -13418.01

Random effects:
 Formula: ~-1 + dm + dm:x + dy + dy:m + dy:x | ID
 Structure: General positive-definite, Log-Cholesky parametrization
         StdDev      Corr                       
dm       16.11733638 dm     dy     dm:x   dy:m  
dy        9.65533742  0.657                     
dm:x      0.13098990 -0.083  0.067              
dy:m      0.08285679 -0.395 -0.508 -0.186       
x:dy      0.15565274  0.086 -0.344  0.024  0.220
Residual 13.74045801                            

Correlation Structure: General
 Formula: ~1 | ID/DiaryDay 
 Parameter estimate(s):
 Correlation: 
  1     
2 -0.043
Variance function:
 Structure: Different standard deviations per stratum
 Formula: ~1 | dvnum 
 Parameter estimates:
        1         0 
1.0000000 0.8503061 
Fixed effects:  z ~ -1 + dm + dm:x + dy + dy:m + dy:x 
         Value Std.Error   DF   t-value p-value
dm   -3.715616 1.8934998 3247 -1.962300  0.0498
dy    0.733774 1.1760408 3247  0.623936  0.5327
dm:x  0.189320 0.0302398 3247  6.260635  0.0000
dy:m  0.473689 0.0222007 3247 21.336684  0.0000
x:dy  0.156641 0.0285439 3247  5.487721  0.0000
 Correlation: 
     dm     dy     dm:x   dy:m  
dy    0.604                     
dm:x -0.072  0.035              
dy:m -0.165 -0.157 -0.037       
x:dy  0.053 -0.261  0.033 -0.076

Standardized Within-Group Residuals:
        Min          Q1         Med          Q3         Max 
-5.15723228 -0.58020893  0.01072805  0.58355766  3.89646755 

Number of Observations: 3327
Number of Groups: 76 
(medmodelsummary <- summary(Women_Model))
Linear mixed-effects model fit by REML
  Data: Women_Long2 
       AIC      BIC    logLik
  26882.02 27022.52 -13418.01

Random effects:
 Formula: ~-1 + dm + dm:x + dy + dy:m + dy:x | ID
 Structure: General positive-definite, Log-Cholesky parametrization
         StdDev      Corr                       
dm       16.11733638 dm     dy     dm:x   dy:m  
dy        9.65533742  0.657                     
dm:x      0.13098990 -0.083  0.067              
dy:m      0.08285679 -0.395 -0.508 -0.186       
x:dy      0.15565274  0.086 -0.344  0.024  0.220
Residual 13.74045801                            

Correlation Structure: General
 Formula: ~1 | ID/DiaryDay 
 Parameter estimate(s):
 Correlation: 
  1     
2 -0.043
Variance function:
 Structure: Different standard deviations per stratum
 Formula: ~1 | dvnum 
 Parameter estimates:
        1         0 
1.0000000 0.8503061 
Fixed effects:  z ~ -1 + dm + dm:x + dy + dy:m + dy:x 
         Value Std.Error   DF   t-value p-value
dm   -3.715616 1.8934998 3247 -1.962300  0.0498
dy    0.733774 1.1760408 3247  0.623936  0.5327
dm:x  0.189320 0.0302398 3247  6.260635  0.0000
dy:m  0.473689 0.0222007 3247 21.336684  0.0000
x:dy  0.156641 0.0285439 3247  5.487721  0.0000
 Correlation: 
     dm     dy     dm:x   dy:m  
dy    0.604                     
dm:x -0.072  0.035              
dy:m -0.165 -0.157 -0.037       
x:dy  0.053 -0.261  0.033 -0.076

Standardized Within-Group Residuals:
        Min          Q1         Med          Q3         Max 
-5.15723228 -0.58020893  0.01072805  0.58355766  3.89646755 

Number of Observations: 3327
Number of Groups: 76 
(FEmatrix <- coef(medmodelsummary))
          Value  Std.Error   DF    t-value      p-value
dm   -3.7156157 1.89349985 3247 -1.9623005 4.981279e-02
dy    0.7337745 1.17604083 3247  0.6239362 5.327133e-01
dm:x  0.1893202 0.03023977 3247  6.2606348 4.337169e-10
dy:m  0.4736890 0.02220069 3247 21.3366843 1.221538e-94
x:dy  0.1566408 0.02854387 3247  5.4877213 4.384036e-08
#Fixed effects (a,b,c')
a <- FEmatrix[3]
b <- FEmatrix[4]
cprime <- FEmatrix[5]

#random effects
REmatrix <- VarCorr(Women_Model)
sig2_a <- as.numeric(REmatrix[3])
sig2_b <- as.numeric(REmatrix[4])
sig2_cprime <- as.numeric(REmatrix[5])

CovMatrix <- getVarCov(Women_Model)
covajbj <- CovMatrix[3,4]

indirecteffect <- a*b + covajbj 
totaleffect <- cprime + a*b + covajbj   
(percentmediated <- 100*(indirecteffect/totaleffect)  )
[1] 35.88231
#Pulling the asymptotic covariances for the fixed effects of interest
(ACM_FE <- vcov(Women_Model))
               dm           dy          dm:x          dy:m          x:dy
dm    3.585341677  1.344232039 -4.130315e-03 -6.921059e-03  2.870044e-03
dy    1.344232039  1.383072039  1.229820e-03 -4.090071e-03 -8.765053e-03
dm:x -0.004130315  0.001229820  9.144438e-04 -2.456088e-05  2.847951e-05
dy:m -0.006921059 -0.004090071 -2.456088e-05  4.928705e-04 -4.842403e-05
x:dy  0.002870044 -0.008765053  2.847951e-05 -4.842403e-05  8.147526e-04
vara <- ACM_FE[3,3]
varb <- ACM_FE[4,4]
covab <- ACM_FE[3,4]

#Pulling the asymptotic covariances for the random effects
#Using the vcov_vc() in the bootmlm library
# (ACM_RE <- bootmlm::vcov_vc(Women_Model, sd_cor = FALSE, print_names = TRUE))#work only with lmer models
# remotes::install_github("marklhc/bootmlm")
# varcovajbj=ACM_RE[2,2]
varcovajbj=0

a=a 
b=b 
covajbj=covajbj 
vara=vara 
varb=varb 
covab=covab 
varcovajbj=varcovajbj 
rep=20000
conf=95
dvec=rnorm(rep)
avec=dvec*sqrt(vara)+a
bvec=dvec*covab/sqrt(vara)+sqrt(varb)*rnorm(rep,sd=sqrt(1-(covab^2)/(vara*varb)))+b
cvec=rnorm(rep)*sqrt(varcovajbj)+covajbj
ab=avec*bvec+cvec
low=(1-conf/100)/2
upp=((1-conf/100)/2)+(conf/100)
LL=quantile(ab,low)
UL=quantile(ab,upp)
LL4=format(LL,digits=4)
UL4=format(UL,digits=4)

hist(ab,breaks='FD',col='skyblue',xlab=paste(conf,'% Confidence Interval ','LL',LL4,'  UL',UL4),
     main='Distribution of Indirect Effect')

Model 5: Multivariate T&B (positive and negative mood)

Centering the negative mood variables

AvgTruthNeg=mean(temp1$Partner_Neg_Mood,na.rm=T)
Long1 <- Long1 %>% mutate(Judg_Neg_MoodMC=Judg_Neg_Mood-AvgTruthNeg,
                          Partner_Neg_MoodMC=Partner_Neg_Mood-AvgTruthNeg,
                          Self_Neg_MoodMC=Self_Neg_Mood-AvgTruthNeg
)

Keeping only relevant variables, and changing their names

Long2 <- Long1 %>% select(Couple,DiaryDay,ID,Pos_Judg=Judg_Pos_MoodMC,Neg_Judg=Judg_Neg_MoodMC,
                                             Pos_Truth=Partner_Pos_MoodMC,Neg_Truth=Partner_Neg_MoodMC,Female,Male)

Creating Multivariate structure:

Long3 <- Long2 %>% pivot_longer(cols=c(Pos_Judg:Neg_Truth),names_to = c("Pos_Neg","Var"), names_sep = "_",values_to="z") %>% 
  pivot_wider(id_cols=c(Couple:Pos_Neg),values_from = "z",names_from = "Var") %>% 
  mutate(Pos=ifelse(Pos_Neg=="Pos",1,0),
         Neg=ifelse(Pos_Neg=="Neg",1,0),
         Pos_Neg_G=paste0(Pos_Neg,"_",Male)
         )
head(Long3)
# A tibble: 6 × 11
  Couple DiaryDay    ID Female  Male Pos_Neg  Judg   Truth   Pos   Neg Pos_Neg_G
   <int>    <int> <int>  <int> <int> <chr>   <dbl>   <dbl> <dbl> <dbl> <chr>    
1    100        0  1000      0     1 Pos     -26.6 -39.6       1     0 Pos_1    
2    100        0  1000      0     1 Neg      69.7  50.1       0     1 Neg_1    
3    100        1  1000      0     1 Pos     -29.6   0.436     1     0 Pos_1    
4    100        1  1000      0     1 Neg      19.7  -5.92      0     1 Neg_1    
5    100        2  1000      0     1 Pos     -29.2 -32.9       1     0 Pos_1    
6    100        2  1000      0     1 Neg      14.7  11.1       0     1 Neg_1    

Estimating the model

TB_Long_Model4 <- lme(fixed = Judg ~ -1 +
                     Male:Pos+Male:Pos:Truth +#men's positive
                     Female:Pos+Female:Pos:Truth+#women's positive
                     Male:Neg+Male:Neg:Truth +#men's negative
                     Female:Neg+Female:Neg:Truth,#women's negative  
                     random = ~ -1 + 
                     Male:Pos+Male:Pos:Truth +
                     Female:Pos+Female:Pos:Truth+
                     Male:Neg+Male:Neg:Truth +
                     Female:Neg+Female:Neg:Truth
                       | Couple,
                     weights = varIdent(form=~1|Pos_Neg_G),
                     # corr=corAR1(form = ~1 | Couple/DiaryDay),
                     #corr=corSymm(form = ~1 | Couple/DiaryDay/Pos_Neg_G),
                                        data=Long3,
                   na.action=na.exclude,
                   control=lmeControl(opt="optim",maxIter = 200, msMaxIter = 200, niterEM = 50, msMaxEval = 400))
summary(TB_Long_Model4)
Linear mixed-effects model fit by REML
  Data: Long3 
       AIC      BIC    logLik
  51843.62 52170.07 -25873.81

Random effects:
 Formula: ~-1 + Male:Pos + Male:Pos:Truth + Female:Pos + Female:Pos:Truth +      Male:Neg + Male:Neg:Truth + Female:Neg + Female:Neg:Truth | Couple
 Structure: General positive-definite, Log-Cholesky parametrization
                 StdDev     Corr                                            
Male:Pos         13.0075062 Mal:Ps Ps:Fml Mal:Ng Fml:Ng Ml:P:T Ps:T:F Ml:T:N
Pos:Female       15.8392611 -0.099                                          
Male:Neg          8.5945502 -0.074 -0.215                                   
Female:Neg        6.7949922  0.017 -0.244 -0.041                            
Male:Pos:Truth    0.2344183 -0.109 -0.198  0.265  0.130                     
Pos:Truth:Female  0.1760986 -0.067 -0.162  0.061  0.218  0.294              
Male:Truth:Neg    0.3155208  0.135 -0.178  0.332 -0.007  0.841  0.416       
Truth:Female:Neg  0.2345493  0.052  0.084 -0.382  0.371 -0.094  0.701  0.082
Residual         12.7350344                                                 

Variance function:
 Structure: Different standard deviations per stratum
 Formula: ~1 | Pos_Neg_G 
 Parameter estimates:
    Pos_1     Neg_1     Pos_0     Neg_0 
1.0000000 0.8280895 1.0328893 0.6322623 
Fixed effects:  Judg ~ -1 + Male:Pos + Male:Pos:Truth + Female:Pos + Female:Pos:Truth +      Male:Neg + Male:Neg:Truth + Female:Neg + Female:Neg:Truth 
                     Value Std.Error   DF   t-value p-value
Male:Pos          0.019453 1.5514238 6565  0.012539  0.9900
Pos:Female       -1.420586 1.8614907 6565 -0.763144  0.4454
Male:Neg          4.372406 1.0327647 6565  4.233691  0.0000
Female:Neg       -0.498154 0.8145589 6565 -0.611563  0.5408
Male:Pos:Truth    0.286142 0.0355023 6565  8.059811  0.0000
Pos:Truth:Female  0.234376 0.0326561 6565  7.177120  0.0000
Male:Truth:Neg    0.407212 0.0472078 6565  8.625965  0.0000
Truth:Female:Neg  0.254566 0.0367206 6565  6.932511  0.0000
 Correlation: 
                 Mal:Ps Ps:Fml Mal:Ng Fml:Ng Ml:P:T Ps:T:F Ml:T:N
Pos:Female       -0.092                                          
Male:Neg         -0.075 -0.201                                   
Female:Neg        0.017 -0.232 -0.036                            
Male:Pos:Truth   -0.050 -0.147  0.192  0.094                     
Pos:Truth:Female -0.041 -0.128  0.036  0.135  0.138              
Male:Truth:Neg    0.090 -0.133  0.272 -0.006  0.507  0.201       
Truth:Female:Neg  0.039  0.051 -0.267  0.314 -0.056  0.349  0.048

Standardized Within-Group Residuals:
        Min          Q1         Med          Q3         Max 
-4.42215725 -0.54503780 -0.09824059  0.47667982  5.55625296 

Number of Observations: 6648
Number of Groups: 76 
tab_model(TB_Long_Model4,show.r2=F)
  Judg
Predictors Estimates CI p
Male × Pos 0.02 -3.02 – 3.06 0.990
Pos × Female -1.42 -5.07 – 2.23 0.445
Male × Neg 4.37 2.35 – 6.40 <0.001
Female × Neg -0.50 -2.09 – 1.10 0.541
Male × Pos × Truth 0.29 0.22 – 0.36 <0.001
Pos × Truth × Female 0.23 0.17 – 0.30 <0.001
Male × Truth × Neg 0.41 0.31 – 0.50 <0.001
Truth × Female × Neg 0.25 0.18 – 0.33 <0.001
Random Effects
σ2 162.18
τ00  
τ00  
τ11 Couple.Pos:Female 250.88
τ11 Couple.Male:Neg 73.87
τ11 Couple.Female:Neg 46.17
τ11 Couple.Male:Pos:Truth 0.05
τ11 Couple.Pos:Truth:Female 0.03
τ11 Couple.Male:Truth:Neg 0.10
τ11 Couple.Truth:Female:Neg 0.06
ρ01 -0.10
-0.07
0.02
-0.11
-0.07
0.14
0.05
ICC 0.48
N Couple 76
Observations 6648
VarCorr(TB_Long_Model4)
Couple = pdLogChol(-1 + Male:Pos + Male:Pos:Truth + Female:Pos + Female:Pos:Truth + ) Couple = pdLogChol(   Male:Neg + Male:Neg:Truth + Female:Neg + Female:Neg:Truth) 
                 Variance     StdDev     Corr                              
Male:Pos         169.19521870 13.0075062 Mal:Ps Ps:Fml Mal:Ng Fml:Ng Ml:P:T
Pos:Female       250.88219223 15.8392611 -0.099                            
Male:Neg          73.86629261  8.5945502 -0.074 -0.215                     
Female:Neg        46.17191869  6.7949922  0.017 -0.244 -0.041              
Male:Pos:Truth     0.05495194  0.2344183 -0.109 -0.198  0.265  0.130       
Pos:Truth:Female   0.03101070  0.1760986 -0.067 -0.162  0.061  0.218  0.294
Male:Truth:Neg     0.09955340  0.3155208  0.135 -0.178  0.332 -0.007  0.841
Truth:Female:Neg   0.05501337  0.2345493  0.052  0.084 -0.382  0.371 -0.094
Residual         162.18110205 12.7350344                                   
                              
Male:Pos         Ps:T:F Ml:T:N
Pos:Female                    
Male:Neg                      
Female:Neg                    
Male:Pos:Truth                
Pos:Truth:Female              
Male:Truth:Neg    0.416       
Truth:Female:Neg  0.701  0.082
Residual