computeVariancePartitioning function

computeVariancePartitioning

computeVariancePartitioning

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

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

Returns

returns an object VP with components VPvals,VPvals, VPR2T, VPgroupandVPgroup and VPgroupnames.

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)

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

See Also

Use plotVariancePartitioning to display the result object.

  • Maintainer: Otso Ovaskainen
  • License: GPL-3 | file LICENSE
  • Last published: 2022-08-11