computeVariancePartitioning: computeVariancePartitioning

View source: R/computeVariancePartitioning.R

computeVariancePartitioningR Documentation

computeVariancePartitioning

Description

Computes variance components with respect to given grouping of fixed effects and levels of random effects

Usage

computeVariancePartitioning(
  hM,
  group = NULL,
  groupnames = NULL,
  start = 1,
  na.ignore = FALSE
)

Arguments

hM

a fitted Hmsc model object

group

vector of numeric values corresponding to group identifiers in groupnames. If the model was defined with XData and XFormula, the default is to use model terms.

groupnames

vector of names for each group of fixed effect. Should match group. If the model was defined with XData and XFormula, the default is to use the labels of model terms.

start

index of first MCMC sample included

na.ignore

logical. If TRUE, covariates are ignored for sites where the focal species is NA when computing variance-covariance matrices for each species

Details

The vector group has one value for each column of the matrix hM$X, describing the index of the group in which this column is to be included. The names of the group are given by groupnames. The output object VP$vals gives the variance proportion for each group and species. The output object VP$R2T gives the variance among species explained by traits, measured for species' responses to covariates (VP$R2T$Beta) and species occurrences (VP$R2T$Y)

Value

returns an object VP with components VP$vals, VP$R2T, VP$group and VP$groupnames.

See Also

Use plotVariancePartitioning to display the result object.

Examples

# Partition the explained variance for a previously fitted model
# without grouping environmental covariates
VP = computeVariancePartitioning(TD$m)

# Partition the explained variance for a previously fitted model
# while grouping the two environmental variables together
VP = computeVariancePartitioning(TD$m, group=c(1,1), groupnames = c("Habitat"))


Hmsc documentation built on Aug. 11, 2022, 5:11 p.m.