predictPairwise.gllvm: Predict co-occurrence from a gllvm object

View source: R/predictSR.gllvm.R

predictPairwise.gllvmR Documentation

Predict co-occurrence from a gllvm object

Description

Obtains the probability of co-occurrnece for species from a fitted generalized linear latent variable model object.

Usage

## S3 method for class 'gllvm'
predictPairwise(
  object,
  spp = NULL,
  se.fit = FALSE,
  alpha = 0.95,
  seed = 42,
  ...
)

Arguments

object

an object of class 'gllvm'.

spp

a vector of length 2, defaults to NULL. If NULL, returns the probability of co-occurrence for all species in the data.

se.fit

logical, defaults to FALSE. If set to TRUE, returns a simulated confidence interval of the prediction.

alpha

numeric between 0 and 1, defaults to 0.95. Confidence level of the prediction.

seed

numeric, defaults to 42. Seed for the simulation of the confidence interval.

...

arguments passed to "predict.gllvm".

Details

The probability of co-occurrence is simply given by the joint probability of getting two presences for any pair of species. As such, it is simply calculated as the product of the probability of occurrence for any pair of species, so that this function mostly serves as convenience wrapper around "predict.gllvm".

Value

A matrix of size np(p-1)/2 by 2.

Author(s)

Bert van der Veen

See Also

predict.gllvm, predictSR.gllvm

Examples



# Load a dataset from the mvabund package
data(spider, package = "mvabund")
y <- as.matrix(spider$abund)
X <- scale(spider$x)
# Fit gllvm model
fit <- gllvm(y = y, X, formula = ~soil.dry, family = poisson())
# fitted values
newX = data.frame(soil.dry = seq(min(X[,"soil.dry"]),max(X[,"soil.dry"]),length.out=100))
predPair <- predictPairwise(fit, spp = c(1,2), newX = newX, level = 0)
plot(x = newX$soil.dry, y = predPair$prob, type = "l", xlab = "Soil dry moisture content", 
    ylab = "Probability of co-occurrence", ylim = c(0,1))




gllvm documentation built on May 10, 2026, 5:06 p.m.