calibrar package: Automated Calibration for Complex Models
This package allows the parameter estimation (i.e. calibration) of complex models, including stochastic ones. It implements generic functions that can be used for fitting any type of models, especially those with non-differentiable objective functions, with the same syntax as base::optim. It supports multiple phases estimation (sequential parameter masking), constrained optimization (bounding box restrictions) and automatic parallel computation of numerical gradients. Some common maximum likelihood estimation methods and automated construction of the objective function from simulated model outputs is provided. See https://roliveros-ramos.github.io/calibrar/ for more details.
Examples
## Not run:require(calibrar)set.seed(880820)path =NULL# NULL to use the current directory# create the demonstration filesdemo = calibrar_demo(model="PoissonMixedModel", L=5, T=100)# get calibration informationcalibrationInfo = calibration_setup(file=demo$path)# get observed dataobserved = calibration_data(setup=calibrationInfo, path=demo$path)# read forcings for the modelforcing = read.csv(file.path(demo$path,"master","environment.csv"), row.names=1)# Defining 'runModel' functionrunModel =function(par, forcing){output = calibrar:::.PoissonMixedModel(par=par, forcing=forcing)# adding gamma parameters for penaltiesoutput = c(output, list(gammas=par$gamma))return(output)}# real parameterscat("Real parameters used to simulate data\n")print(demo$par)# objective functionsobj = calibration_objFn(model=runModel, setup=calibrationInfo, observed=observed, forcing=forcing)cat("Starting calibration...\n")control = list(weights=calibrationInfo$weights, maxit=3.6e5)# control parameterscat("Running optimization algorithms\n","\t", date(),"\n")cat("Running optim AHR-ES\n")ahr = calibrate(par=demo$guess, fn=obj, lower=demo$lower, upper=demo$upper, control=control)summary(ahr)## End(Not run)
References
calibrar: an R package for the calibration of ecological models (Oliveros-Ramos and Shin 2014)