data(Y, X, G)
# define abiotic part of the model
env.formula = "~ X_1 + X_2"
# Run the model with bottom-up control using stan_glm as fitting method and no penalisation
# (set iter = 1000 to obtain reliable results)
m = trophicSDM(Y, X, G, env.formula, iter = 100,
family = binomial(link = "logit"), penal = NULL,
mode = "prey", method = "stan_glm")
# In order to predict non-basal species, we need to also provide
# the predicted occurrences of its preys. Here we compute the probability of
# presence of species Y4 at environemntal conditions c(0.5,0.5)
# when its prey Y3 is present.
predict(m$model$Y4, newdata = data.frame(X_1 = 0.5, X_2 = 0.5, Y3 = 1), pred_samples = 10)
Run the code above in your browser using DataLab