fit_plug_and_play: Fit presence-background distribution models in a...

View source: R/fit_plug_and_play.R

fit_plug_and_playR Documentation

Fit presence-background distribution models in a plug-and-play framework.

Description

This function fits presence-background species distribution models for the specified plug-and-play methods \insertCiteDrake2018-ha,Drake2015-sbS4DM.

Usage

fit_plug_and_play(
  presence = NULL,
  background = NULL,
  method = NULL,
  presence_method = NULL,
  background_method = NULL,
  bootstrap = "none",
  bootstrap_reps = 100,
  ...
)

Arguments

presence

dataframe of covariates at presence points

background

Optional. Dataframe of covariates at background points

method

Optional. If supplied, both presence and background density estimation will use this method.

presence_method

Optional. Method for estimation of presence density.

background_method

Optional. Method for estimation of background density.

bootstrap

Character. One of "none" (the default, no bootstrapping), "numbag" (presence function is bootstrapped), or "doublebag" (presence and background functions are bootstrapped).

bootstrap_reps

Integer. Number of bootstrap replicates to use (default is 100)

...

Additional parameters passed to internal functions.

Details

Current methods include: "gaussian", "kde","vine","rangebagging", "lobagoc", and "none".

Value

List of class "pnp_model" containing model objects and metadata needed for projecting the fitted models.

Note

Either method or both presence_method and background_method must be supplied.

References

\insertAllCited

Examples



# load in sample data

 library(S4DM)
 library(terra)

 # occurrence points
   data("sample_points")
   occurrences <- sample_points

 # environmental data
   env <- rast(system.file('ex/sample_env.tif', package="S4DM"))

 # rescale the environmental data

   env <- scale(env)

 # Get presence environmental data

  pres_env <- get_env_pres(coords = occurrences,
                           env = env)

# Get background environmental data

 bg_env <- get_env_bg(coords = occurrences,
                      env = env,width = 100000)


# Note that the functions to get the environmental data return lists,
# and only the "env" element of these is used in the fit function

  kde_fit <- fit_plug_and_play (presence = pres_env$env,
                                background = bg_env$env,
                                method = "kde")



bmaitner/pbsdm documentation built on Feb. 8, 2025, 2:27 p.m.