[R] constraining correlations
Matthew Keller
mckellercran at gmail.com
Fri Oct 12 22:41:35 CEST 2007
Hi all,
I want to constrain observed correlations to be equal. E.g., I want to
find the ML cor(x,y) and cor (w,z) given that cor(x,y) must be equal
to cor(w,z).
I've received some suggestions that were sent directly to me, but
based on these responses, I'm afraid I wasn't clear enough in my
original querry (I think that my self-reproducing code through people
off).
I am *not* trying to create (simulate) variables that have some given
correlation. I know how to do that. Rather, given some empirical data
(such as that that I have simulated below in my code), I would like to
constrain some of the observed correlations to be the same value. I
can do this sort of thing in the Mx SEM software, but wanted to do it
from within R. Any help would be very appreciated!
Matt
On 10/11/07, Matthew Keller <mckellercran at gmail.com> wrote:
> Hello,
>
> I've searched for an answer to no avail. I am wondering if anyone
> knows how to constrain certain correlations to be equal. I have family
> data with 2 twins per family plus up to 2 siblings. I would like to
> somehow constrain all the sibling correlations (twin-sib and sib-sib)
> to be the same while allowing the twin-twin correlation to be
> different. Here is some simulated code:
>
> set.seed(5)
> famdata <- matrix(rnorm(400),ncol=4,dimnames=list(NULL,c("Twin1","Twin2","Sib1","Sib2")))
> famdata[runif(100)<.2,3] <- NA #20% of sib 1s are missing
> famdata[runif(100)<.4,4] <- NA #40% of sib 2s are missing
> cor(famdata,use="pairwise.complete")
>
> <R output>
> Twin1 Twin2 Sib1 Sib2
> Twin1 1.00000 0.12027 0.02286 -0.10578
> Twin2 0.12027 1.00000 0.08118 -0.08470
> Sib1 0.02286 0.08118 1.00000 -0.05064
> Sib2 -0.10578 -0.08470 -0.05064 1.00000
>
> So I want these five correlations: 0.02286 -0.10578 0.08118 -0.08470
> -0.05064 to be constrained to be the same value. My actual data is
> much more complicated than this, needing to constrain many different
> classes of parent-offspring and spousal correlations.
>
> Or is there some simpler alternative - e.g., transforming the
> correlations to a Fisher z and doing a weighted sum?
>
> Thanks in advance,
>
> Matt
>
--
Matthew C Keller
Asst. Professor of Psychology
University of Colorado at Boulder
www.matthewckeller.com
More information about the R-help
mailing list