R/generateAutoregressive.R

Defines functions .dataAR

.dataAR <- function(n, poisParam = 0.05, meanGap = 10, y0 = 10, gamma = .99, sdY = 1) {
  changepoints <- rpois(n, poisParam)
  cp = which(changepoints > 0)
  mu = cumsum(sample(c(-1, 1), size = n, replace = TRUE) * changepoints * rnorm(n, mean = meanGap))
  y <- .dataAR_c(gamma, y0, mu, rnorm(n, sd = sdY))$z
  return(list(y = y, cp = cp))
}

Try the DeCAFS package in your browser

Any scripts or data that you put into this service are public.

DeCAFS documentation built on Jan. 6, 2023, 5:27 p.m.