jsdm_statsummary | R Documentation |
jsdmStanFit
modelThis function extracts the predicted Y values for within the models and then calculates summary statistics for each simulated community. The default is to sum all the predicted scores for each site.
jsdm_statsummary(
object,
species = NULL,
sites = NULL,
summary_stat = "sum",
post_type = "linpred",
calc_over = "site",
simplify = TRUE,
draw_ids = NULL,
ndraws = NULL,
...
)
object |
A |
species |
Which species to include in the summary statistic, by default all |
sites |
Which sites to include in the summary statistic, by default all |
summary_stat |
The summary statistic to be used, by default |
post_type |
The type of posterior prediction to be used, either
|
calc_over |
Whether to calculate the summary statistic by site or species, by
default |
simplify |
Whether to simplify the output into a matrix, by default
|
draw_ids |
The IDs of the draws to be used, as a numeric vector |
ndraws |
Number of draws, by default the number of samples in the posterior. Will be sampled randomly from the chains if fewer than the number of samples. |
... |
Arguments passed to the posterior prediction function |
If simplify = TRUE
then a matrix where each row is a draw and each
column is either a site (if calc_over = "site"
) or a species (if
calc_over = "species"
).
pp_check.jsdmStanFit
## Not run:
# First simulate data and fit the jsdmStan model:
gllvm_data <- gllvm_sim_data(
N = 100, S = 9, D = 2,
family = "bernoulli"
)
gllvm_fit <- stan_gllvm(dat_list = gllvm_data, family = "bernoulli")
# The default is to return a matrix:
jsdm_statsummary(gllvm_fit)
# The above returns the linear predictor, while we may want to get the posterior
# prediction instead:
jsdm_statsummary(gllvm_fit, post_type = "predict")
# This can be limited to a specific set of species and/or sites:
jsdm_statsummary(gllvm_fit, species = 1:5, sites = seq(5, 95, 10))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.