[R-sig-ME] Correlations among random variables

Uanhoro, James u@nhoro@1 @ending from buckeyem@il@o@u@edu
Sat Jan 12 14:16:45 CET 2019


In the lme4 syntax, you'd have to change the double pipe, ||, when specifying the random effects to a single pipe, |, to permit a correlation between random effects. lme4 is faster than nlme.

Assuming lme4 and nlme are the only options ... If you want to specify an error covariance structure beyond the covariance structure implied by standard multilevel models, you will have to use nlme. nlme has a `correlation =` argument that allows different covariance structures, corSymm (general/unstructured), corCompSymm (exchangeable), ...


On Jan 12, 2019 02:01, Avraham Kluger <avik using savion.huji.ac.il> wrote:

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

-----------------------------
df <- read.csv("https://raw.githubusercontent.com/avi-kluger/RCompanion4DDABook/master/Chapter%2010/Chapter10_df.csv")
head(df)
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)?

Additional information


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]]

_______________________________________________
R-sig-mixed-models using r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models


	[[alternative HTML version deleted]]



More information about the R-sig-mixed-models mailing list