Step change trend response model

step_trend(t, change_points, means, ...)

Arguments

t

numeric; vector of time points.

change_points

numeric; vector of change points, within t

means

numeric; vector of means for the regimes implied by change_points. Must be of length length(change_points) + 1.

...

other arguments. Ignored here.

Examples

# \dontshow{
set.seed(1)
op <- options(digits = 3, cli.unicode = FALSE)
# }
sims <- step_trend(1:100, change_points = c(25, 75), means = c(2, 8, 4))
sims
#> # A tibble: 100 x 2
#>        t trend
#>    <int> <dbl>
#>  1     1     2
#>  2     2     2
#>  3     3     2
#>  4     4     2
#>  5     5     2
#>  6     6     2
#>  7     7     2
#>  8     8     2
#>  9     9     2
#> 10    10     2
#> # ... with 90 more rows

library("ggplot2")
ggplot(sims, aes(x = t, y = trend)) +
  geom_step()

options(op)