Instrumental-Variable Regression

## Arguments

formula a symbolic representation of the model to be estimated, in the form y ~ x1 + x2, where y is the dependent variable and x1 and x2 are the explanatory variables, and y, x1, and x2 are contained in the same dataset. (You may include more than two explanatory variables, of course.) The + symbol means inclusion'' notaddition.'' You may also include interaction terms and main effects in the form x1*x2 without computing them in prior steps; I(x1*x2) to include only the interaction term and exclude the main effects; and quadratic terms in the form I(x1^2). the name of a statistical model to estimate. For a list of other supported models and their documentation see: http://docs.zeligproject.org/articles/. the name of a data frame containing the variables referenced in the formula or a list of multiply imputed data frames each having the same variable names and row numbers (created by Amelia or to_zelig_mi). additional arguments passed to zelig, relevant for the model to be estimated. a factor variable contained in data. If supplied, zelig will subset the data frame based on the levels in the by variable, and estimate a model for each subset. This can save a considerable amount of effort. You may also use by to run models using MatchIt subclasses. If is set to 'TRUE' (default), the model citation will be printed to the console. specification(s) of the regression relationship the instruments. Either instruments is missing and formula has three parts as in y ~ x1 + x2 | z1 + z2 + z3 (recommended) or formula is y ~ x1 + x2 and instruments is a one-sided formula ~ z1 + z2 + z3. Using instruments is not recommended with zelig. logicals. If TRUE the corresponding components of the fit (the model frame, the model matrices , the response) are returned. further arguments passed to methods. See also zelig.

## Source

ivreg is from Christian Kleiber and Achim Zeileis (2008). Applied Econometrics with R. New York: Springer-Verlag. ISBN 978-0-387-77316-2. URL https://CRAN.R-project.org/package=AER

## Value

Depending on the class of model selected, zelig will return an object with elements including coefficients, residuals, and formula which may be summarized using summary(z.out) or individually extracted using, for example, coef(z.out). See http://docs.zeligproject.org/articles/getters.html for a list of functions to extract model components. You can also extract whole fitted model objects using from_zelig_model.

## Details

Additional parameters avaialable to many models include:

Regressors and instruments for ivreg are most easily specified in a formula with two parts on the right-hand side, e.g., y ~ x1 + x2 | z1 + z2 + z3, where x1 and x2 are the regressors and z1, z2, and z3 are the instruments. Note that exogenous regressors have to be included as instruments for themselves. For example, if there is one exogenous regressor ex and one endogenous regressor en with instrument in, the appropriate formula would be y ~ ex + en | ex + in. Equivalently, this can be specified as y ~ ex + en | . - en + in, i.e., by providing an update formula with a . in the second part of the formula. The latter is typically more convenient, if there is a large number of exogenous regressors.

## Methods

zelig(formula, data, model = NULL, ..., weights = NULL, by, bootstrap = FALSE)

The zelig function estimates a variety of statistical models

Vignette: http://docs.zeligproject.org/articles/zelig_ivreg.html Fit instrumental-variable regression by two-stage least squares. This is equivalent to direct instrumental-variables estimation when the number of instruments is equal to the number of predictors. zelig, Greene, W. H. (1993) Econometric Analysis, 2nd ed., Macmillan.

## Examples

library(Zelig)
library(dplyr) # for the pipe operator %>%
data("CigarettesSW")
CigarettesSW$rprice <- with(CigarettesSW, price/cpi) CigarettesSW$rincome <- with(CigarettesSW, income/population/cpi)
CigarettesSW$tdiff <- with(CigarettesSW, (taxs - tax)/cpi) # log second stage independent variables, as logging internally for ivreg is # not currently supported CigarettesSW$log_rprice <- log(CigarettesSW$rprice) CigarettesSW$log_rincome <- log(CigarettesSW$rincome) z.out1 <- zelig(log(packs) ~ log_rprice + log_rincome | log_rincome + tdiff + I(tax/cpi),data = CigarettesSW, subset = year == "1995",model = "ivreg")#> Error in eval(substitute(subset), data, env): object 'year' not foundsummary(z.out1)#> Error in summary(z.out1): object 'z.out1' not foundlibrary(Zelig) library(AER) # for sandwich vcov library(dplyr) # for the pipe operator %>% # load and transform data data("CigarettesSW") CigarettesSW$rprice <- with(CigarettesSW, price/cpi)
CigarettesSW$rincome <- with(CigarettesSW, income/population/cpi) CigarettesSW$tdiff <- with(CigarettesSW, (taxs - tax)/cpi)

# log second stage independent variables, as logging internally for ivreg is
# not currently supported
CigarettesSW$log_rprice <- log(CigarettesSW$rprice)
CigarettesSW$log_rincome <- log(CigarettesSW$rincome)

# estimate model
z.out1 <- zelig(log(packs) ~ log_rprice + log_rincome |
log_rincome + tdiff + I(tax/cpi),
data = CigarettesSW,
model = "ivreg")#> How to cite this model in Zelig:
#>   Christian Kleiber and Achim Zeileis. 2008.
#>   ivreg: Instrumental-Variable Regression
#>   in Christine Choirat, Christopher Gandrud, James Honaker, Kosuke Imai, Gary King, and Olivia Lau,
#>   "Zelig: Everyone's Statistical Software," http://zeligproject.org/summary(z.out1)#> Model:
#>
#> Call:
#> z5\$zelig(formula = formula, data = data, by = by)
#>
#> Residuals:
#>     Min      1Q  Median      3Q     Max
#> -0.6138 -0.0723  0.0144  0.0949  0.3750
#>
#> Coefficients:
#>             Estimate Std. Error t value Pr(>|t|)
#> (Intercept)    9.736      0.569   17.12  < 2e-16
#> log_rprice    -1.229      0.155   -7.92  4.9e-12
#> log_rincome    0.257      0.143    1.79    0.077
#>
#> Residual standard error: 0.165 on 93 degrees of freedom
#> Multiple R-Squared: 0.549,	Adjusted R-squared: 0.539
#> Wald test: 39.9 on 2 and 93 DF,  p-value: 3.02e-13
#>
#> Next step: Use 'setx' method