Skip to contents

sim_ts() is mostly a helper function, to be used internally in this package, but you can use it here to simulate a time series.

Usage

sim_ts(n, b0 = 0, bt = 0, rho = 1, white_noise = FALSE, rsd = 1)

Arguments

n

a numeric vector for the length of the series

b0

a numeric vector for a potential drift in the series. Defaults to 0

bt

a numeric vector for a potential trend in the series. Defaults to 0.

rho

a numeric vector for the simple autoregressive parameter. Defaults to 1.

white_noise

= logical, defaults to FALSE. If FALSE, generates a random walk. If TRUE, series is white noise.

rsd

the standard deviation for a normal distribution to be simulated. Defaults to 1.

Value

sim_ts() returns a numeric vector of a simulated time series that would follow the user's input.

Author

Steven V. Miller

Examples


set.seed(8675309) # don't want new numbers in documentation every time...

sim_ts(25)
#>  [1] -0.9965824 -0.2747582 -0.8919670  1.1374246  2.2028406  3.1900603
#>  [7]  3.2175143  3.8903866  4.4624531  5.3661308  3.8165784  4.8392162
#> [13]  4.9892994  4.3293354  3.3347464  5.3072051  4.8654034  3.9647662
#> [19]  3.8141780  2.9862838  4.9721096  5.0161147  4.6118324  4.1388338
#> [25]  3.7240106

sim_ts(25, b0 = 1)
#>  [1]  1.683234  3.373435  4.906927  5.720822  7.103768  8.479952 10.633483
#>  [8] 13.208385 14.796913 15.181867 15.952956 17.016873 17.703400 18.454900
#> [15] 19.301105 19.665848 20.662054 21.707669 23.391741 24.139698 24.988660
#> [22] 25.113728 24.136827 25.374490 26.410581

sim_ts(25, b0 = 1, bt = .05)
#>  [1]  1.184898  2.352480  2.576891  1.491655  2.755863  2.858795  3.257155
#>  [8]  5.035858  7.135636  8.287603 10.934595 12.548679 13.443317 13.317850
#> [15] 14.225703 16.176485 17.584662 17.716140 17.444117 18.721917 19.424063
#> [22] 21.774787 22.600140 21.053274 21.181542