AR1 function

Autoregressive model of first order

Autoregressive model of first order

Generates time series from an AR1 model.

AR1(n, alpha, mean = 0, sd = 1)

Arguments

  • n: number of values
  • alpha: lag-1 autocorrelation
  • mean: mean
  • sd: standard deviation

Examples

library(CoSMoS) ## generate 500 values from an AR1 having lag-1 autocorrelation 0.8, ## mean value equal to 0, and standard deviation equal to 1. n <- 500 ## generate white noise for comparsion x <- rnorm(n) ggplot() + geom_line(aes(x = 1:n, y = x)) + labs(x = '', y = 'value') + theme_classic() ## generete values using AR1 y <- AR1(n, .8) ggplot() + geom_line(aes(x = 1:n, y = y)) + labs(x = '', y = 'value') + theme_classic()

Other functions in CoSMoS

Related functions from the same R package