Dear Daniel,
I thank you very much for your note. In the meantime, my student Limor Borut solved the problem with lme:
mlm <- lme(outcome ~ 0 + focalcode + 0 + partcode, random = ~ 0 + focalcode + partcode|focalid/dyadid, data = df)
Best,
Avi
-----Original Message-----
From: d.luedecke at uke.de [mailto:d.luedecke at uke.de]
Sent: Saturday, January 12, 2019 11:28 AM
To: Avraham Kluger <avik at savion.huji.ac.il>; r-sig-mixed-models at r-project.org
Subject: AW: [R-sig-ME] Correlations among random variables
Hi Avi,
You can find some of the numbers from the covariance parameters from the SPSS output also in the "summary()" from your model. Other parameters don't match, maybe the random effects structure needs to be specified in a different way? However, I'm not sure how to translate the rather "confusing"
SPSS notation into R-syntax.
Best
Daniel
-----Urspr?ngliche Nachricht-----
Von: R-sig-mixed-models <r-sig-mixed-models-bounces at r-project.org> Im Auftrag von Avraham Kluger
Gesendet: Samstag, 12. Januar 2019 08:01
An: r-sig-mixed-models at r-project.org
Cc: Michal Lehmann <chikush at gmail.com>; Kenny, David <david.kenny at uconn.edu>; Sarit Pery <sarit at peryjoy.com>
Betreff: [R-sig-ME] Correlations among random variables
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/ma
ster/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/
_______________________________________________
R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
--
_____________________________________________________________________
Universit?tsklinikum Hamburg-Eppendorf; K?rperschaft des ?ffentlichen Rechts; Gerichtsstand: Hamburg | www.uke.de
Vorstandsmitglieder: Prof. Dr. Burkhard G?ke (Vorsitzender), Prof. Dr. Dr. Uwe Koch-Gromus, Joachim Pr?l?, Marya Verdel _____________________________________________________________________
SAVE PAPER - THINK BEFORE PRINTING