This short document showcases how to use the gllvm package to analyse multivariate percent cover data. Namely, we show how to apply the hurdle beta GLLVM (with logistic link), as detailed in Korhonen et al. (2024), to analyse the kelp forest dataset from the Santa Barbara Coastal Long-Term Ecological Research project, available from https://doi.org/10.6073/pasta/0af1a5b0d9dde5b4e5915c0012ccf99c.

A multivariate percent cover dataset often comes in the form of a n×mn \times m matrix $\bf{Y}$, with nn being the number of observational units/sites, and mm being the number of species of plants, macroalgae, sessile invertebrates, et cetera. The response yijy_{ij} is then the recorded percentage of the relative area covered by species jj on unit/site ii. Typically such datasets contain considerable proportion of zero observations, as a given obs. unit is often populated by only a small subset of the mm species in total. More rarely, it might even be the case that one of the species covers some obs. unit completely.

Hurdle beta GLLVM

Traditionally, beta regression has been used to model responses that take the form of percentages. If yij*y^*_{ij} is in the (open) interval (0,1)(0,1), and is distributed according to beta distribution, yij*Beta(μij,ϕj)y^*_{ij} \sim \text{Beta}(\mu_{ij}, \phi_j), then it has the following density: fbeta(yij*;μij,ϕj)=Γ(ϕj)Γ(μijϕj)Γ(ϕjϕjμij)(yij*)μijϕj1(1yij*)ϕj(1μij1). f_{\text{beta}}(y_{ij}^*; \mu_{ij}, \phi_j) = \frac{\Gamma(\phi_j)}{\Gamma(\mu_{ij}\phi_j)\Gamma(\phi_j-\phi_j\mu_{ij})} (y_{ij}^*)^{\mu_{ij}\phi_j-1}(1-y_{ij}^*)^{\phi_j(1-\mu_{ij}-1)}.

The mean parameter μij\mu_{ij} can be connected to a set of covariates and latent variables through some link function, by the equation $g(\mu_{ij})=\eta_{ij} = \beta_{0j} + \boldsymbol{\beta}_j^\top\bf{x_i} + \boldsymbol{\lambda}_j^\top\bf{u_i}$.

However, such a model is ill-suited for most percent cover datasets, due to the fact that the beta distribution isn’t capable of handling zero (or 100%100\%) responses. To make use of the beta regression model in such scenario, one needs to use some transformation in order to ‘push’ the responses away from the boundaries. This procedure might provide reasonable results when the numbers of zeros or ones in the data are relatively low. On the other hand, by transforming the zeros and ones, we might lose some important information.

A more sophisticated way of tackling such issue is by considering a zero-accommodating model, couple of which have been proposed recently. One such model is the hurdle beta model, which models the two (can be extended to three if 100%100\% covers are recorded, see Korhonen et al. (2024)) classes the response yijy_{ij} can take, i.e., {0}\{0\} and (0,1)(0,1), by separate processes. Namely, the zeros are assumed to be generated by a Bernoulli process. Conditional on yij(0,1)y_{ij}\in(0,1), the response is modeled using the standard beta distribution as presented above. The likelihood function for a response YijY_{ij} following the hurdle beta distribution is of the form: P(Yij;μij,μij0,ϕj)={1μij0,Yij=0,μij0fbeta(Yij;μij,ϕj),Yij(0,1). P(Y_{ij};\mu_{ij}, \mu_{ij}^0, \phi_j) = \begin{cases} 1-\mu_{ij}^0, & Y_{ij} = 0,\\ \mu_{ij}^0 \cdot f_{\text{beta}}(Y_{ij};\mu_{ij},\phi_j), & Y_{ij} \in (0,1). \\ \end{cases} where $g(\mu_{ij}^0) = \eta_{ij}^0 = \beta_{0j}^0 + \bf{x_i}^\top\boldsymbol{\beta}_j^0 + \bf{u_i}^\top\boldsymbol{\lambda}_j^0$ for and $g(\mu_{ij}) = \eta_{ij} = \beta_{0j} + \bf{x_i}^\top\boldsymbol{\beta}_j + \bf{u_i}^\top\boldsymbol{\lambda}_j$ and g()g(\cdot) can be either probit or logistic link function. Note, that here, the separate linear predictors share the same environmental covariates $\bf{x}_i$ and latent variable scores $\bf{u}_i$, while the coefficients and loadings are allowed to differ.

The gllvm package implements the hurdle beta GLLVM with two different estimation methods available. First, accessed by the argument method="VA" when calling uses a hybrid approach, where the method of variational approximations, or VA, is applied to the Bernoulli-process part of the data (only probit link allowed), while the method of extended variational approximations, see Korhonen et al. (2023), is applied to the beta distributed part. By instead specifying method="EVA", the EVA method is applied to both parts of the likelihood.

Example

In the following, we show how to fit the logistic hurdle beta GLLVM using EVA on the SBC LTER marine macroalgae (i.e., seaweed) percent cover dataset. The data has been collected in 2000-2020 along 44 permanent transect lines along coastal southern California. We will specify a model with two latent variables (for ordination) and will include the rockiness of the seabed and the average number of stripes of giant kelp as environmental covariates in the model.

## Loading required package: TMB
## 
## Attaching package: 'gllvm'
## The following object is masked from 'package:stats':
## 
##     simulate
data("kelpforest")
Yabund <- kelpforest$Y
Xenv <- kelpforest$X
SPinfo <- kelpforest$SPinfo

# Data contains both algae and sessile invertebrates
table(SPinfo$GROUP)
## 
##  ALGAE INVERT  PLANT 
##     61     69      2
# Select only the macroalgae:
Yalg <- Yabund[,SPinfo$GROUP=="ALGAE"]

# Remove empty rows and rows with missing values from the data
rem0 <- which((rowSums(Yalg)==0) | is.na(rowSums(Yalg)))
Yalg <- Yalg[-rem0,]
Xenv <- Xenv[-rem0,]

# Use only the data from the year 2016:

Yalg <- Yalg[Xenv$YEAR==2016,]
Xenv <- Xenv[Xenv$YEAR==2016,]

# Remove species which have no observations
Yalg <- Yalg[,-which(colSums(Yalg>0)==0)]
# Number of obs. and species:
dim(Yalg)
## [1] 44 53
# Specify the covariates in the linear predictor
Xformulai = ~KELP_FRONDS + PERCENT_ROCKY

After setting up the data, LV design and the covariates, the model is estimated by

fit <- gllvm(Yalg, X=Xenv, formula = Xformulai, family = "betaH", method="EVA", 
             num.lv = 2, link="logit", control=list(reltol=1e-12))

To inspect e.g., the covariate effects, use

fit$params$Xcoef
##            KELP_FRONDS PERCENT_ROCKY
## AMZO     -7.559186e-04 -0.0373175029
## AU       -1.171584e-02 -0.0144005483
## BF       -7.152126e+00  0.2910471383
## BLD      -3.204658e-03 -0.0476120686
## BO        2.921004e-01 -0.0518882807
## BR       -7.344966e-02  0.0170783843
## BRA       5.055051e-01 -0.0834416672
## CAL       1.084007e-02  0.0987800253
## CC        1.025623e-02  0.0073087358
## CF        3.707650e-01 -0.0541218208
## CG       -5.926928e-01  0.0200915429
## CO       -1.616248e-01 -0.0018804530
## COF      -1.945997e+00  0.1076413311
## CP       -5.341896e-01 -0.0525919654
## CRYP     -2.611052e-01  0.2110012892
## CYOS     -4.161144e-02 -0.0008006455
## CZ        4.628213e-04  0.0085906513
## DL        7.894424e-02  0.0212654434
## DMH       4.544533e-01 -0.0691309306
## DP       -3.263565e-01  0.0274147869
## DU        7.196500e-01 -0.0447905585
## EAH       1.519401e+00 -0.0156289883
## EC        5.883289e-02 -0.0042398629
## EH        4.749486e-01 -0.0975087044
## ER        3.295087e-01  0.0531826773
## FASP     -1.215428e-03 -0.0391408967
## FB       -4.407266e+00  0.1916424807
## FTHR      7.616866e-01 -0.1097986807
## GR       -7.260712e-01  0.1102382440
## GS       -3.964070e-01  0.0111632915
## GYSP      2.413003e-01  0.0143571013
## IR        1.441621e-04  0.0053780677
## LH       -3.276121e-03 -0.0450325932
## LI       -2.157823e-04 -0.1942040396
## LS       -4.760342e-03 -0.0669292377
## LX       -9.268553e-03 -0.1243831800
## MH        1.951122e-01 -0.0469759419
## NIE      -3.443298e-01  0.0464217012
## PH        3.919663e+00 -0.4895614905
## PHSE     -4.274897e-01  0.0069147629
## PL        1.301021e-01 -0.0120383487
## POLA      3.667980e-03 -0.0402016866
## PRSP      7.412486e-02  0.0179344497
## R        -1.332818e-01 -0.0179944287
## RAT      -1.488806e-01 -0.0007753643
## SAFU     -2.529752e+00 -0.0106505288
## SAHO      1.442079e+01 -0.0401619983
## SAMU      6.549716e-02 -0.0414008525
## SCCA      1.490898e-01  0.1616272016
## STIN     -1.475045e-04 -0.1327540257
## TALE     -1.129042e+00  0.2133050826
## UEC      -8.695526e-06 -0.0043477629
## UV        2.003956e+00 -0.0479209989
## H01_AMZO -4.841612e+00  0.1788281281
## H01_AU    5.541914e-01 -0.0499089497
## H01_BF    9.302235e-01 -0.1831368106
## H01_BLD  -3.166692e+00  0.0044685104
## H01_BO   -8.521816e-01  0.0597387768
## H01_BR   -4.130075e+00  0.2062679137
## H01_BRA   1.467430e+00 -0.1214364228
## H01_CAL   1.098740e-01  0.1016509682
## H01_CC   -9.434492e-01  0.0476976557
## H01_CF   -8.951098e-01  0.0555029715
## H01_CG    2.782149e+00 -0.0360817065
## H01_CO    1.089165e-02 -0.0070612956
## H01_COF   8.422893e-01  0.1341693069
## H01_CP    1.234360e-01  0.1637403771
## H01_CRYP  2.431979e-01 -0.0520857664
## H01_CYOS  1.385716e-01 -0.0426825965
## H01_CZ    1.940466e+00  0.0116455418
## H01_DL    1.940083e+00 -0.1921942650
## H01_DMH   8.445488e-01 -0.1031294144
## H01_DP   -1.148621e+00  0.0846122857
## H01_DU    1.648629e-01  0.1139389772
## H01_EAH  -1.101818e+01  0.1624284935
## H01_EC   -4.705728e-01  0.0752961970
## H01_EH    6.594496e-01 -0.0852358489
## H01_ER   -9.091324e-02  0.0489652646
## H01_FASP -3.594163e+00  0.2610957250
## H01_FB    3.312038e-01 -0.1065414193
## H01_FTHR -4.004102e-01 -0.0294651876
## H01_GR    1.734091e-01  0.1893856202
## H01_GS    6.162066e-01 -0.1798357145
## H01_GYSP -1.709483e-01  0.0603420945
## H01_IR    1.031488e+00  0.0744924805
## H01_LH   -2.832070e-02  0.1480468392
## H01_LI   -9.133589e+00  0.1530503448
## H01_LS    1.407361e+00 -0.0180365105
## H01_LX   -2.052777e+00  0.0602210236
## H01_MH    1.298937e+00 -0.0143851169
## H01_NIE   2.156391e+00 -0.1614652703
## H01_PH   -6.586931e-01  0.0278619343
## H01_PHSE  4.155348e-01 -0.1406834417
## H01_PL    1.172594e-01 -0.0136841328
## H01_POLA  5.610652e-01 -0.0527295403
## H01_PRSP  5.774080e-01 -0.0424166671
## H01_R    -3.099174e+00  0.1850947593
## H01_RAT  -8.390719e-03  0.0203986826
## H01_SAFU -8.869626e-01 -0.2241742926
## H01_SAHO -5.815047e+00  0.1592870866
## H01_SAMU  5.432835e-02 -0.0014264794
## H01_SCCA -3.423721e+00  0.2266017485
## H01_STIN -8.767218e+00  0.1366966215
## H01_TALE -4.500551e-01  0.2346714056
## H01_UEC  -8.019724e-01  0.0908981956
## H01_UV   -1.021429e+00 -0.1290730236

In the above, the prefix indicates that the coefficient relates to the Bernoulli part of the hurdle model.

Ordination plot can then be generated as per usual:

ordiplot(fit, jitter = TRUE, s.cex = .8)

References

Korhonen, P., F.K.C. Hui, J. Niku, and S. Taskinen. 2023. “Fast and Universal Estimation of Latent Variable Models Using Extended Variational Approximations.” 33: 26. https://doi.org/10.1007/s11222-022-10189-w.
Korhonen, P., F.K.C. Hui, J. Niku, S. Taskinen, and B. van der Veen. 2024. “A Comparison of Joint Species Distribution Models for Percent Cover Data.” https://doi.org/10.48550/arXiv.2403.11562.