computeSAIR: computeSAIR

View source: R/computeSAIR.R

computeSAIRR Documentation

computeSAIR

Description

Computes the shared and idiosyncratic responses to measured and latent predictors

Usage

computeSAIR(hM, X = NULL)

Arguments

hM

a fitted Hmsc model object

X

a design matrix to be used in the computations (as defaul hM$X)

Details

The shared and idiosyncratic responses are computed only for models without traits.

Value

returns the posterior distribution of the parameters mu.X2,V.XX,mu.Omega2,V.OmegaOmega,mu.tot,V.tot,s described Ovaskainen and Abrego (manuscript): Measuring niche overlap with joint species distribution models: shared and idiosyncratic responses of the species to measured and latent predictors

Examples

# Simulate a small dataset, fit Hmsc model to it, compute SAIR, and show posterior means 

nc = 2
ns = 5
ny = 10
mu = rnorm(n = nc)
X = matrix(rnorm(n=nc*ny),nrow=ny)
X[,1] = 1
eps = matrix(rnorm(nc*ns),nrow=nc)
L = matrix(rep(X%*%mu,ns),nrow=ny)  + X%*%eps
Y = pnorm(L)
m = Hmsc(Y = Y, XData = data.frame(env = X[,2]), distr = "probit")
m = sampleMcmc(m,samples=100,transient=50,verbose = 0)
SI = computeSAIR(m)
colMeans(SI)


hmsc-r/HMSC documentation built on March 5, 2025, 10:52 p.m.