Built using Zelig version

The release of Zelig 5.0 expands the set of models available, while simplifying the model wrapping process, and solving architectural problems by completely rewriting into R’s Reference Classes for a fully object-oriented architecture. Comparability wrappers are available so that you can still use pre-Zelig 5 syntax.

Zelig 5 uses reference classes which work a bit differently from what you may expect in R. The big difference is that they are “mutable”, i.e. assigning values to them does not overwrite the objects previous contents.

Zelig 5 workflow overview

All models in Zelig 5 can be estimated and results explored presented using a five simple steps:

  • Initialise the Zelig object, e.g with z.out <- zls$new(), for a least squares model. Then populate the object with:

  • zelig to estimate the parameters,

  • setx to set fitted values for which we want to find quantities of interest,

  • sim to simulate the quantities of interest,

  • graph to plot the simulation results.

Here is an example workflow with Zelig 5:

z5 <- zls$new()
z5$zelig(Y ~ X1 + X ~ X, weights = w, data = mydata)


Here is the same set of operations as above using the Zelig 4 wrappers:

z.out <- zelig(Y ~ X1 + X2, model = "ls", weights = w, data = mydata)
x.out <- setx(z.out)
s.out <- sim(z.out, x = x.out)

Note that all of the output objects from the Zelig 4 wrappers are Zelig 5 reference class objects, so you can mix and match which syntax you like.

Also note that when using the Zelig 5 methods for a range of fitted values you will need to use setrange rather than setx. For first differences you will need to call $setx1 after $setx. Because of this, using the setx compatibility wrapper can be more straightforward.