JenniNiku / gllvm

Generalized Linear Latent Variable Models
https://jenniniku.github.io/gllvm/
48 stars 20 forks source link

Model-based constrained ordination with random-effects #43

Closed BertvanderVeen closed 3 years ago

BertvanderVeen commented 3 years ago

This update adds a new model that allows users to perform constrained ordination in the GLLVM framework.

It adds a range of new models such as reduced rank regression, quadratic reduced rank regression, partial reduced rank regression, reduced rank regression with residual ordination, partial constrained ordination, partial constrained and residual ordination, et cetera. In summary, it is possible to combine with all current features in the GLLVM package, including the newly implemented structured row-effects and distributions added with Extended Variational Approximations.

The models in the GLLVM r-package have now been re-parameterized to include a scale parameter, which was needed to include the new models. For identifiability reasons one species-specific parameter is fixed per latent variable, though the number of parameters remains the same.

Two new vignettes have been added, one demonstrating use of the quadratic response model, and the other demonstrating use of model-based constrained ordination. For further details I refer to that, and to the manuscript that is in preparation.

There is also a new print.summary() method, which nicely present predictor coefficients with standard errors, z-statistic and p-values with formatting similar to base R models such as glm(). This can also report intercepts and dispersion parameters, though it does not by default. It reports the number of reduced ranks, constrained and unconstrained LVs in the model (where the second is reduced rank + residual, the terminology might have to be adapted still), and the standard deviation for the random-effects (LVs), which can be used as a measure of gradient length or to evaluate if a random-effect is redundant.

The getLV functionality has been altered, so that it can return the latent variable scaled with their newly added standard deviations. For models with only unconstrained latent variables it (still) returns standard normal realizations (i.e. unscaled LVs).

CMSEPs have been implemented for Reduced Rank, constrained and unconstrained ordinations combined.

The ordiplot() adds arrows for constrained models, which are proportional to the magnitude of predictor slopes (i.e. the predictor with the largest effect always has the longest arrow). When unconstrained LVs are additionally included in the same model, no arrows are currently drawn due to difficulties with the rotation to principal direction. In the future, post-hoc the relation of unconstrained LVs to the predictors could be calculated and arrows could be drawn (not sure if this should be the default behavior at the moment).

There are a range of other small changes or implementations.