Open smithja16 opened 1 year ago
Thanks James.
As far as I know there are no plans to support this, but it is straightforward to implement yourself. Ovaskainen and Abrego (2020) is quite clear on the concept of a conditional prediction, and implementing the ideas behind eq. 7.14-7.15 in gllvm is not difficult.
Note that eq. 7.15 includes an inverse of a part of the correlation matrix that is modelled in reduced rank using the latent variables. So, AFAIK, it is only possible to calculate this conditional prediction if the number of LVs is equal to or larger than the number of species for which the linear predictor is "known". It is of course possible to plug in a generalized inverse, but..
Example:
library(gllvm)
data(spider)
Y <- spider$abund
known <- c(1,2,3)
unknown <- (1:ncol(Y))[-known]
model <- gllvm(Y, num.lv = length(known), family = "poisson")
covs <- getResidualCov(model)$cov
cond.pred <- covs[unknown,known]%*%solve(covs[known,known])%*%model$params$theta[known,,drop=F]%*%diag(model$params$sigma.lv)%*%t(getLV(model))
cond.covs <- covs[unknown,unknown] - covs[unknown,known]%*%solve(covs[known,known])%*%covs[known,unknown]
Amazing - thank you. I'll test whether this is suitable for me, given that I have ~100 species with ~50 known - not sure if 50 LVs makes sense.
If you are really interested in doing a conditional prediction you might want to drop one of the HMSC devs an e-mail to check if there is a way around that constraint.
I was wondering if capability for conditional joint predictions are planned for gllvm, i.e. using observations from some species to predict abundance of other unobserved species? I also use Hmsc, and its conditional prediction and conditional joint prediction is a very useful feature.