funspaceGAM {funspace}R Documentation

Functional space GAM

Description

Mapping response variables in a functional space

Usage

funspaceGAM(y, funspace, family = "gaussian", minObs = 30)

Arguments

y

vector including the variable to be mapped inside the functional space. There must be a correspondence between the elements of y and the observations used to make the PCA (contained in 'pca.object'), both in the number of elements and in their order.

funspace

An object of class funspace providing the functional space to be considered. See function funspace

family

A family object specifying the distribution and link to use in the gam model. Defaults to "gaussian". See package mgcv for more details.

minObs

minimum number of observations needed in a group to make a model (defaults to 30).

Details

Different response variables can be mapped onto a functional space. In funspace, we follow the approach by Carmona et al. (2021), in which a generalized additive model is estimated across the bidimensional functional space. The resulting models show the predicted values of the response variable at each position of the portion of the functional space that is defined in the TPD of the global set of observations or of individual groups.

Value

The function returns an object of class funspace containing the functional space, trait probability distributions, and the fitted gam models. The funspace class has specific methods exists for the generic functions plot and summary.

References

CP Carmona, et al. (2021). Erosion of global functional diversity across the tree of life. Science Advances eabf2675

Examples


# 1. GAM on a space based on a PCA
x <- princomp(GSPFF)
funtest <- funspace(x = x, PCs = c(1, 2), threshold = 0.95)
y <- abs(x$scores[, 1] * x$scores[, 2]) + rnorm(nrow(GSPFF), mean = 0, sd = 1)
funtestGAM <- funspaceGAM(y = y, funspace = funtest)
plot(funtestGAM, quant.plot = TRUE, quant.col = "grey90")
summary(funtestGAM)



[Package funspace version 0.2.2 Index]