timeModel: Express a model in function of time only

timeModelR Documentation

Express a model in function of time only

Description

Compose the function of the model and the interpolating functions representing its variables.

Usage

timeModel(
  model,
  conditions,
  param = list(),
  control = list(),
  interpolation = "constant"
)

Arguments

model

character corresponding to the name of the rate model.

conditions

data.frame with columns named time and variables expected to correspond to those of the model.

param

list parameters of the model.

control

list of arguments that control the behaviour of the model.

interpolation

character corresponding to the name of the interpolating method of the model variables. Available methods include constant (default), linear and spline (for natural cubic splines).

Value

Return a new function that only depend on time (represented as time).

Examples

#Example of a rate model in function of time (instead of the original variable(s))
conditions <- data.frame(time = seq(0,30,length.out = 10), temp = rnorm(10, 10, 5))
model <- "modelLinear"
param = list(a = 1, T0 = 10)

#Get the function representing the model, can be evaluated at any time within those of conditions
f <- timeModel(model = model, conditions = conditions, param = param)
x <- seq(0,30,length.out = 20)
f(x)

#Plot
x <- seq(0,30,length.out = 1000)
plot(conditions$time,f(conditions$time))
lines(x,f(x))


aleblancbio/timescale documentation built on Aug. 27, 2022, 3:01 p.m.