# [R-sig-ME] Correlations among random variables

Avraham Kluger @vik @ending from @@vion@huji@@c@il
Sat Jan 12 08:01:02 CET 2019

```Hi,

I am struggling to analyze, in R, MLM models that specify correlations among random variables, as can be done with SPSS, SAS, or MlWin.

Consider the following code in SPSS
-----------------------------
MIXED
Outcome  BY role  WITH focalcode partcode
/FIXED = focalcode partcode | NOINT
/PRINT = SOLUTION TESTCOV
/RANDOM focalcode partcode | SUBJECT(focalid) COVTYPE(UNR)
/REPEATED = role | SUBJECT(focalid*dyadid) COVTYPE(UNR).
-----------------------------
And a minimal code (with data) in R

-----------------------------
library(lme4)

mlm <- lmer(outcome   ~ 0 + focalcode + partcode + role +
(0 + focalcode + partcode|| focalid/ dyadid),
data = df)
summary(mlm)
-----------------------------

These SPSS and R codes produce the same variance estimates.  However, SPSS also produces a correlation among "focalcode" and "partcode."  How can this be done in R?  Is it also possible to produce the correlation among the respective error variances (as in SPSS)?

1.       MOTIVATION.  The question arises from David Kenny's work on one-with-many reciprocal designs (e.g., a manager rate all subordinates, and all subordinates rate the same manager).  These models estimate the variance stemming from the one (e.g., managers) and the many (e.g., subordinates), and the correlation among them (termed generalized reciprocity).  The data and codes for SAS etc. are available at http://davidakenny.net/kkc/c10/c10.htm.

2.       SPSS OUTPUT (download HTML file):  https://www.dropbox.com/s/eqch0kq6djtbsfx/One%20with%20many%20SPSS%20output.htm?dl=1

Sincerely,

Avi Kluger
https://www.avi-kluger.com/

[[alternative HTML version deleted]]

```