ts.sim {changepointGA}R Documentation

Time series simulation with changepoint effects

Description

This is a function to simulate time series with changepoint effects. See details below.

Usage

ts.sim(
  beta,
  XMat,
  sigma,
  phi = NULL,
  theta = NULL,
  Delta = NULL,
  CpLoc = NULL,
  seed = NULL
)

Arguments

beta

A parameter vector contains other mean function parameters without changepoint parameters.

XMat

The covairates for time series mean function without changepoint indicators.

sigma

The standard deviation for time series residuals \epsilon_{t}.

phi

A vector for the autoregressive (AR) parameters for AR part.

theta

A vector for the moving average (MA) parameters for MA part.

Delta

The parameter vector contains the changepoint parameters for time series mean function.

CpLoc

A vector contains the changepoint locations range from 1\leq\tau\leq T_{s}.

seed

The random seed for simulation reproducibility.

Details

The simulated time series Z_{t}, t=1,\ldots,T_{s} is from a class of models,

Z_{t}=\mu_{t}+e_{t}.

Value

The simulated time series with attributes:

Z

The simulated time series.

Attributes
  • DesignX The covariates include all changepoint indicators.

  • mu A vector includes the mean values for simulated time series sequences.

  • theta The true parameter vector (including changepoint effects).

  • CpEff The true changepoint magnitudes.

  • CpLoc The true changepoint locations where we introduce the mean changing effects.

  • arEff A vector givies the AR coefficients.

  • maEff A vector givies the MA coefficients.

  • seed The random seed used for this simulation.

Examples

##### M1: Time series observations are IID
Ts = 1000
betaT = c(0.5) # intercept
XMatT = matrix(1, nrow=Ts, ncol=1)
colnames(XMatT) = "intercept"
sigmaT = 1
DeltaT = c(2, -2)
Cp.prop = c(1/4, 3/4)
CpLocT = floor(Ts*Cp.prop)

myts = ts.sim(beta=betaT, XMat=XMatT, sigma=sigmaT,
              Delta=DeltaT, CpLoc=CpLocT, seed=1234)
TsPlotCheck(Y=myts, tau=CpLocT)

##### M2: ARMA(2,1) model with constant mean
Ts = 1000
betaT = c(0.5) # intercept
XMatT = matrix(1, nrow=Ts, ncol=1)
colnames(XMatT) = "intercept"
sigmaT = 1
phiT = c(0.5, -0.5)
thetaT = c(0.8)
DeltaT = c(2, -2)
Cp.prop = c(1/4, 3/4)
CpLocT = floor(Ts*Cp.prop)

myts = ts.sim(beta=betaT, XMat=XMatT, sigma=sigmaT,
              phi=phiT, theta=thetaT, Delta=DeltaT, CpLoc=CpLocT, seed=1234)
TsPlotCheck(Y=myts, tau=CpLocT)

##### M3: ARMA(2,1) model with seasonality
Ts = 1000
betaT = c(0.5, -0.5, 0.3) # intercept, B, D
period = 30
XMatT = cbind(rep(1, Ts), cos(2*pi*(1:Ts)/period), sin(2*pi*(1:Ts)/period))
colnames(XMatT) = c("intercept", "Bvalue", "DValue")
sigmaT = 1
phiT = c(0.5, -0.5)
thetaT = c(0.8)
DeltaT = c(2, -2)
Cp.prop = c(1/4, 3/4)
CpLocT = floor(Ts*Cp.prop)

myts = ts.sim(beta=betaT, XMat=XMatT, sigma=sigmaT,
              phi=phiT, theta=thetaT, Delta=DeltaT, CpLoc=CpLocT, seed=1234)
TsPlotCheck(Y=myts, tau=CpLocT)


##### M4: ARMA(2,1) model with seasonality and trend
# scaled trend if large number of sample size
Ts = 1000
betaT = c(0.5, -0.5, 0.3, 0.01) # intercept, B, D, alpha
period = 30
XMatT = cbind(rep(1, Ts), cos(2*pi*(1:Ts)/period), sin(2*pi*(1:Ts)/period), 1:Ts)
colnames(XMatT) = c("intercept", "Bvalue", "DValue", "trend")
sigmaT = 1
phiT = c(0.5, -0.5)
thetaT = c(0.8)
DeltaT = c(2, -2)
Cp.prop = c(1/4, 3/4)
CpLocT = floor(Ts*Cp.prop)

myts = ts.sim(beta=betaT, XMat=XMatT, sigma=sigmaT,
              phi=phiT, theta=thetaT, Delta=DeltaT, CpLoc=CpLocT, seed=1234)
TsPlotCheck(Y=myts, tau=CpLocT)

[Package changepointGA version 0.1.1 Index]