Learn R Programming

AER (version 0.2-2)

ivreg.fit: Fitting Intrumental-Variable Regressions

Description

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.

Usage

ivreg.fit(x, y, z, weights, offset, ...)

Arguments

x
regressor matrix.
y
vector with dependet variable.
z
instruments matrix.
weights
an optional vector of weights to be used in the fitting process.
offset
an optional offset that can be used to specify an a priori known component to be included during fitting.
...
further arguments passed to lm.fit or link[stats]{lm.wfit}, respectively.

Value

  • ivreg.fit returns an unclassed list with the following components:
  • coefficientsparameter estimates.
  • residualsa vector of residuals.
  • fitted.valuesa vector of predicted means.
  • weightseither the vector of weights used (if any) or NULL (if none).
  • offseteither the offset used (if any) or NULL (if none).
  • estfuna matrix containing the empirical estimating functions.
  • nnumber of observations.
  • rankthe numeric rank of the fitted linear model.
  • df.residualresidual degrees of freedom for fitted model.
  • cov.unscaledunscaled covariance matrix for the coefficients.
  • sigmaresidual standard error.
  • hatvaluesregression hat values.

Details

ivreg is the high-level interface to the work-horse function ivreg.fit, a set of standard methods (including summary, vcov, anova, hatvalues, predict, terms, model.matrix, bread, estfun) is available and described on summary.ivreg. ivreg.fit is a convenience interface to lm.fit (or lm.wfit) for first projecting x onto the image of z and the running a regression of y onto the projected x.

See Also

ivreg, lm.fit

Examples

Run this code
## data
data("CigarettesSW")
CigarettesSW$rprice <- with(CigarettesSW, price/cpi)
CigarettesSW$rincome <- with(CigarettesSW, income/population/cpi)
CigarettesSW$tdiff <- with(CigarettesSW, (taxs - tax)/cpi)

## high-level interface
fm <- ivreg(log(packs) ~ log(rprice) + log(rincome) | log(rincome) + tdiff + I(tax/cpi),
  data = CigarettesSW, subset = year == "1995")

## low-level interface
y <- fm$y
x <- model.matrix(fm)
z <- model.matrix(fm, component = "instruments")
ivreg.fit(x, y, z)$coefficients

Run the code above in your browser using DataLab