dataRWAR: Generate a Random Walk + AR realization

View source: R/generateRWAR.R

dataRWARR Documentation

Generate a Random Walk + AR realization

Description

Generate a Realization from the RWAR model (check the references for further details).

y_t = μ_t + ε_t

where

μ_t = μ_{t-1} + η_t + δ_t, \quad η_t \sim N(0, σ_η^2), \ δ_t \ \in R

and

ε_t = φ ε_{t-1} + ν_t \quad ν_t \sim N(0, σ_ν^2)

Usage

dataRWAR(
  n = 1000,
  sdEta = 0,
  sdNu = 1,
  phi = 0,
  type = c("none", "up", "updown", "rand1"),
  nbSeg = 20,
  jumpSize = 1
)

Arguments

n

The length of the sequence of observations.

sdEta

The standard deviation of the Random Walk Component on the signal drift

sdNu

The standard deviation of the Autocorrelated noise

phi

The autocorrelation parameter φ

type

Possible change scenarios for the jump structure (default: none)

nbSeg

Number of segments

jumpSize

Maximum magnitude of a change

Value

A list containing:

y

the data sequence,

signal

the underlying signal without the superimposed AR(1) noise,

changepoints

the changepoint locations

References

Romano, G., Rigaill, G., Runge, V., Fearnhead, P. Detecting Abrupt Changes in the Presence of Local Fluctuations and Autocorrelated Noise. arXiv preprint https://arxiv.org/abs/2005.01379 (2020).

Examples

library(ggplot2)
set.seed(42)
Y = dataRWAR(n = 1e3, phi = .5, sdEta = 3, sdNu = 1, jumpSize = 15, type = "updown", nbSeg = 5)
y = Y$y
ggplot(data.frame(t = 1:length(y), y), aes(x = t, y = y)) +
  geom_point() +
  geom_vline(xintercept = Y$changepoints, col = 4,  lty = 3)

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