Learn R Programming

variancePartition (version 1.2.5)

calcVarPart: Compute variance statistics

Description

Compute fraction of variation attributable to each variable in regression model. Also interpretable as the intra-class correlation after correcting for all other variables in the model.

Usage

calcVarPart(fit, adjust = NULL, adjustAll = FALSE, showWarnings = TRUE, ...)
"calcVarPart"(fit, adjust = NULL, adjustAll = FALSE, showWarnings = TRUE, ...)
"calcVarPart"(fit, adjust = NULL, adjustAll = FALSE, showWarnings = TRUE, ...)

Arguments

fit
model fit from lm() or lmer()
adjust
remove variation from specified variables from the denominator. This computes the adjusted ICC with respect to the specified variables
adjustAll
adjust for all variables. This computes the adjusted ICC with respect to all variables
showWarnings
show warnings about model fit (default TRUE)
...
additional arguments (not currently used)

Value

fraction of variance explained / ICC for each variable in the model

Examples

Run this code
library(lme4)
data(varPartData)

# Linear mixed model
fit <- lmer( geneExpr[1,] ~ (1|Tissue) + Age, info)
calcVarPart( fit )

# Linear model
# Note that the two models produce slightly different results
# This is expected: they are different statistical estimates 
# of the same underlying value
fit <- lm( geneExpr[1,] ~ Tissue + Age, info)
calcVarPart( fit )

Run the code above in your browser using DataLab