| Title: | Create Maps Forecasting Risk of Pest Occurrence |
| Version: | 0.1.2 |
| Description: | There are three different modules: (1) model fitting and selection using a set of the most commonly used equations describing developmental responses to temperature helped by already existing R packages ('rTPC') and nonlinear regression model functions from 'nls.multstart' (Padfield et al. 2021, <doi:10.1111/2041-210X.13585>), with visualization of model predictions to guide ecological criteria for model selection; (2) calculation of suitability thermal limits, which consist on a temperature interval delimiting the optimal performance zone or suitability; and (3) climatic data extraction and visualization inspired on previous research (Taylor et al. 2019, <doi:10.1111/1365-2664.13455>), with either exportable rasters, static map images or html, interactive maps. |
| License: | GPL (≥ 3) |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.3 |
| URL: | https://github.com/EcologyR/mappestRisk, https://ecologyr.github.io/mappestRisk/ |
| BugReports: | https://github.com/EcologyR/mappestRisk/issues |
| Depends: | R (≥ 4.3.0) |
| LazyData: | true |
| Suggests: | covr, leaflet, testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| Imports: | dplyr, geodata, ggplot2, khroma, nls.multstart, progress, purrr, rTPC, terra, tidyr |
| Config/Needs/website: | rmarkdown |
| NeedsCompilation: | no |
| Packaged: | 2025-11-14 12:44:16 UTC; dario |
| Author: | Darío San-Segundo Molina
|
| Maintainer: | Darío San-Segundo Molina <dario.ssm2@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2025-11-19 18:20:02 UTC |
mappestRisk: Create Maps Forecasting Risk of Pest Occurrence
Description
There are three different modules: (1) model fitting and selection using a set of the most commonly used equations describing developmental responses to temperature helped by already existing R packages ('rTPC') and nonlinear regression model functions from 'nls.multstart' (Padfield et al. 2021, doi:10.1111/2041-210X.13585), with visualization of model predictions to guide ecological criteria for model selection; (2) calculation of suitability thermal limits, which consist on a temperature interval delimiting the optimal performance zone or suitability; and (3) climatic data extraction and visualization inspired on previous research (Taylor et al. 2019, doi:10.1111/1365-2664.13455), with either exportable rasters, static map images or html, interactive maps.
Author(s)
Maintainer: Darío San-Segundo Molina dario.ssm2@gmail.com (ORCID) [copyright holder]
Authors:
A. Márcia Barbosa (ORCID) [copyright holder]
Antonio Jesús Pérez-Luque ajpelu@gmail.com (ORCID) [copyright holder]
Francisco Rodríguez-Sánchez f.rodriguez.sanc@gmail.com (ORCID) [copyright holder]
See Also
Useful links:
Report bugs at https://github.com/EcologyR/mappestRisk/issues
Brachycaudus schwartzi whole life cycle development rate across temperatures
Description
A modified data set from Table 1 in Satar and Yokomi (2002) on days of development for Brachycaudus schwartzi across different constant temperatures and life stages
Usage
data(aphid)
Format
aphid
A data frame with 7 rows and 5 columns.
The workflow is reproducible and available in /data-raw folder of the
mappestRisk GitHub repository,
which includes both the original summarized data set -satar_data.xlsx-
and the R script with the dev. days to dev. rate conversion
in prepare_aphid.R.
- reference
"Satar2002" refers to the source paper as cited below in section
Source.- temperature
Temperature treatments (ºC).
- dev_days
Development days (i.e., days to fulfill development requirements from a life-stage to the following)
- rate_value
Rate of Development (1/days), the reciprocal of Development days, see
dev_days- stage
Life stage or instar evaluated. In this case, only data of the whole immature stages (i.e., nymphs) were used
Source
Satar, S. and Yokomi, R. (2002). Effect of temperature and host on development of Brachycaudus schwartzi (Homoptera: Aphididae). Ann. Entomol. Soc. Am. 95: 597-602. doi:10.1603/0013-8746(2002)095[0597:EOTAHO]2.0.CO;2.
Licence: CC BY-NC 3.0 (modified material).
Available Models Table
Description
Table containing the available models to be fit using fit_devmodels().
These models come from two other packages:
devRate and
rTPC .
Usage
data("available_models")
Format
available_models
A data.frame/tibble with 13 rows and 6 columns:
- model_name
Model name to be used within
fit_devmodels().- package
names of the packages used by
fit_devmodels()to obtain appropriate start values for the user-provided data. When the package is rTPC package, start values are automatically computed withrTPC::get_start_vals(), which in turn relies onnls.multstart::nls_multstart(). When the package is devRate package, iterative starting values are computed usingnls.multstart::nls_multstart(), using the parameters published indevRate::devRateEqStartVal()as first attempts to iterate. As an exception, ifmodel_name == "briere1", generic starting values are provided and advised to the user due to the unrealistic value of some parameters in thedevRatedata set.- source_model_name
name of the function in the source packages
rTPCanddevRate.- formula, working_formula, n_params
formulas used for model fitting.
Source
Rebaudo, F., Struelens, Q., and Dangles, O. (2018). Modelling temperature-dependent
development rate and phenology in arthropods: The devRate package for R.
Methods Ecol Evol. 9: 1144-1150. doi:10.1111/2041-210X.12935.
Padfield, D., O´Sullivan, H., and Pawar, S., (2021). rTPC and nls.multstart:
a new pipeline to fit thermal performance curves in R. Methods Ecol Evol. 12: 1138-1143.
doi:10.1111/2041-210X.13585.
Country names
Description
Country names
Usage
country_names
Format
country_names
A character vector of country names (length = 231 countries)
Source
https://gadm.org
Fit Thermal Performance Curves
Description
Fit nonlinear regression models to data representing how development rate changes
with temperature (known as Thermal Performance Curves), based on
nls.multstart::nls_multstart() approach to development rate data across temperatures.
The fitting procedure is built upon previous packages for starting values estimation,
namely rTPC and devRate.
Usage
fit_devmodels(temp = NULL, dev_rate = NULL, model_name = NULL)
Arguments
temp |
a vector of temperatures used in the experiment. It should have at least four different temperatures and must contain only numbers without any missing values. |
dev_rate |
a vector of estimated development rates corresponding to each temperature.
These rates are calculated as the inverse of the number of days to complete the transition
from the beginning of a certain life stage to the beginning of the following at each temperature.
It must be numeric and of the same length as |
model_name |
a string or a vector that specifies the model(s) to use for fitting the Thermal Performance Curves. Options include "all" or specific models listed in available_models. These models typically exhibit a common unimodal, left-skewed shape. |
Value
A table in tibble format with estimates and standard errors
for each parameter of the models specified by the user that have adequately
converged. Models are sorted based on their Akaike Information Criterion (AIC) values,
with the best fitting models shown first. Fitted models are also provided in list format
in the model_list column and can be accessed using get_fitted_model() for
for further inspection.
It is important to consider ecological criteria alongside statistical information.
For additional help in model selection,
we recommend using plot_devmodels() and consulting relevant literature.
Source
The dataset used in the example was originally published in Satar & Yokomi (2022) under the CC-BY-NC license. The start values and equations for the 'briere1', 'lactin1', 'mod_polynomial' and 'wang' models have been obtained from the devRate package.
References
Angilletta, M.J., (2006). Estimating and comparing thermal performance curves. J. Therm. Biol. 31: 541-545. (for model selection in TPC framework)
Padfield, D., O'Sullivan, H. and Pawar, S. (2021). rTPC and nls.multstart:
A new pipeline to fit thermal performance curves in R. Methods Ecol Evol. 12: 1138-1143.
Rebaudo, F., Struelens, Q. and Dangles, O. (2018). Modelling temperature-dependent
development rate and phenology in arthropods: The devRate package for R.
Methods Ecol Evol. 9: 1144-1150.
Satar, S. and Yokomi, R. (2002). Effect of temperature and host on development of Brachycaudus schwartzi (Homoptera: Aphididae). Ann. Entomol. Soc. Am. 95: 597-602.
See Also
nls.multstart::nls_multstart() for structure of model fitting approach
browseVignettes("rTPC") for model names, start values searching workflows and
bootstrapping procedures using both rTPC and nls.multstart packages.
Examples
data("aphid")
fitted_tpcs <- fit_devmodels(temp = aphid$temperature,
dev_rate = aphid$rate_value,
model_name = c("lactin2", "briere2",
"mod_weibull")
)
head(fitted_tpcs)
Get fitted model object
Description
Get fitted model object
Usage
get_fitted_model(fitted_df = NULL, model_name = NULL)
Arguments
fitted_df |
A table with fitted models, as produced by |
model_name |
Character. Name of a fitted model, see available_models. |
Value
A model object
Examples
data("aphid")
fitted_tpcs_aphid <- fit_devmodels(temp = aphid$temperature,
dev_rate = aphid$rate_value,
model_name = c("lactin2", "briere2", "ratkowsky")
)
get_fitted_model(fitted_tpcs_aphid, "briere2")
Map pest risk
Description
This function produces a raster map where each pixel shows the number of
months per year in which temperature is within a given set of bounds. If
the input has several pairs of minimum and maximum temperatures (as
produced by therm_suit_bounds()), the output raster has two layers: mean
and standard deviation.
Usage
map_risk(
t_vals = NULL,
t_rast = NULL,
region = NULL,
res = 2.5,
path = NULL,
mask = TRUE,
verbose = FALSE,
plot = TRUE,
interactive = FALSE
)
Arguments
t_vals |
a |
t_rast |
Optional 12-layer |
region |
Optional object specifying the region to map. Must overlap the
extent of |
res |
Argument to pass to |
path |
Argument to pass to |
mask |
Logical value to pass to |
verbose |
Logical value specifying whether to display messages about what the function is doing at possibly slow steps. The default is FALSE. Setting it to TRUE can be useful for checking progress when maps are large. |
plot |
Logical value specifying whether to plot the results in a map.
Defaults to TRUE. Note that the function will always return a |
interactive |
Logical value specifying whether the plotted map should be interactive (if plot=TRUE). The default is TRUE if the 'leaflet' package is installed. |
Value
This function returns a terra::SpatRaster() with up to 2 layers:
the (mean()) number of months with temperature within the species' thermal
bounds; and (if t_vals has >1 rows) the standard deviation (stats::sd()) around
that mean.
Examples
data("aphid")
fitted_tpcs <- fit_devmodels(temp = aphid$temperature,
dev_rate = aphid$rate_value,
model_name = "all")
plot_devmodels(temp = aphid$temperature,
dev_rate = aphid$rate_value,
fitted_parameters = fitted_tpcs,
species = "Brachycaudus schwartzi",
life_stage = "Nymphs")
boot_tpcs <- predict_curves(temp = aphid$temperature,
dev_rate = aphid$rate_value,
fitted_parameters = fitted_tpcs,
model_name_2boot = c("lactin2", "briere2", "beta"),
propagate_uncertainty = TRUE,
n_boots_samples = 10)
print(boot_tpcs)
plot_uncertainties(temp = aphid$temperature,
dev_rate = aphid$rate_value,
bootstrap_tpcs = boot_tpcs,
species = "Brachycaudus schwartzi",
life_stage = "Nymphs")
boundaries <- therm_suit_bounds(preds_tbl = boot_tpcs,
model_name = "lactin2",
suitability_threshold = 80)
risk_map_reunion <- map_risk(t_vals = boundaries,
path = tempdir(),
region = "Réunion",
mask = TRUE,
plot = TRUE,
interactive = FALSE,
verbose = TRUE)
Plot fitted thermal performance curves
Description
Plot the predicted development rates across temperatures based on fitted Thermal Performance Curves (TPCs) for one or several models displayed in facets.
Usage
plot_devmodels(
temp = NULL,
dev_rate = NULL,
fitted_parameters = NULL,
species = NULL,
life_stage = NULL
)
Arguments
temp |
a vector of temperatures used in the experiment. It should have at least four different temperatures and must contain only numbers without any missing values. |
dev_rate |
a vector of estimated development rates corresponding to each temperature.
These rates are calculated as the inverse of the number of days to complete the transition
from the beginning of a certain life stage to the beginning of the following at each temperature.
It must be numeric and of the same length as |
fitted_parameters |
a |
species |
optional a string of the target species that will constitute the plot title. Must be of type "character". |
life_stage |
optional a string of the target life stage that will constitute the plot subtitle. Must be of type "character". |
Value
A plot with predicted values (development rate) across temperatures
for models that have adequately converged using fit_devmodels() function.
It's a ggplot object, which can be assigned to a user-defined object.
References
Angilletta, M.J., (2006). Estimating and comparing thermal performance curves. J. Therm. Biol. 31: 541-545. (for model selection in TPC framework)
Padfield, D., O'Sullivan, H. and Pawar, S. (2021). rTPC and nls.multstart:
A new pipeline to fit thermal performance curves in R. Methods Ecol Evol. 12: 1138-1143.
Rebaudo, F., Struelens, Q. and Dangles, O. (2018). Modelling temperature-dependent
development rate and phenology in arthropods: The devRate package for R.
Methods Ecol Evol. 9: 1144-1150.
Satar, S. and Yokomi, R. (2002). Effect of temperature and host on development of Brachycaudus schwartzi (Homoptera: Aphididae). Ann. Entomol. Soc. Am. 95: 597-602.
See Also
fit_devmodels() for fitting Thermal Performance Curves to
development rate data, which is in turn based on nls.multstart::nls_multstart().
Examples
data("aphid")
fitted_tpcs <- fit_devmodels(temp = aphid$temperature,
dev_rate = aphid$rate_value,
model_name = c("lactin2", "briere2", "mod_weibull"))
plot_devmodels(temp = aphid$temperature,
dev_rate = aphid$rate_value,
fitted_parameters = fitted_tpcs,
species = "Brachycaudus schwartzi",
life_stage = "Nymphs")
Draw bootstrapped Thermal Performance Curves (TPCs) to visualize uncertainty in parameter estimation of TPC fitting
Description
Draw bootstrapped Thermal Performance Curves (TPCs) to visualize uncertainty in parameter estimation of TPC fitting
Usage
plot_uncertainties(
temp = NULL,
dev_rate = NULL,
bootstrap_tpcs = NULL,
species = NULL,
life_stage = NULL,
alpha = 0.2
)
Arguments
temp |
a vector of temperatures used in the experiment. It should have at least four different temperatures and must contain only numbers without any missing values. |
dev_rate |
a vector of estimated development rates corresponding to each temperature.
These rates are calculated as the inverse of the number of days to complete the transition
from the beginning of a certain life stage to the beginning of the following at each temperature.
It must be numeric and of the same length as |
bootstrap_tpcs |
a |
species |
optional a string of the target species that will constitute the plot title. Must be of type "character". |
life_stage |
optional a string of the target life stage that will constitute the plot subtitle. Must be of type "character". |
alpha |
a number between 0 and 1 to choose transparency of the bootstrapped curves (0 = complete transparency, 1 = solid line). |
Value
A ggplot object containing the visual representation of the estimate TPC and the bootstrapped uncertainty curves as a ribbon. Each model is represented in a facet, and data points are also explicit.
References
Angilletta, M.J., (2006). Estimating and comparing thermal performance curves. J. Therm. Biol. 31: 541-545. (for model selection in TPC framework)
Padfield, D., O'Sullivan, H. and Pawar, S. (2021). rTPC and nls.multstart:
A new pipeline to fit thermal performance curves in R. Methods Ecol Evol. 12: 1138-1143.
Rebaudo, F., Struelens, Q. and Dangles, O. (2018). Modelling temperature-dependent
development rate and phenology in arthropods: The devRate package for R.
Methods Ecol Evol. 9: 1144-1150.
Satar, S. and Yokomi, R. (2002). Effect of temperature and host on development of Brachycaudus schwartzi (Homoptera: Aphididae). Ann. Entomol. Soc. Am. 95: 597-602.
See Also
browseVignettes("rTPC") for model names, start values searching workflows, and
bootstrapping procedures using both rTPC::get_start_vals() and nls.multstart::nls_multstart()
fit_devmodels() for fitting Thermal Performance Curves to development rate data,
which is in turn based on nls.multstart::nls_multstart().
predict_curves() for bootstrapping procedure based on the above-mentioned rTPC vignettes.
Examples
data("aphid")
fitted_tpcs <- fit_devmodels(temp = aphid$temperature,
dev_rate = aphid$rate_value,
model_name = "all")
plot_devmodels(temp = aphid$temperature,
dev_rate = aphid$rate_value,
fitted_parameters = fitted_tpcs,
species = "Brachycaudus swartzi",
life_stage = "Nymphs")
boot_tpcs <- predict_curves(temp = aphid$temperature,
dev_rate = aphid$rate_value,
fitted_parameters = fitted_tpcs,
model_name_2boot = c("lactin2", "briere2", "beta"),
propagate_uncertainty = TRUE,
n_boots_samples = 10)
print(boot_tpcs)
plot_uncertainties(temp = aphid$temperature,
dev_rate = aphid$rate_value,
bootstrap_tpcs = boot_tpcs,
species = "Brachycaudus schwartzi",
life_stage = "Nymphs")
Propagate parameter uncertainty of TPC fits using bootstrap with residual resampling
Description
Propagate parameter uncertainty of TPC fits using bootstrap with residual resampling
Usage
predict_curves(
temp = NULL,
dev_rate = NULL,
fitted_parameters = NULL,
model_name_2boot = NULL,
propagate_uncertainty = TRUE,
n_boots_samples = 100
)
Arguments
temp |
a vector of temperatures used in the experiment. It should have at least four different temperatures and must contain only numbers without any missing values. |
dev_rate |
a vector of estimated development rates corresponding to each temperature.
These rates are calculated as the inverse of the number of days to complete the transition
from the beginning of a certain life stage to the beginning of the following at each temperature.
It must be numeric and of the same length as |
fitted_parameters |
a |
model_name_2boot |
A vector of strings including one or several TPC models
fitted by |
propagate_uncertainty |
A logical argument that specifies whether to
propagate parameter uncertainty by bootstrap with residual resampling.
If |
n_boots_samples |
Number of bootstrap resampling iterations (default is 100).
A larger number of iterations makes the resampling procedure more robust,
but typically 100 is sufficient for propagating parameter uncertainty,
as increasing |
Value
A tibble object with as many curves (TPCs) as the number of iterations provided
in the n_boots_samples argument if propagate_uncertainty = TRUE minus the bootstrap samples that
could not be fitted (i.e., new nonlinear regression models did not converge for them).
Otherwise, it returns just one prediction TPC from model fit estimates.
Each resampled TPC consists of a collection of predictions for a set of temperatures
from temp - 20 to temp + 15 with a resolution of 0.1°C and a unique identifier
called boots_iter. In addition to the uncertainty TPCs, the estimated TPC
is also explicit in the output tibble.
References
Angilletta, M.J., (2006). Estimating and comparing thermal performance curves. J. Therm. Biol. 31: 541-545. (for model selection in TPC framework)
Padfield, D., O'Sullivan, H. and Pawar, S. (2021). rTPC and nls.multstart:
A new pipeline to fit thermal performance curves in R. Methods Ecol Evol. 12: 1138-1143.
Rebaudo, F., Struelens, Q. and Dangles, O. (2018). Modelling temperature-dependent
development rate and phenology in arthropods: The devRate package for R.
Methods Ecol Evol. 9: 1144-1150.
Satar, S. and Yokomi, R. (2002). Effect of temperature and host on development of Brachycaudus schwartzi (Homoptera: Aphididae). Ann. Entomol. Soc. Am. 95: 597-602.
See Also
browseVignettes("rTPC") for model names, start values searching workflows, and
bootstrapping procedures using both rTPC::get_start_vals() and nls.multstart::nls_multstart()
fit_devmodels() for fitting Thermal Performance Curves to development rate data,
which is in turn based on nls.multstart::nls_multstart().
Examples
data("aphid")
fitted_tpcs <- fit_devmodels(temp = aphid$temperature,
dev_rate = aphid$rate_value,
model_name = "all")
plot_devmodels(temp = aphid$temperature,
dev_rate = aphid$rate_value,
fitted_parameters = fitted_tpcs,
species = "Brachycaudus schwartzi",
life_stage = "Nymphs")
boot_tpcs <- predict_curves(temp = aphid$temperature,
dev_rate = aphid$rate_value,
fitted_parameters = fitted_tpcs,
model_name_2boot = c("lactin2", "briere2", "beta"),
propagate_uncertainty = TRUE,
n_boots_samples = 10)
head(boot_tpcs)
Determine Thermal Boundaries for Optimal Performance Level
Description
Calculate thermal boundaries that define the suitable region of a Thermal Performance Curve (TPC) corresponding to a user-defined optimal performance level.
Usage
therm_suit_bounds(
preds_tbl = NULL,
model_name = NULL,
suitability_threshold = NULL
)
Arguments
preds_tbl |
a |
model_name |
character. Name of one or several of the TPC models fitted
first in |
suitability_threshold |
A numeric value from 50 to 100 representing
the quantile of the curve that provides the user-defined optimal performance.
For instance, setting |
Value
A tibble with six columns:
-
model_name: A string indicating the selected TPC model used for projections. -
suitability: A string indicating the suitability threshold in percentage (seesuitability_threshold). -
tval_left: A number representing the lower thermal boundary delimiting the suitable region of the TPC. -
tval_right: A number representing the upper thermal boundary delimiting the suitable region of the TPC. -
pred_suit: A number corresponding to the predicted development rate value determining the chosen quantile threshold of the maximum rate (i.e., suitability percentage of maximum rate). -
iter: A string determining the TPC identity from the bootstrapping procedure inpredict_curves()function, orestimatewhen it represents the estimated TPC fitted infit_devmodels().
References
Angilletta, M.J., (2006). Estimating and comparing thermal performance curves. J. Therm. Biol. 31: 541-545. (for model selection in TPC framework)
Padfield, D., O'Sullivan, H. and Pawar, S. (2021). rTPC and nls.multstart:
A new pipeline to fit thermal performance curves in R. Methods Ecol Evol. 12: 1138-1143.
Rebaudo, F., Struelens, Q. and Dangles, O. (2018). Modelling temperature-dependent
development rate and phenology in arthropods: The devRate package for R.
Methods Ecol Evol. 9: 1144-1150.
Satar, S. and Yokomi, R. (2002). Effect of temperature and host on development of Brachycaudus schwartzi (Homoptera: Aphididae). Ann. Entomol. Soc. Am. 95: 597-602.
See Also
browseVignettes("rTPC") for model names, start values searching workflows, and
bootstrapping procedures using both rTPC::get_start_vals() and nls.multstart::nls_multstart()
fit_devmodels() for fitting Thermal Performance Curves to development rate data,
which is in turn based on nls.multstart::nls_multstart().
predict_curves() for bootstrapping procedure based on the above-mentioned rTPC vignettes.
Examples
data("aphid")
fitted_tpcs <- fit_devmodels(temp = aphid$temperature,
dev_rate = aphid$rate_value,
model_name = "all")
plot_devmodels(temp = aphid$temperature,
dev_rate = aphid$rate_value,
fitted_parameters = fitted_tpcs,
species = "Brachycaudus schwartzi",
life_stage = "Nymphs")
boot_tpcs <- predict_curves(temp = aphid$temperature,
dev_rate = aphid$rate_value,
fitted_parameters = fitted_tpcs,
model_name_2boot = c("lactin2", "briere2", "beta"),
propagate_uncertainty = TRUE,
n_boots_samples = 10)
print(boot_tpcs)
plot_uncertainties(temp = aphid$temperature,
dev_rate = aphid$rate_value,
bootstrap_tpcs = boot_tpcs,
species = "Brachycaudus schwartzi",
life_stage = "Nymphs")
boundaries <- therm_suit_bounds(preds_tbl = boot_tpcs,
model_name = "lactin2",
suitability_threshold = 80)
head(boundaries)