Back to schedule


Getting Started

We first need to open the data and load the library for the multilevel run.

library(nlme)
library(dyadr)

 riggsp <- read.csv("riggsp.csv") 

MLM Run Using GLS

We are doing a run looking at the effects of Gender (Gender_A) and Relationship Length (Rel_Length) on Attachment Anxiety (Anxiety_A), allowing for nonindepedence by correlating the errors of the two members and treating dyad members as indistinguishable:

dyad_mlm  <- gls(Anxiety_A ~ Gender_A + Rel_Length, na.action=na.omit, 
                 correlation=corCompSymm (form=~1|Dyad), data=riggsp)

We use gls as it allows us to correlate the errors of the two members.

The gls Statement Explained:

dyad_mlm = object name where the results are located
gls() statistical procedure used
Anxiety_A ~ outcome variable name in the dataset
Gender_A + Rel_Length, predictors variables in the dataset separated by plus signs
na.action=na.omit, needed if there are missing data
correlation=corCompSymm (form=~1|Dyad), correlates errors of the two members from the same dyad, Dyad is the ID variable for dyad
data=riggsp name of the dataset in R (see above)

Output for the run

summary(dyad_mlm)
## Generalized least squares fit by REML
##   Model: Anxiety_A ~ Gender_A + Rel_Length 
##   Data: riggsp 
##        AIC      BIC    logLik
##   1016.352 1034.986 -503.1758
## 
## Correlation Structure: Compound symmetry
##  Formula: ~1 | Dyad 
##  Parameter estimate(s):
##       Rho 
## 0.1752702 
## 
## Coefficients:
##                  Value  Std.Error   t-value p-value
## (Intercept)  3.1124125 0.14213523 21.897545  0.0000
## Gender_A     0.1471889 0.06299073  2.336676  0.0201
## Rel_Length  -0.1913836 0.06937610 -2.758638  0.0062
## 
##  Correlation: 
##            (Intr) Gndr_A
## Gender_A    0.000       
## Rel_Length -0.849  0.000
## 
## Standardized residuals:
##         Min          Q1         Med          Q3         Max 
## -2.14083388 -0.69990001 -0.03775157  0.62345798  2.72854066 
## 
## Residual standard error: 1.221242 
## Degrees of freedom: 310 total; 307 residual

Sometimes better to use the dyadr function of smallsummary:

smallsummary(dyad_mlm)
## Correlation structure of class corCompSymm representing
##       Rho 
## 0.1752702 
## 
## Residual standard error: 1.221242 
## 
##               Value Std.Error t-value p-value
## (Intercept)  3.1124    0.1421 21.8975  0.0000
## Gender_A     0.1472    0.0630  2.3367  0.0201
## Rel_Length  -0.1914    0.0694 -2.7586  0.0062
##               2.5 %  97.5 %
## (Intercept)  2.8338  3.3910
## Gender_A     0.0237  0.2706
## Rel_Length  -0.3274 -0.0554

Interpretation

They are interpreted as regression coefficients, adjusted for nonindependence.

Intercept = 3.11241250: The predicted level of Anxiety for those who score zero on all the predictors (someone halfway between a man and a woman and those who have just started a relationship)

Effect of Gender = 0.1471889: The effect of a one unit change of Gender_A on Anxiety_A holding Rel_Length constant. Given the coding of Gender_A the coefficient needs to be doubled and so we have 0.29437. Thus, women score .294 units higher on Attachment Anxiety than men. This result is statistically signficant. Note the the 95% confidence interval is from 0.0237 to 0.2706.

Effect of Relationship Length = -0.1913836: The effect of a year change of in relationship length leads to lower Attachement Anxiety of -0.19 units. Likely, it is more the issue that if couple members are anxiously attached, they are less likely to have long-term relationships. Note the the 95% confidence interval is from -0.3274 to -0.0554.

Note these tests are Z tests, not t tests, and so no degrees of freedom is associated with the test.

The measure of nonindependence is .175.

This is partial intraclass correlation. That is, it the correlations between the two members’ Attachment Anxiety, controlling for both gender and length of the relationship.

Also the standard deviation of the errors can be directly accessed by:

dyad_mlm$sigma
## [1] 1.221242

The standard deviation of the errors is 1.22. This can be useful in computing effect sizes. For instance, the gender d effect size would be

 0.1471889*2/1.221242
## [1] 0.2410479

The R code that could be used to compute “d” without putting the numbers is:

2*coef(summary(dyad_mlm))[2]/dyad_mlm$sigma
## [1] 0.241048

Because it is larger than .1 but smaller than .3, the effect would be viewed as “small.”

Output from “summary” not “smallsummary” to Ignore or To Be Considered Later:

Fit Statisics: AIC, BIC, logLik
Correlation of Effects

summary(dyad_mlm)
## Generalized least squares fit by REML
##   Model: Anxiety_A ~ Gender_A + Rel_Length 
##   Data: riggsp 
##        AIC      BIC    logLik
##   1016.352 1034.986 -503.1758
## 
## Correlation Structure: Compound symmetry
##  Formula: ~1 | Dyad 
##  Parameter estimate(s):
##       Rho 
## 0.1752702 
## 
## Coefficients:
##                  Value  Std.Error   t-value p-value
## (Intercept)  3.1124125 0.14213523 21.897545  0.0000
## Gender_A     0.1471889 0.06299073  2.336676  0.0201
## Rel_Length  -0.1913836 0.06937610 -2.758638  0.0062
## 
##  Correlation: 
##            (Intr) Gndr_A
## Gender_A    0.000       
## Rel_Length -0.849  0.000
## 
## Standardized residuals:
##         Min          Q1         Med          Q3         Max 
## -2.14083388 -0.69990001 -0.03775157  0.62345798  2.72854066 
## 
## Residual standard error: 1.221242 
## Degrees of freedom: 310 total; 307 residual

Back to schedule