Description Usage Arguments Value Details Author(s) Examples

View source: R/stackedsdm_s3.R

Predictions from a stackedsdm object

1 2 3 4 5 6 7 8 9 |

`object` |
An object of class |

`newdata` |
Pptionally, 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 '"newdata"'. The default is to predict |

`...` |
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>.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ```
X <- as.data.frame(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")
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.