ivreg | R Documentation |
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.
ivreg(formula, instruments, data, subset, na.action, weights, offset,
contrasts = NULL, model = TRUE, y = TRUE, x = FALSE, ...)
formula , instruments |
formula specification(s) of the regression
relationship and the instruments. Either |
data |
an optional data frame containing the variables in the model.
By default the variables are taken from the environment of the |
subset |
an optional vector specifying a subset of observations to be used in fitting the model. |
na.action |
a function that indicates what should happen when the
data contain |
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. |
contrasts |
an optional list. See the |
model , x , y |
logicals. If |
... |
further arguments passed to |
ivreg
is the high-level interface to the work-horse function ivreg.fit
,
a set of standard methods (including print
, summary
, vcov
, anova
,
hatvalues
, predict
, terms
, model.matrix
, bread
,
estfun
) is available and described on summary.ivreg
.
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.
ivreg
returns an object of class "ivreg"
, with the following components:
coefficients |
parameter estimates. |
residuals |
a vector of residuals. |
fitted.values |
a vector of predicted means. |
weights |
either the vector of weights used (if any) or |
offset |
either the offset used (if any) or |
n |
number of observations. |
nobs |
number of observations with non-zero weights. |
rank |
the numeric rank of the fitted linear model. |
df.residual |
residual degrees of freedom for fitted model. |
cov.unscaled |
unscaled covariance matrix for the coefficients. |
sigma |
residual standard error. |
call |
the original function call. |
formula |
the model formula. |
terms |
a list with elements |
levels |
levels of the categorical regressors. |
contrasts |
the contrasts used for categorical regressors. |
model |
the full model frame (if |
y |
the response vector (if |
x |
a list with elements |
Greene, W. H. (1993) Econometric Analysis, 2nd ed., Macmillan.
ivreg.fit
, lm
, lm.fit
## data
data("CigarettesSW", package = "AER")
CigarettesSW <- transform(CigarettesSW,
rprice = price/cpi,
rincome = income/population/cpi,
tdiff = (taxs - tax)/cpi
)
## model
fm <- ivreg(log(packs) ~ log(rprice) + log(rincome) | log(rincome) + tdiff + I(tax/cpi),
data = CigarettesSW, subset = year == "1995")
summary(fm)
summary(fm, vcov = sandwich, df = Inf, diagnostics = TRUE)
## ANOVA
fm2 <- ivreg(log(packs) ~ log(rprice) | tdiff, data = CigarettesSW, subset = year == "1995")
anova(fm, fm2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.