[R-sig-ME] bivariate response mixed model using lme4 and residual (co)variances

Ned Dochtermann ned.dochtermann at gmail.com
Fri Sep 23 00:59:17 CEST 2011


Hi,
I think I may have misunderstood/misimplemented your recommendation.
Using the below data and model format:

	ind.data:
	ind   	ind.obs	y   	z
	1    	1		1.2  	2.4
	1    	2		1.3  	2.1
	2    	1		2.1  	3.2
	2    	2		2.3  	4.6
	...
	ind.data2<-melt(ind.data,id.var=c("ind","ind.obs"))
	ind.data2[1:2] <- lapply(ind.data2[1:2], factor)
	#and: 
	
yz.mm<-lmer(value~-1+variable+(variable-1|ind/ind.obs),data=ind.data2)

was, I thought, the way to go. However it doesn't seem to be what was really
needed. 
For example, in a representative case, simulated data had known
between-individual and within-individual correlations of 0 (4.3*10^-4
actually) and 0.5 (0.49997) respectively. Unfortunately the estimated
ind.obs:ind (within-individual) correlation was 0.736 (ind,
between-individual: 0.122). Incidentally, MCMCglmm likewise overestimated
the between-individual correlation (0.112) but produced a reasonably
accurate estimate of the within-individual correlation of 0.495.

Since the above approach accurately estimates the between-individual
correlation when the within correlation is 0, I suspect the problem is on my
end with model specification. Any ideas?

Thanks,
Ned

--
Ned A. Dochtermann
Department of Biology
University of Nevada, Reno

ned.dochtermann at gmail.com
http://wolfweb.unr.edu/homepage/mpeacock/Ned.Dochtermann/
http://www.researcherid.com/rid/A-7146-2010
--



From: Ned Dochtermann [mailto:ned.dochtermann at gmail.com] 
Sent: Wednesday, September 21, 2011 2:12 PM
To: r-sig-mixed-models at r-project.org; bbolker at gmail.com
Subject: Re: [R-sig-ME] bivariate response mixed model using lme4 and
residual (co)variances

Thanks! The reason would be my ignorance not yours! 
I found some SAS code a year or so back for using Proc Mixed for some
similar questions and adapted it to my purposes in R. Your approach is
certainly a lot smoother and cumbersome. Your "obs" recommendation also
looks good, I'll play around with that and compare it to MCMCglmm's within
individual estimates.

Thanks a lot,
Ned



Ben Bolker wrote:
 Maybe displaying my ignorance, but is there a particular reason
to use dummy variables instead of a factor?  That is, if I start with

ind   y   z
A    1.2  2.4
A    1.3  2.1
B    2.1  3.2
B    2.3  4.6
...

and then use melt(data,id.var=1) from reshape I get data that look like

ind  variable value
A     y      1.2
A     z      2.4
A     y      1.3
A     z      2.1
....

and then

lmer(value~variable-1+(
variable-1|ind),data=ind.data) ?

it seems you could also add an "obs" variable to the original
data frame, use it as an id var as well, and be able to get a
correlation among observations taken at the same time within
the same individual ...


Ned Dochtermann <ned.dochtermann at ...> writes:

>
> All,
>
> I am attempting to "cheat" with lme4 to calculate the correlation between
> two traits--y & z--measured repeatedly (simulation data actually) for
> individuals by use of dummy variables. I can calculate the
> between-individual variances and covariances with the data structured as:
>
> ind   y_rand          z_rand          yz
> A     1               0               -1.941248639
> A     1               0               0.747675528
> B     1               0               2.502358777
> B     1               0               2.752530485

 [snip]

> and then fitting the following model:
>
> yz.mm<-lmer(yz~-1+y_rand+z_
rand+(y_rand+z_rand-1|ind),data=ind.data)
>
> This gives seemingly correct results (i.e. consistent with results from
> MCMCglmm and ASReml) for the between-individual estimates. The issue that
> I'm running into is that since I'm treating y and z as the same variable,
I
> can't figure out how to get any sort of within-individual estimates beyond
a
> single variance estimate. This makes sense given the way I've formulated
the
> model.
>
> Is there any way to likewise cheat to get within-individual/group variance
> and covariance estimates with lme4? I can get what I need from MCMCglmm
but,
> for computational reasons I'd prefer lme4.
>
> Thanks for any help,
> Ned
>
> p.s. just realized that I can probably get what I want from lme...
>




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