Description Usage Arguments Value Examples
View source: R/cmpR2_Function.R
Compute R2 with a specified C matrix
1 |
c |
Contrast matrix for fixed effects |
x |
Fixed effects design matrix |
SigHat |
estimated model covariance (matrix or scalar) |
beta |
fixed effects estimates |
method |
the method for computing r2beta |
obsperclust |
number of observations per cluster (i.e. subject) |
nclusts |
number of clusters (i.e. subjects) |
A vector with the Wald statistic (ncp), approximate Wald F statistic (F), numerator degrees of freedom (v1), denominator degrees of freedom (v2), and the specified r squared value (Rsq)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | library(nlme)
library(lme4)
library(mgcv)
lmemod = lme(distance ~ age*Sex, random = ~1|Subject, data = Orthodont)
X = model.matrix(lmemod, data = Orthodont)
SigHat = extract.lme.cov(lmemod, data = Orthodont)
beta = fixef(lmemod)
p = length(beta)
obsperclust = as.numeric(table(lmemod$data[,'Subject']))
nclusts = length(obsperclust)
C = cbind(rep(0, p-1),diag(p-1))
partial.c = make.partial.C(p-1,p,2)
cmp_R2(c=C, x=X, SigHat=SigHat, beta=beta, obsperclust = obsperclust,
nclusts = nclusts, method = 'sgv')
cmp_R2(c=partial.c, x=X, SigHat=SigHat, beta=beta, obsperclust = obsperclust,
nclusts = nclusts, method = 'sgv')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.