R/07_simulate.R
simulate_process.RdThis function automates the process of generating a random underlying function (of various types) and then sampling noisy observations from it, returning a complete simulated dataset.
simulate_process(
x = NULL,
n_basis = 50,
sd_fun = 1,
sd = 0.1,
sd_poly = 0.1,
type = c("linear", "nonlinear", "quadratic", "nondynamic"),
p = 1,
pred_step = 16,
normalize = FALSE
)A numeric vector specifying the grid points where the function is evaluated.
An integer specifying the number of basis functions (for "nonlinear" type).
A numeric value controlling the smoothness of the function under the IWP prior.
A numeric value or vector specifying the standard deviation(s) of observation noise.
A numeric value specifying the standard deviation for polynomial coefficients.
A character string specifying the type of function to simulate. One of "linear", "quadratic", "nonlinear", or "nondynamic".
An integer specifying the order of the polynomial trend in the nonlinear model.
A numeric value representing the resolution parameter for scaling the IWP precision.
A logical value indicating whether to rescale the function to roughly zero mean and unit range.
A data frame containing:
xGrid points where the function is evaluated.
yNoisy observed values.
truefTrue underlying function values at each x.
sdNoise standard deviation used at each point.
dat <- simulate_process(type = "nonlinear")
plot(dat$x, dat$y)