[R-sig-ME] Calculate % Variance Attributed to Random Slopes (Phenotypic Plasticity)
Paul Johnson
paul.johnson at glasgow.ac.uk
Wed Apr 23 12:21:03 CEST 2014
Hi Jacob
I’m not sure I’ve understood your question, particularly when you ask how to get the variance in the predictor variable.
>> model<-lmer(X~Y*Year+(Y|Individual)
>>
>> but I do not know how to extract the proportion of variance explained by
>> the individual slope term.
As I understand variance partitioning, we are partitioning the variance of the responses, here labelled X (I think Jake understandably mixed up X and Y in his reponse - to avoid confusion I’m going to use “response” and “predictor”, and ignore the other predictor, Year). The total variance in the responses explained by the random effects (in both the slope and intercept) is given by the numerator of the VPC equation on Jake’s slide 28 (Calculating the Total Variance). As Jake says this is dependent on the predictor, so some rows will have a higher random effects variance than others. I wouldn’t agree that it’s meaningless though - if summed across all rows it can be interpreted as the component of variance that is due to inter-individual variation, as separate from the variance due to the fixed effects and the residual variance within individuals. This total random effects variance can be calculated easily with lme4 output. It doesn’t depend on the predictor in the sense that it is summed across all values of the predictor:
sum(diag(Z %*% D %*% t(Z)))
Z is the design matrix of the random effects and D is the random effects covariance matrix from VarCorr(model)$Individual (Laird & Ware, 1982, Biometrics, http://www.jstor.org/stable/2529876). The columns of Z and the rows and columns of Sigma have to match. This is equivalent to summing across the ij in the numerator of the VPC equation mentioned above. The mean variance is mean(diag(Z %*% Sigma %*% t(Z))). This random effects variance could be used in variance components stats e.g. R^2, ICC, etc, although I accept that it would have to be interpreted with caution and in some scenarios might not be meaningful.
This formula doesn’t give you what you asked for though, the proportion of variance explained by the individual slope term, it gives the variance component attributable to *all* random effects at the individual level, which here are the random intercept and random slope. I don’t know how you would isolate the variance due to the random slope alone, and I’m not sure that it's a meaningful quantity for the reasons that Jake gives, i.e. the dependence of the total random effects variance on the value of the predictor. E.g. in a simple one-predictor random slopes model Z will have a column of 1s for the intercept and column containing the values of the predictor. You could fix the predictor in the above formula to any value and calculate the mean random effects variance conditioned on that value, i.e. removing variation in the predictor, but the resulting variance will depend on the choice of predictor value, and there’s no guarantee that it will be less than the marginal variance (i.e. averaged across all values of the predictor).
>> If I run the printout:
>>
>> summary(model)
>>
>> I can get the variance in slope with respect to Y, but this is not the
>> variance in Y itself, but rather how X is influenced by Y.
>>
>> Any ideas on how to get the variance in Y itself?
I don’t understand this part of your question. How does the variance of the predictor come into this? The total (or mean) random effects variance above depends on the predictor so will also depend on the variance of the predictor, but it’s the variance in the responses that we’re trying to explain (or have I misunderstood the question?).
There might be better ways to quantify the random slopes contribution… E.g. take a phenotypic trait that shows high inter-individual variation in different environments (predictor values), and where the same individuals tend to have high trait values in both environments. In this scenario you would expect a high intercept variance and a low slope variance (and presumably also a low covariance). These variances and covariances can be transformed into useful descriptive stats like environment-specific repeatabilities (ICCs) and a cross environment correlation coefficient (which in this example would be high). A cross-environment correlation coefficient close to 1 would indicate that the random slopes contribution is very small - this sound like it gets close to what you were asking for. How to do this, with R code, is described here:
Brommer, J.E. (2013). Variation in plasticity of personality traits implies that the ranking of personality measures changes between environmental contexts: calculating the cross-environmental correlation. Behavioral Ecology and Sociobiology, 67, 1709–1718.
Incidentally the methodology in this paper is quite similar to the random effects variance component formula above.
Good luck,
Paul
On 23 Apr 2014, at 00:48, Jake Westfall <jake987722 at hotmail.com> wrote:
> Jacob,
>
> Unfortunately the meaning of percent variance attributed to random terms (or to different "levels" if you're into that) is conceptually pretty unclear when there are random slopes. In general the variance of Y differs at different values of X. Consequently, estimates of percent variance explained are different for different values of X, and so they are not particularly useful or informative statistics in themselves. You may want to check out the following resources:
>
> Sections 1 and 2 of Goldstein, Browne, & Rasbash, 2002:
> http://www.bristol.ac.uk/cmm/research/pvmm.pdf
>
> Slides 28, 29, and 30 from the following powerpoint presentation:
> http://www.bristol.ac.uk/cmm/software/support/workshops/materials/random-slopes.pdf
>
> Jake
>
>> Date: Tue, 22 Apr 2014 16:34:41 -0400
>> From: segerfan83 at gmail.com
>> To: r-sig-mixed-models at r-project.org
>> Subject: [R-sig-ME] Calculate % Variance Attributed to Random Slopes (Phenotypic Plasticity)
>>
>> Hi all,
>>
>> I am trying to figure out how to calculate how strong individual plasticity
>> is in my model:
>>
>> model<-lmer(X~Y*Year+(Y|Individual)
>>
>> but I do not know how to extract the proportion of variance explained by
>> the individual slope term. If I run the printout:
>>
>> summary(model)
>>
>> I can get the variance in slope with respect to Y, but this is not the
>> variance in Y itself, but rather how X is influenced by Y.
>>
>> Any ideas on how to get the variance in Y itself?
>>
>> Thank you,
>> Jacob
>>
>> [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-mixed-models at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
More information about the R-sig-mixed-models
mailing list