getPreds {fuzzySim} | R Documentation |
This function allows getting the predictions of multiple models when applied to a given dataset. It can be useful if you have a list of model objects (e.g. resulting from multGLM
) and want to apply them to a new data set containing the same variables for another region or time period. There are options to include the logit link (Y
) and/or Favourability
(see Fav
).
getPreds(data, models, id.col = NULL, Y = FALSE, P = TRUE, Favourability = TRUE, incl.input = FALSE)
data |
a data frame or RasterStack to which to apply the |
models |
an object of class 'list' containing one or more model objects, obtained e.g. with function |
id.col |
optionally, the index number of a column of 'data' containing row identifiers, to be included in the result. Ignored if |
Y |
logical, whether to include the logit link (y) value in the predictions. |
P |
logical, whether to include the probability value in the predictions. |
Favourability |
logical, whether to include Favourability in the predictions (see |
incl.input |
logical, whether to include input columns in the output data frame (if the 'data' input is a data frame as well). The default is FALSE. |
This function returns the model predictions in an object of the same class as the input 'data', i.e. either a data frame or a RasterStack.
A. Marcia Barbosa
data(rotif.env) names(rotif.env) # identify rotifer data in the Eastern and Western hemispheres: unique(rotif.env$CONTINENT) rotif.env$HEMISPHERE <- "Eastern" rotif.env$HEMISPHERE[rotif.env$CONTINENT %in% c("NORTHERN_AMERICA", "SOUTHERN_AMERICA")] <- "Western" head(rotif.env) # separate the rotifer data into hemispheres east.hem <- rotif.env[rotif.env$HEMISPHERE == "Eastern", ] west.hem <- rotif.env[rotif.env$HEMISPHERE == "Western", ] # make models for 3 of the species in rotif.env based on their distribution # in the Eastern hemisphere: mods <- multGLM(east.hem, sp.cols = 18:20, var.cols = 5:17, id.col = 1, step = FALSE, FDR = FALSE, trim = FALSE) # get the models' predictions for the Western hemisphere dataset: preds <- getPreds(west.hem, models = mods$models, P = TRUE, Favourability = TRUE) head(preds)