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)
Time-Series Model with Autoregressive Disturbance with ar
.
Warning: Simulation is not currently implemented for ar
models.
Currently, only the Zelig 5 reference class syntax is available for ar
models:
z.out <- zelig(Y ~ X1 + X2, model = "ar", data = mydata) setx(z.out) # sim(z.out) # Not yet implemented
Zelig accepts the following additional inputs for ar
to specify variables that provide the time index and any cross-sectional element if there are multiple time-series in the same dataset:
ts
: Name of a variable that denotes the time element of the data. As a variable name, this should be in quotes. If this is not provided, Zelig will assume that the data is already ordered by time, but if provided, the dataset will be sorted by this variable before estimation.
cs
: Name of a variable that denotes the cross-sectional element of the data, for example, country name in a dataset with time-series across different countries. As a variable name, this should be in quotes. If this is not provided, Zelig will assume that all observations come from the same unit over time, and should be pooled, but if provided, individual models will be run in each cross-section. If cs
is given as an argument, ts
must also be provided.
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 = "ar", data = subset)
Summarize estimated model parameters:
summary(ts.out)
The estimator used for AR 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(ar)
.
z5 <- zar$new() z5$references()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.