Title: | Automated Parameter Estimation for Complex Models |
---|---|
Description: | General optimisation and specific tools for 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 'stats::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. |
Authors: | Ricardo Oliveros-Ramos [aut, cre] |
Maintainer: | Ricardo Oliveros-Ramos <[email protected]> |
License: | GPL-2 |
Version: | 0.9.0.9002 |
Built: | 2024-11-26 14:31:08 UTC |
Source: | https://github.com/roliveros-ramos/calibrar |
Automated Calibration for Complex Models
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.
Ricardo Oliveros-Ramos Maintainer: Ricardo Oliveros-Ramos <[email protected]>
calibrar: an R package for the calibration of ecological models (Oliveros-Ramos and Shin 2014)
Useful links:
Report bugs at https://github.com/roliveros-ramos/calibrar/issues
## Not run: require(calibrar) set.seed(880820) path = NULL # NULL to use the current directory # create the demonstration files demo = calibrar_demo(model="PoissonMixedModel", L=5, T=100) # get calibration information calibrationInfo = calibration_setup(file=demo$path) # get observed data observed = calibration_data(setup=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 = calibration_objFn(model=runModel, setup=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) ## End(Not run)
## Not run: require(calibrar) set.seed(880820) path = NULL # NULL to use the current directory # create the demonstration files demo = calibrar_demo(model="PoissonMixedModel", L=5, T=100) # get calibration information calibrationInfo = calibration_setup(file=demo$path) # get observed data observed = calibration_data(setup=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 = calibration_objFn(model=runModel, setup=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) ## End(Not run)
Get an specific argument from the command line
.get_command_argument( x, argument, prefix = "--", default = FALSE, verbose = FALSE )
.get_command_argument( x, argument, prefix = "--", default = FALSE, verbose = FALSE )
x |
The command line arguments, from |
argument |
The name of the argument. |
prefix |
The prefix to any argument of interest, the default is "–" |
default |
Default value to return is argument is missing, default to FALSE. |
verbose |
Boolean, if TRUE, shows a warning when the parameter is not found. |
The value of the argument, assumed to be followed after '=' or, TRUE if nothing but the argument was found. If the argument is not found, FALSE is returned.
.get_command_argument(commandArgs(), "interactive") .get_command_argument(commandArgs(), "RStudio") .get_command_argument(commandArgs(), "RStudio", prefix="") .get_command_argument(commandArgs(), "vanilla") .get_command_argument("--control.file=baz.txt", "control.file")
.get_command_argument(commandArgs(), "interactive") .get_command_argument(commandArgs(), "RStudio") .get_command_argument(commandArgs(), "RStudio", prefix="") .get_command_argument(commandArgs(), "vanilla") .get_command_argument("--control.file=baz.txt", "control.file")
File is expected to have lines of the form 'key SEP value' where key is the name of the parameter, SEP a separator (can be '=' ',', ';') and value the value of the parameter itself. The SEP for each line is determined and parameters values are returned as a list.
.read_configuration( file, recursive = TRUE, keep.names = TRUE, conf.key = NULL, ... )
.read_configuration( file, recursive = TRUE, keep.names = TRUE, conf.key = NULL, ... )
file |
File to read the configuration |
recursive |
Should 'conf.key' keys be read as additional configuration files? Default is TRUE. |
keep.names |
Should names be kept as they are? By default, are converted to lower case. |
conf.key |
String indicating the leading key to find an additional configuration file. |
... |
Additional arguments, not currently in use. |
This function performs the optimization of a function using the Adaptative Hierarchical Recombination Evolutionary Strategy (AHR-ES, Oliveros & Shin, 2015).
ahres( par, fn, gr = NULL, ..., lower = -Inf, upper = +Inf, active = NULL, control = list(), hessian = FALSE, parallel = FALSE )
ahres( par, fn, gr = NULL, ..., lower = -Inf, upper = +Inf, active = NULL, control = list(), hessian = FALSE, parallel = FALSE )
par |
A numeric vector or list. The length of the par argument defines the number of parameters to be estimated (i.e. the dimension of the problem). |
fn |
The function to be minimized. |
gr |
A function computing the gradient of |
... |
Additional parameters to be passed to |
lower |
Lower threshold value(s) for parameters. One value or a vector
of the same length as par. If one value is provided, it is used for all
parameters. |
upper |
Upper threshold value(s) for parameters. One value or a vector
of the same length as par. If one value is provided, it is used for all
parameters. |
active |
Boolean vector of the same length as par, indicating if the parameter is used in the optimization (TRUE) or hold at a fixed value (FALSE). |
control |
Parameter for the control of the algorithm itself, see details. |
hessian |
Logical. Should a numerically differentiated Hessian matrix be returned? Currently not implemented. |
parallel |
Logical. Use parallel computation numerical of gradient? |
A list with components:
The best set of parameters found.
The value of fn corresponding to par.
A two-element integer vector giving the number of calls to fn and gr respectively. This excludes those calls needed to compute the Hessian, if requested, and any calls to fn to compute a finite-difference approximation to the gradient.
An integer code. 0 indicates successful completion.
A character string giving any additional information returned by the optimizer, or NULL.
Only if argument hessian is true. A symmetric matrix giving an estimate of the Hessian at the solution found. Note that this is the Hessian of the unconstrained problem even if the box constraints are active.
Ricardo Oliveros-Ramos
Other optimisers:
calibrate()
,
optim2()
,
optimh()
## Not run: ahres(par=rep(1, 5), fn=sphereN)
## Not run: ahres(par=rep(1, 5), fn=sphereN)
Creates demo files able to be processed for a full calibration using the calibrar package
calibrar_demo(path = NULL, model = NULL, ...)
calibrar_demo(path = NULL, model = NULL, ...)
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. |
Current implemented models are:
Poisson Autoregressive Mixed model for the dynamics of a population in different sites:
where is the size of the population in site
at year
,
is the value of an environmental variable in site
at year
.
The parameters to estimate were
,
, and
, the
random effects for each year,
, and the initial
population at each site
. We assumed that the observations
follow a Poisson distribution with mean
.
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$:
The parameters to estimate are the prey’s growth rate , the predator’s
mortality rate
, the carrying capacity of the prey
and
and
for the predation interaction. Uses
deSolve
package
for numerical solution of the ODE system.
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:
The parameters to estimate are the average number of contacts per person per
time and the instant probability of an infectious individual
recovering
. Uses
deSolve
package for numerical solution of the ODE system.
Stochastic Individual Based Model for Lotka-Volterra model. Uses ibm
package for the simulation.
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. |
Ricardo Oliveros–Ramos
Oliveros-Ramos and Shin (2014)
## 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)
## 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)
This function performs the optimization of a function, possibly
in sequential phases of increasing complexity, and it is designed for the
calibration of a model, by minimizing the error function fn
associated to it.
calibrate( par, fn, gr, ..., method, lower, upper, phases, control, hessian, replicates, parallel ) ## Default S3 method: calibrate( par, fn, gr = NULL, ..., method = NULL, lower = NULL, upper = NULL, phases = NULL, control = list(), hessian = FALSE, replicates = 1, parallel = FALSE )
calibrate( par, fn, gr, ..., method, lower, upper, phases, control, hessian, replicates, parallel ) ## Default S3 method: calibrate( par, fn, gr = NULL, ..., method = NULL, lower = NULL, upper = NULL, phases = NULL, control = list(), hessian = FALSE, replicates = 1, parallel = FALSE )
par |
A numeric vector or list. The length of the par argument defines the number of parameters to be estimated (i.e. the dimension of the problem). |
fn |
The function to be minimized. |
gr |
A function computing the gradient of |
... |
Additional parameters to be passed to |
method |
The optimization method to be used. The default method is the AHR-ES (Adaptative Hierarchical Recombination Evolutionary Strategy, Oliveros-Ramos & Shin, 2016). See details for the methods available. |
lower |
Lower threshold value(s) for parameters. One value or a vector
of the same length as par. If one value is provided, it is used for all
parameters. |
upper |
Upper threshold value(s) for parameters. One value or a vector
of the same length as par. If one value is provided, it is used for all
parameters. |
phases |
An optional vector of the same length as |
control |
Parameter for the control of the algorithm itself, see details. |
hessian |
Logical. Should a numerically differentiated Hessian matrix be returned? Currently not implemented. |
replicates |
The number of replicates for the evaluation of |
parallel |
Logical. Use parallel computation numerical of gradient? |
In the control list, aggFn
is a function to aggregate fn
to
a scalar value if the returned value is a vector. Some optimization algorithm can
exploite the additional information provided by a vectorial output from fn
.
Ricardo Oliveros-Ramos
Other optimisers:
ahres()
,
optim2()
,
optimh()
calibrate(par=rep(NA, 5), fn=sphereN) ## Not run: calibrate(par=rep(NA, 5), fn=sphereN, replicates=3) calibrate(par=rep(0.5, 5), fn=sphereN, replicates=3, lower=-5, upper=5) calibrate(par=rep(0.5, 5), fn=sphereN, replicates=3, lower=-5, upper=5, phases=c(1,1,1,2,3)) calibrate(par=rep(0.5, 5), fn=sphereN, replicates=c(1,1,4), lower=-5, upper=5, phases=c(1,1,1,2,3)) ## End(Not run)
calibrate(par=rep(NA, 5), fn=sphereN) ## Not run: calibrate(par=rep(NA, 5), fn=sphereN, replicates=3) calibrate(par=rep(0.5, 5), fn=sphereN, replicates=3, lower=-5, upper=5) calibrate(par=rep(0.5, 5), fn=sphereN, replicates=3, lower=-5, upper=5, phases=c(1,1,1,2,3)) calibrate(par=rep(0.5, 5), fn=sphereN, replicates=c(1,1,4), lower=-5, upper=5, phases=c(1,1,1,2,3)) ## End(Not run)
Create a list with the observed data with the information provided by its main argument.
calibration_data(setup, path = ".", file = NULL, verbose = TRUE, ...)
calibration_data(setup, path = ".", file = NULL, verbose = TRUE, ...)
setup |
A data.frame with the information about the calibration,
normally created with the |
path |
Path to the directory to look up for the data. Paths in setup are considered relatives to this path. |
file |
Optional file to save the created object (as an 'rds' file.) |
verbose |
If TRUE, detailed messages of the process are printed. |
... |
Additional arguments to |
A list with the observed data needed for a calibration, to be used
in combination with the calibration_objFn
.
Ricardo Oliveros-Ramos
calibration_objFn
, calibration_setup
.
Create a new function, to be used as the objective function in the calibration, given a function to run the model within R, observed data and information about the comparison with data.
calibration_objFn(model, setup, observed, aggFn = NULL, aggregate = FALSE, ...)
calibration_objFn(model, setup, observed, aggFn = NULL, aggregate = FALSE, ...)
model |
Function to run the model and produce a list of outputs. |
setup |
A data.frame with the information about the calibration,
normally created with the |
observed |
A list of the observed variables created with the
function |
aggFn |
A function to aggregate |
aggregate |
boolean, if TRUE, a scalar value is returned using the
|
... |
More arguments passed to the |
A function, integrating the simulation of the model and the comparison with observed data.
Ricardo Oliveros-Ramos
calibration_data
, calibration_setup
.
calibrar
package.A wrapper for read.csv
checking column names and data types
for the table with the calibration information.
calibration_setup(file, control = list(), ...)
calibration_setup(file, control = list(), ...)
file |
The file with the calibration information, see details. |
control |
Control arguments for generating the setup. See details. |
... |
Additional arguments to |
A data.frame with the information for the calibration of a
model, to be used with the calibration_objFn
and calibration_data
.
Ricardo Oliveros-Ramos
calibration_objFn
, calibration_data
.
Calculate a discretization of the 2D Gaussian Kernel
gaussian_kernel(par, lower, upper, n = 10, checkSymmetry = TRUE, ...)
gaussian_kernel(par, lower, upper, n = 10, checkSymmetry = TRUE, ...)
par |
A list, including the mean and covariance matrix. |
lower |
A vector, indicating the lower bound for the calculation. |
upper |
A vector, indicating the upper bound for the calculation. |
n |
The number of cells for each dimension, can be one or two numbers. |
checkSymmetry |
TRUE by default, checks if the covariance matrix is symmetric. |
... |
Additional arguments, currently not used. |
A list, with 'x', 'y' and 'z' components.
This function calculates the gradient of a function, numerically, including the possibility of doing it in parallel.
gradient(fn, x, method, control, parallel, ...)
gradient(fn, x, method, control, parallel, ...)
fn |
The function to calculate the gradient. |
x |
The value to compute the gradient at. |
method |
The method used. Currently implemented: central, backward, forward and Richardson. See details. |
control |
A list of control arguments. |
parallel |
Boolean, should numerical derivatives be calculated in parallel? |
... |
Additional arguments to be passed to |
The gradient of fn
at x
.
gradient(fn=function(x) sum(x^3), x=0)
gradient(fn=function(x) sum(x^3), x=0)
Calcuted error measure between observed and simulated data
objFn(obs, sim, FUN, ...) fitness(obs, sim, FUN, ...)
objFn(obs, sim, FUN, ...) fitness(obs, sim, FUN, ...)
obs |
observed data as expected by FUN. |
sim |
simulated data matching 'obs' |
FUN |
the error function. Current accepted values area: 'norm2', 'lnorm2', 'lnorm3', 'multinomial', 'pois', 'penalty0', 'penalty1', 'penalty2' and 'normp'. |
... |
Additional arguments to FUN |
the value of FUN(obs, sim, ...)
General-purpose optimization with parallel numerical gradient computation
optim2( par, fn, gr = NULL, ..., method = c("Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN", "Brent", "nlm", "nlminb", "Rcgmin", "Rvmmin", "hjn", "spg", "LBFGSB3", "AHR-ES"), lower = -Inf, upper = +Inf, active = NULL, control = list(), hessian = FALSE, parallel = FALSE )
optim2( par, fn, gr = NULL, ..., method = c("Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN", "Brent", "nlm", "nlminb", "Rcgmin", "Rvmmin", "hjn", "spg", "LBFGSB3", "AHR-ES"), lower = -Inf, upper = +Inf, active = NULL, control = list(), hessian = FALSE, parallel = FALSE )
par |
A numeric vector or list. The length of the par argument defines the number of parameters to be estimated (i.e. the dimension of the problem). |
fn |
The function to be minimized. |
gr |
A function computing the gradient of |
... |
Additional parameters to be passed to |
method |
The optimization method to be used. The default method is the AHR-ES (Adaptative Hierarchical Recombination Evolutionary Strategy, Oliveros-Ramos & Shin, 2016). See details for the methods available. |
lower |
Lower threshold value(s) for parameters. One value or a vector
of the same length as par. If one value is provided, it is used for all
parameters. |
upper |
Upper threshold value(s) for parameters. One value or a vector
of the same length as par. If one value is provided, it is used for all
parameters. |
active |
Boolean vector of the same length as par, indicating if the parameter is used in the optimization (TRUE) or hold at a fixed value (FALSE). |
control |
Parameter for the control of the algorithm itself, see details. |
hessian |
Logical. Should a numerically differentiated Hessian matrix be returned? Currently not implemented. |
parallel |
Logical. Use parallel computation numerical of gradient? |
A list with components:
The best set of parameters found.
The value of fn corresponding to par.
A two-element integer vector giving the number of calls to fn and gr respectively. This excludes those calls needed to compute the Hessian, if requested, and any calls to fn to compute a finite-difference approximation to the gradient.
An integer code. 0 indicates successful completion.
A character string giving any additional information returned by the optimizer, or NULL.
Only if argument hessian is true. A symmetric matrix giving an estimate of the Hessian at the solution found. Note that this is the Hessian of the unconstrained problem even if the box constraints are active.
Ricardo Oliveros-Ramos
Other optimisers:
ahres()
,
calibrate()
,
optimh()
optim2(par=rep(NA, 5), fn=sphereN)
optim2(par=rep(NA, 5), fn=sphereN)
General-purpose optimization using heuristic algorithms
optimh( par, fn, gr = NULL, ..., method = c("AHR-ES", "Nelder-Mead", "SANN", "hjn", "bobyqa", "CMA-ES", "genSA", "DE", "soma", "genoud", "PSO", "hybridPSO", "mads", "hjk", "hjkb", "nmk", "nmkb"), lower = -Inf, upper = +Inf, active = NULL, control = list(), hessian = FALSE, parallel = FALSE )
optimh( par, fn, gr = NULL, ..., method = c("AHR-ES", "Nelder-Mead", "SANN", "hjn", "bobyqa", "CMA-ES", "genSA", "DE", "soma", "genoud", "PSO", "hybridPSO", "mads", "hjk", "hjkb", "nmk", "nmkb"), lower = -Inf, upper = +Inf, active = NULL, control = list(), hessian = FALSE, parallel = FALSE )
par |
A numeric vector or list. The length of the par argument defines the number of parameters to be estimated (i.e. the dimension of the problem). |
fn |
The function to be minimized. |
gr |
Function to compute the gradient of |
... |
Additional parameters to be passed to |
method |
The optimization method to be used. The default method is the AHR-ES (Adaptative Hierarchical Recombination Evolutionary Strategy, Oliveros-Ramos & Shin, 2016). See details for the methods available. |
lower |
Lower threshold value(s) for parameters. One value or a vector
of the same length as par. If one value is provided, it is used for all
parameters. |
upper |
Upper threshold value(s) for parameters. One value or a vector
of the same length as par. If one value is provided, it is used for all
parameters. |
active |
Boolean vector of the same length as par, indicating if the parameter is used in the optimization (TRUE) or hold at a fixed value (FALSE). |
control |
Parameter for the control of the algorithm itself, see details. |
hessian |
Logical. Should a numerically differentiated Hessian matrix be returned? Currently not implemented. |
parallel |
Logical. Use parallel computation numerical of gradient? |
A list with components:
The best set of parameters found.
The value of fn corresponding to par.
A two-element integer vector giving the number of calls to fn and gr respectively. This excludes those calls needed to compute the Hessian, if requested, and any calls to fn to compute a finite-difference approximation to the gradient.
An integer code. 0 indicates successful completion.
A character string giving any additional information returned by the optimizer, or NULL.
Only if argument hessian is true. A symmetric matrix giving an estimate of the Hessian at the solution found. Note that this is the Hessian of the unconstrained problem even if the box constraints are active.
Ricardo Oliveros-Ramos
Other optimisers:
ahres()
,
calibrate()
,
optim2()
optim2(par=rep(NA, 5), fn=sphereN)
optim2(par=rep(NA, 5), fn=sphereN)
This function calculates the Euclidian distance from a point to the origin after a random displacement of its position.
sphereN(x, sd = 0.1, aggregate = TRUE)
sphereN(x, sd = 0.1, aggregate = TRUE)
x |
The coordinates of the point |
sd |
The standard deviation of the noise
to be added to the position of |
aggregate |
If |
The distance from the point x
to the origin after a random
displacement.
Ricardo Oliveros–Ramos
sphereN(rep(0, 10))
sphereN(rep(0, 10))
Predict time-varying parameters using splines.
spline_par(par, n, knots = NULL, periodic = FALSE, period = NULL)
spline_par(par, n, knots = NULL, periodic = FALSE, period = NULL)
par |
Values at knots |
n |
Number of points. Time (independent variable) is assumed to be between 0 and n with length(par) equidistant points (including 0 and n). |
knots |
Position of knots. Default, is length(x) equidistant points between 0 and 1. Always are re-scaled to 0 to 1. |
periodic |
boolean, is the spline periodic? |
period |
If periodic is TRUE, it specify the time period. |
A list with the interpolates values as 'x' and 'time'.