Back to schedule


Read in the individual data (or a pairwise dataset)

library(tidyr)
library(dplyr)

acitelli_ind <- read.csv(file.choose(), header=TRUE)

Convert individual data to pairwise. If you imported a pairwise set, skip this chunk.

tempA <- acitelli_ind %>% 
  mutate(genderE = gender, partnum = 1) %>%
  mutate(gender = ifelse(gender == 1, "A", "P")) %>%
  gather(variable, value, self_pos:genderE) %>%
  unite(var_gender, variable, gender) %>%
  spread(var_gender, value)

tempB <- acitelli_ind %>% 
  mutate(genderE = gender, partnum = 2) %>%
  mutate(gender = ifelse(gender == 1, "P", "A")) %>%
  gather(variable, value, self_pos:genderE)%>%
  unite(var_gender, variable, gender) %>%
  spread(var_gender, value)

acitelli_pair <- bind_rows(tempA, tempB) %>%
  arrange(cuplid) 
  
rm(tempA, tempB)

Multilevel Modeling (MLM) for Dyadic Data

Now we’re ready to do multilevel modeling with the pairwise dataset!

#install.packages("nlme")
library(nlme)

mlm <- gls(satisfaction_A ~ genderE_A + Yearsmar,
          data = acitelli_pair,
          correlation = corCompSymm(form=~1|cuplid),
          na.action = na.omit)

summary(mlm)
## Generalized least squares fit by REML
##   Model: satisfaction_A ~ genderE_A + Yearsmar 
##   Data: acitelli_pair 
##        AIC      BIC    logLik
##   382.9383 401.3392 -186.4692
## 
## Correlation Structure: Compound symmetry
##  Formula: ~1 | cuplid 
##  Parameter estimate(s):
##       Rho 
## 0.6196688 
## 
## Coefficients:
##                 Value  Std.Error  t-value p-value
## (Intercept)  3.604730 0.03687099 97.76601  0.0000
## genderE_A    0.013514 0.01786704  0.75634  0.4501
## Yearsmar    -0.000379 0.00479242 -0.07916  0.9370
## 
##  Correlation: 
##           (Intr) gndE_A
## genderE_A 0            
## Yearsmar  0      0     
## 
## Standardized residuals:
##        Min         Q1        Med         Q3        Max 
## -4.9122662 -0.5110996  0.4292026  0.7693473  0.8313078 
## 
## Residual standard error: 0.4984454 
## Degrees of freedom: 296 total; 293 residual

Interpretation

Fixed Effects

Intercept: Predicted level of satisfaction for people married about 11 years.
Effect of genderE_A: Husbands are more satisfied than wives by .027 units (not significant); we need to double because the difference between Husbands (+1) and Wives (-1) is two units.
Effect of Yearsmar: For every year married, less satisfied by .0004 (not significant).

Random Effects

Rho is the correlation of residuals, 0.62.
Residual standard error is the error or unexplained variance (square-rooted).

Partial ICC equals .620. Husbands and wives are very similar in their level of marital satisfaction.


Back to schedule