Learn R Programming

calibrar (version 0.2.0)

calibrarDemo: Demos for the calibrar package

Description

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

Usage

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

Value

A list with the following elements:

path

Path were the files were saved

par

Real value of the parameters used in the demo

constants

Constants used in the demo

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.

Author

Ricardo Oliveros--Ramos

References

Oliveros-Ramos and Shin (2014)

Examples

Run this code
if (FALSE) {
require(calibrar)
set.seed(880820)
path = NULL # NULL to use the current directory
# create the demonstration files
demo = calibrarDemo(model="PoissonMixedModel", L=5, T=100)
# get calibration information
calibrationInfo = getCalibrationInfo(path=demo$path)
# get observed data
observed = getObservedData(info=calibrationInfo, path=demo$path)
# read forcings for the model
forcing = read.csv(file.path(demo$path, "master", "environment.csv"), row.names=1)
# Defining 'runModel' function
runModel = function(par, forcing) {
output = calibrar:::.PoissonMixedModel(par=par, forcing=forcing)
# adding gamma parameters for penalties
output = c(output, list(gammas=par$gamma))
return(output)
}
# real parameters
cat("Real parameters used to simulate data\n")
print(demo$par)
# objective functions
obj  = createObjectiveFunction(runModel=runModel, info=calibrationInfo,
                               observed=observed, forcing=forcing)
cat("Starting calibration...\n")
control = list(weights=calibrationInfo$weights, maxit=3.6e5) # control parameters
cat("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)
}

Run the code above in your browser using DataLab