Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

predict_methods

Predict methods in ipmr


Description

This function is used when a predict method is incorporated into the vital rate expressions of a kernel. Generally, ipmr can handle this without any additional user effort, but some model classes will fail (often with an obscure error message). When this happens, use_vr_model can ensure that model object is correctly represented in the data_list.

Usage

use_vr_model(model)

Arguments

model

A fitted model object representing a vital rate. Primarily used to avoid writing the mathematical expression for a vital rate, and using a predict() method instead.

Details

ipmr usually recognizes model objects passed into the data_list argument automatically. Unfortunately, sometimes it'll miss one, and the user will need to manually protect it from the standard build process. This function provides a wrapper around that process.

Wrap a model object in use_vr_model when building the data_list to pass to define_kernel.

Value

A model object with a "flat_protect" attribute.

Examples

data(iceplant_ex)

grow_mod <- lm(log_size_next ~ log_size, data = iceplant_ex)
surv_mod <- glm(survival ~ log_size, data = iceplant_ex, family = binomial())

data_list <- list(
  grow_mod = use_vr_model(grow_mod),
  surv_mod = use_vr_model(surv_mod),
  recruit_mean = 20,
  recruit_sd   = 5
)

ipmr

Fits Integral Projection Models Using an Expression Based Framework

v0.0.1
MIT + file LICENSE
Authors
Sam Levin [aut, cre] (<https://orcid.org/0000-0002-3289-9925>), Aldo Compagnoni [aut], Dylan Childs [aut], Sanne Evers [aut], Roberto Salguero-Gomez [aut], Tiffany Knight [aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.