Zelig 5.1–1: New Website, zeligverse, Instrumental Variables Regression, Formula Updating, and More!

Zelig version 5.1–1 is now available for download from CRAN!

New website

Perhaps the flashiest change is a new website for Zelig’s documentation: http://docs.zeligproject.org/

This site is your first port of call for detailed information about Zelig.

More important than being shiny and new, the website is constructed with Hadley Wickham’s pkgdown tool for documenting R packages. This should make the documentation’s examples more robust and easier to maintain and easier.

Please send us any feedback you have on how to make the site more useful.

zeligverse

Most Zelig models are in the core Zelig package. However, a number of models are in other packages that you need to install separately from CRAN. This includes ZeligChoice for a range of categorical outcome models and ZeligEI for ecological inference.

The main reason that Zelig is split into multiple packages is to ensure that it is robust to breaking changes in its models’ package dependencies. For example, if the eiPack package underlying ecological inference models breaks, you can still load all non-EI models, because they are in separate packages.

However, as a user you don’t really need to think about this. Separately installing multiple packages and remembering which model is in which package is a pain.

So we’ve simplified the process with a new package (now on CRAN) called zeligverse.

When you install zeligverse

install.packages("zeligverse")

the package installs all of the stable Zelig packages (if they aren’t already installed.

When you load zeligverse

library(zeligverse)

all of the Zelig packages will be loaded. You can also still load each Zelig package separately.

In the near future, we intend to expand the number of packages in zeligverse. The Amelia, MatchIt, and WhatIf packages will be included. This will allow you to easily install and load all of the packages you need for a full Zelig workflow:

Imai, King, and Lau (2009, 30)

Instrumental variable regression

Due to popular demand we’ve added instrumental variable (two-stage least squares) regression to Zelig. You can access it in a zelig call by setting model = ivreg. It uses | syntax to separate the first and second stage equations. For example:

z.out <- zelig(Y ~ X1 + X2 | Z1 + Z2 + Z3, model = "ivreg", 
data = mydata)

Where X1 and X2 are the regressors (in the second stage) and Z1, Z2, and Z3 are the instruments (in the first stage).

One caveat: if you want to log (or otherwise transform) regressors, you need to do this before estimating the model. Imagine, we have a data set called CigarettesSW and it has two regressors that we want to natural log transform — rprice and rincome. First transform the variables:

library(zeligverse)
data("CigarettesSW")
CigarettesSW$log_rprice <- log(CigarettesSW$rprice)
CigarettesSW$log_rincome <- log(CigarettesSW$rincome)

Then estimate the model:

z.out1 <- zelig(log(packs) ~ log_rprice + log_rincome |
log_rincome + tdiff + I(tax/cpi),
data = CigarettesSW,
model = "ivreg")

(We intend to support variable transformations in the zelig call for ivreg in a future version.)

Formula updating and more

You can now update your model estimation formulas using R’s update function and also its dot notation. update allows you to add variables to a model sequentially without having to retype the whole formula.

For example:

library(zeligverse)
data(tobin)

# define model implicitly
controls <- ~ quant
z.out <- zelig(formula = update(controls, durable ~ age + .),
data = tobin, model = "tobit")

In this example, the quant variable is added to the formula at the position of the “.”.

For all model types (other than ivreg) you can now make arbitrary log transformations (e.g. log2(x)) and arbitrary factor calls within the zelig model call.

Please see the Zelig NEWS for lots of other updates and improvements.

As always, we would love to hear your feedback on what we can improve in future versions. Give us a shout on GitHub (for reporting bugs and feature requests) and Google Groups (for general questions).

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.