getVarianceComponents {variancePartition} | R Documentation

## Extract variance terms

### Description

Extract variance terms from a model fit with lm() or lmer()

### Usage

    getVarianceComponents(fit)

### Arguments

`fit` | list of lmer() model fits

### Value

variance explained by each variable

### Examples

    # library(variancePartition)

    # optional step to run analysis in parallel on multicore machines
    # Here, we used 4 threads
    library(doParallel)
    cl <- makeCluster(4)
    registerDoParallel(cl)
    # or by using the doSNOW package

    # load simulated data:
    # geneExpr: matrix of gene expression values
    # info: information/metadata about each sample
    data(varPartData)

    # Specify variables to consider
    # Age is continuous so we model it as a fixed effect
    # Individual and Tissue are both categorical, so we model them as random effects
    form <- ~ Age + (1|Individual) + (1|Tissue)

    # Fit model and extract variance in two separate steps
    # Step 1: fit model for each gene, store model fit for each gene in a list
    modelList <- fitVarPartModel( geneExpr, form, info )

    fit <- modelList[[1]]
    getVarianceComponents( fit )

    # stop cluster
    stopCluster(cl)

[Package variancePartition version 1.8.1 Index]