calibrar_demo: Demos for the calibrar package

View source: R/calibrar-auxiliar.R

calibrar_demoR Documentation

Demos for the calibrar package

Description

Creates demo files able to be processed for a full calibration using the calibrar package

Usage

calibrar_demo(path = NULL, model = NULL, ...)

Arguments

path

Path to create the demo files

model

Model to be used in the demo files, see details.

...

Additional parameters to be used in the construction of the demo files.

Details

Current implemented models are:

PoissonMixedModel

Poisson Autoregressive Mixed model for the dynamics of a population in different sites:

log(\mu_{i, t+1}) = log(\mu_{i, t}) + \alpha + \beta X_{i, t} + \gamma_t

where \mu_{i, t} is the size of the population in site i at year t, X_{i, t} is the value of an environmental variable in site i at year t. The parameters to estimate were \alpha, \beta, and \gamma_t, the random effects for each year, \gamma_t \sim N(0,\sigma^2), and the initial population at each site \mu_{i, 0}. We assumed that the observations N_{i,t} follow a Poisson distribution with mean \mu_{i, t}.

PredatorPrey

Lotka Volterra Predator-Prey model. The model is defined by a system of ordinary differential equations for the abundance of prey $N$ and predator $P$:

\frac{dN}{dt} = rN(1-N/K)-\alpha NP

\frac{dP}{dt} = -lP + \gamma\alpha NP

The parameters to estimate are the prey’s growth rate r, the predator’s mortality rate l, the carrying capacity of the prey K and \alpha and \gamma for the predation interaction. Uses deSolve package for numerical solution of the ODE system.

SIR

Susceptible-Infected-Recovered epidemiological model. The model is defined by a system of ordinary differential equations for the number of susceptible $S$, infected $I$ and recovered $R$ individuals:

\frac{dS}{dt} = -\beta S I/N

\frac{dI}{dt} = \beta S I/N -\gamma I

\frac{dR}{dt} = \gamma I

The parameters to estimate are the average number of contacts per person per time \beta and the instant probability of an infectious individual recovering \gamma. Uses deSolve package for numerical solution of the ODE system.

IBMLotkaVolterra

Stochastic Individual Based Model for Lotka-Volterra model. Uses ibm package for the simulation.

Value

A list with the following elements:

path

Path were the files were saved

par

Real value of the parameters used in the demo

setup

Path to the calibration setup file

guess

Values to be provided as initial guess to the calibrate function

lower

Values to be provided as lower bounds to the calibrate function

upper

Values to be provided as upper bounds to the calibrate function

phase

Values to be provided as phases to the calibrate function

constants

Constants used in the demo, any other variable not listed here.

value

NA, set for compatibility with summary methods.

time

NA, set for compatibility with summary methods.

counts

NA, set for compatibility with summary methods.

Author(s)

Ricardo Oliveros–Ramos

References

Oliveros-Ramos and Shin (2014)

Examples

## Not run: 

summary(ahr)
set.seed(880820)
path = NULL # NULL to use the current directory
# create the demonstration files
demo = calibrar_demo(path=path, model="PredatorPrey", T=100) 
# get calibration information
calibration_settings = calibration_setup(file = demo$setup)
# get observed data
observed = calibration_data(setup = calibration_settings, path=demo$path)
# Defining 'run_model' function
run_model = calibrar:::.PredatorPreyModel
# real parameters
cat("Real parameters used to simulate data\n")
print(unlist(demo$par)) # parameters are in a list
# objective functions
obj  = calibration_objFn(model=run_model, setup=calibration_settings, observed=observed, T=demo$T)
obj2 = calibration_objFn(model=run_model, setup=calibration_settings, observed=observed, 
T=demo$T, aggregate=TRUE)
cat("Starting calibration...\n")
cat("Running optimization algorithms\n", "\t")
cat("Running optim AHR-ES\n")
ahr = calibrate(par=demo$guess, fn=obj, lower=demo$lower, upper=demo$upper, phases=demo$phase)
summary(ahr)

## End(Not run) 

roliveros-ramos/calibrar documentation built on March 15, 2024, 12:08 a.m.