Generate a sequence of parameter values of length nstep. The user specify a number of "change points" in the sequence the function fills out the rest of the sequence s.t. the shape between each pair of consecutive change points is linear. All values before the first element and after the last element in timing are equal to the first element last element in vals respectively.

vary_param(nstep, vals, timing)

Arguments

nstep

The number of time steps to generate parameter values for, interpreted as the time range of the simulation.

vals

A vector of change point values in the sequence.

timing

A vector of the indices specifying the location or step numbers at which the change points occur. The length of vals and timing should be the same, and both smaller than nsteps.

Value

A sequence of length nsteps.

Examples

round(vary_param(nstep = 10, vals = c(2.5, 3.4, 1.2), timing = c(2, 4, 7)), 2)
#> [1] 2.50 2.50 2.95 3.40 2.67 1.93 1.20 1.20 1.20 1.20