View source: R/stackedsdm_s3.R
predict.stackedsdm | R Documentation |
Predictions from a stackedsdm object
## S3 method for class 'stackedsdm' predict( object, newdata = NULL, type = "link", se.fit = FALSE, na.action = na.pass, ... )
object |
An object of class |
newdata |
Optionally, a data frame in which to look for variables with which to predict. If omitted, the covariates from the existing dataset are used. |
type |
The type of prediction required. This can be supplied as either a single character string, when is applied to all species, or a vector of character strings of the same length as |
se.fit |
Logical switch indicating if standard errors are required. |
na.action |
Function determining what should be done with missing values in |
... |
not used |
A list where the k-th element is the result of applying the predict
method to the k-th fitted model in object$fits
.
This function simply applies a for loop, cycling through each fitted model from the stackedsdm
object and then attempting to construct the relevant predictions by applying the relevant predict
method. Please keep in mind no formatting is done to the predictions.
Francis K.C. Hui <francis.hui@anu.edu.au>.
X <- spider$x abund <- spider$abund # Example 1: Simple example myfamily <- "negative.binomial" # Fit models including all covariates are linear terms, but exclude for bare sand fit0 <- stackedsdm(abund, formula_X = ~. -bare.sand, data = X, family = myfamily, ncores=2) predict(fit0, type = "response") # Example 2: Funkier example where Species are assumed to have different distributions abund[,1:3] <- (abund[,1:3]>0)*1 # First three columns for presence absence myfamily <- c(rep(c("binomial"), 3), rep(c("negative.binomial"), 5), rep(c("tweedie"), 4) ) fit0 <- stackedsdm(abund, formula_X = ~ bare.sand, data = X, family = myfamily, ncores=2) predict(fit0, type = "response")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.