| cpt_simulate | R Documentation |
Creates a synthetic time series with known changepoints for testing and benchmarking.
cpt_simulate(
n,
changepoints = integer(),
change_in = c("mean", "var", "meanvar", "slope"),
params = NULL,
noise = c("gauss", "t", "ar1", "rw"),
sd = 1,
df = 3,
rho = 0,
seasonality = NULL,
sd_trend = NULL,
seed = NULL,
family = c("gaussian", "poisson", "binomial", "exponential"),
transition = 0
)
rcpt(...)
n |
Length of the series. |
changepoints |
Integer vector of changepoint locations (last index of each segment before the change). |
change_in |
What changes: |
params |
A list of parameters per segment. For |
noise |
Noise type: |
sd |
Noise standard deviation, non-negative (for Gaussian and t;
t-noise is rescaled so its standard deviation is exactly |
df |
Degrees of freedom for t-noise; must exceed 2 so the variance exists. Defaults to 3. |
rho |
AR(1) autocorrelation parameter, strictly between -1 and 1 for
stationarity. Defaults to 0. Used only when |
seasonality |
Optional seasonal component added to the signal, as a
list with |
sd_trend |
Optional smoothly varying noise scale: a length-2 numeric
giving the multiplier on |
seed |
Optional seed for reproducibility. The seed is scoped to this
call: |
family |
The distribution of the observations: |
transition |
Width, in observations, of a gradual change in level:
the mean moves linearly from one segment's value to the next across
|
... |
Passed to |
A tibble with columns index, value, and seg_id.
The true changepoints are stored in the true_changepoints attribute.
Other test signals:
signal_blocks(),
signal_fms(),
signal_mix(),
signal_stairs(),
signal_teeth()
dat <- cpt_simulate(200, changepoints = c(100), change_in = "mean",
params = c(0, 10), seed = 2022)
attr(dat, "true_changepoints")
# a seasonal series with a level shift, and one with drifting noise
seasonal <- cpt_simulate(240, changepoints = 120, params = c(0, 3),
seasonality = list(period = 12, amplitude = 2),
seed = 1)
drifting <- cpt_simulate(240, changepoints = 120, params = c(0, 3),
sd_trend = c(0.5, 3), seed = 1)
# a change that takes 30 observations instead of one
gradual <- cpt_simulate(240, changepoints = 120, params = c(0, 3),
transition = 30, seed = 1)
# counts whose rate doubles
counts <- cpt_simulate(200, changepoints = 100, params = c(4, 8),
family = "poisson", seed = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.