Learn R Programming

wbsts (version 2.1)

sim.pw.ar: Simulation of a piecewise constant AR(1) model

Description

The function simulates a piecewise constant AR(1) model with multiple change-points

Usage

sim.pw.ar(N, sd_u, b.slope, br.loc)

Arguments

N

Length of the series.

sd_u

A vector of the innovation standard deviation for every segment.

b.slope

A vector of the AR(1) coefficients.

br.loc

A vector with the location of the change-points.

Value

A simulated series

Examples

Run this code
# NOT RUN {
cps=c(400,612)
y=sim.pw.ar(N =1024,sd_u = 1,b.slope=c(0.4,-0.6,0.5),br.loc=cps)[[2]]
ts.plot(y)
abline(v=cps,col="red")

# }

Run the code above in your browser using DataLab