Built using Zelig version r packageVersion("Zelig")

knitr::opts_knit$set(
    stop_on_error = 2L
)
knitr::opts_chunk$set(
    fig.height = 11,
    fig.width = 7
)

options(cite = FALSE)

++++ All Zelig time series models will be deprecated on 1 February 2018 ++++

Autoregressive and Moving-Average Models with Integration for Time-Series Data

Syntax

z.out <- zarima$new()
z.out$zelig(Y ~ X1 + X2, order = c(1, 0, 0), data = mydata)
x.out$setx(z.out)
s.out$sim(z.out)

Additional Inputs

Zelig accepts the following additional inputs for arima to specify variables that provide the time index and any cross-sectional element if there are multiple time-series in the same dataset:

Examples

Single Series

rm(list=ls(pattern="\\.out"))
suppressWarnings(suppressMessages(library(Zelig)))
set.seed(1234)

Attach sample data, which has left party seat share and unemployment across time in several countries. We will subset to just those observations from the United Kingdom:

data(seatshare)
subset <- seatshare[seatshare$country == "UNITED KINGDOM",]

Estimate model:

ts.out <- zelig(unemp ~ leftseat, model = 'arima', order = c(1, 0, 1), data = subset)

Summarize estimated model parameters:

summary(ts.out)

Next we simulate what happens when leftseat share drops from a moderately high level of 75 percent, to a rather low level of 25 percent:

ts.out <- setx(ts.out, leftseat = 0.75)
ts.out <- setx1(ts.out, leftseat = 0.25)
ts.out <- sim(ts.out)
plot(ts.out)

AR and MA Models

AR (Autoregressive) and MA (Moving Average) models are commonly used in time series analysis. As both AR and MA models are special cases of ARIMA models they are not implemented as separate models within Zelig. Specification of AR and MA models can be accomplished by changing the value of the order parameter within the ARIMA model.

AR

ts.out <- zelig(unemp ~ leftseat, model = "arima", order = c(1, 0, 0), data = subset)

MA

ts.out <- zelig(unemp ~ leftseat, model = "arima", order = c(0, 0, 1), data = subset)

Multiple Series

The dataset contains similar series for 11 different OECD countries, and we could run the same model on each country's data. Here we need to specify the ts and cs arguments to identify the names of variables that give the time and cross-section of each observation in the dataset

ts.out2 <- zelig(unemp ~ leftseat, model="arima", order = c(1,0,1), ts = "year",
              cs = "country", data = seatshare)
summary(ts.out2)

See Also

The estimator used for ARIMA models is part of the stats package by William N. Venables and Brian D. Ripley .In addition, advanced users may wish to refer to help(arima).

z5 <- zarima$new()
z5$references()


IQSS/Zelig documentation built on Dec. 11, 2023, 1:51 a.m.