View source: R/predict.scampr.R
predict.scampr | R Documentation |
Functions the same as predict.glm with additional functionality. Can select whether predictions come from the realised latent field (dens = "posterior") or unrealised (dens = "prior") - depending on whether a user wants to make data specific predictions or be more broad. Particular to combined data models the user can specify whether to return the rate at which presence records occur (use.formula = "presence-only") or the underlying abundance rate (use.formula = "presence-absence").
## S3 method for class 'scampr'
predict(
object,
...,
newdata,
type = c("link", "response"),
dens = c("posterior", "prior"),
include.bias.accounting = FALSE
)
object |
a scampr model object |
... |
NA |
newdata |
a data frame of point locations to predict over as well as predictors involved in the model |
type |
a character string , one of 'link' or 'response', indicating the type of prediction to be returned. Either log-intensity or intensity respectively. |
dens |
a character string, one of 'posterior' or 'prior', indicating the probability density of the random effects to take the expectation from. |
include.bias.accounting |
a logical indicating if biasing effects (random or fixed) should be included in the predictions. Default is FALSE. |
a numeric vector of length newdata (or length of fitted data) containing the predictions.
# Get the flora data for one of the species
dat_po <- flora$po$sp1
# 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)
# Point Process Model
m <- scampr(pres ~ MNT + D.Main, dat_po, include.sre = F)
# Set up some prediction points
newdat <- flora$quad[sample(1:nrow(flora$quad), 100, replace = F), ]
# Make predictions
preds <- predict(m, newdat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.