View source: R/get.TMB.data.input.R
get.TMB.data.input | R Documentation |
Internal scampr function that creates a list of data and starting parameters for scampr models
get.TMB.data.input(
formula,
data,
bias.formula,
pa.data,
coord.names = c("x", "y"),
quad.weights.name = "quad.size",
approx.type = c("variational", "laplace", "not_sre"),
model.type = c("PO", "PA", "IDM"),
basis.functions,
bf.matrix.type = c("sparse", "dense"),
starting.pars,
latent.po.biasing = TRUE,
po.biasing.basis.functions,
prune.bfs = 4
)
formula |
an object of class "formula" (or one that can be coerced to that class): a symbolic description of the fixed effects of the model to be fitted. The 'response' must be a binary that indicates whether a datum is a presence or: quadrature point (for point process models)/ absence (for binary models). See GLM function for further formula details. |
data |
a data frame containing response and predictors within |
bias.formula |
an object of class "formula" (or one that can be coerced to that class) OR the character string "latent". In the formula case, this is a symbolic description of the predictors included to account for bias in the presence-only data (no response term is needed). In the case of fitting an integrated data model, |
pa.data |
an optional data frame. When fitting an integrated data model use this to pass in the presence/absence data. |
coord.names |
a vector of character strings describing the column names of the coordinates in both data frames. |
quad.weights.name |
a charater string of the column name of quadrature weights in the data. |
approx.type |
a character string indicating the type of model to be used. May be one of 'laplace' or 'variational' for models involving spatial random effects, OR 'not_sre' for a fixed effect model. |
model.type |
a character string indicating the type of data to be used. May be one of 'PO' (for a presence-only PPM) or 'PA' (for a presence/absence Binary GLM) or 'IDM' (for an integrated data model). |
basis.functions |
an optional object of class 'Basis' created by |
bf.matrix.type |
a character string, one of 'sparse' or 'dense' indicating whether to use sparse or dense matrix computations for the basis functions created. |
starting.pars |
an optional named list or scampr model object that gives warm starting values for the parameters of the model. |
latent.po.biasing |
a logical indicating whether biasing in the presence-only data should be accounted for via an additional latent field. Applies to IDM only. |
po.biasing.basis.functions |
an optional extra set of basis functions that can be used when |
prune.bfs |
an integer indicating the number of presence-only records required within a basis function's radius for it NOT to be pruned. Applies to the PO and IDM model (additionally, within the presence-only biasing basis functions in the IDM case) to assist with stability in model convergence. Default is zero, i.e. no pruning. |
list of elements required for TMB::MakeADFun
# Get the flora data for one of the species
dat_po <- flora$po$sp1
dat_pa <- flora$pa
# obtain a sample of 10,000 quadrature points for the point process model
set.seed(1)
quad.pts <- flora$quad[sample(1:nrow(flora$quad), 10000, replace = F), ]
set.seed(NULL)
# Attach the quadrature points to the presence-only data
dat_po <- rbind.data.frame(dat_po, quad.pts)
# Ensure the "response" variable in each data set shares the same name
dat_po$presence <- dat_po$pres
dat_pa$presence <- dat_pa$sp1
# Get the TMB data lists for a combined data model without latent field
tmb.input <- scampr:::get.TMB.data.input(presence ~ MNT, bias.formula ~ D.Main, po.data = dat_po, pa.data = dat_pa)
str(tmb.input)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.