cmp_R2 {r2glmm}R Documentation

Compute R2 with a specified C matrix

Description

Compute R2 with a specified C matrix

Usage

cmp_R2(c, x, SigHat, beta, method, obsperclust = NULL, nclusts = NULL)

Arguments

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)

Value

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)

Examples

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')

[Package r2glmm version 0.1.2 Index]