Learn R Programming

sTSD (version 0.2.0)

sim_ts: Simulate a Time Series

Description

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)

Value

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

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.

Author

Steven V. Miller

Examples

Run this code

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

sim_ts(25)

sim_ts(25, b0 = 1)

sim_ts(25, b0 = 1, bt = .05)

Run the code above in your browser using DataLab