R/ivreg.fit.R
ivreg.fit.Rd
Fit instrumental-variable regression by two-stage least squares (2SLS). This is equivalent to direct instrumental-variables estimation when the number of instruments is equal to the number of predictors. Alternative robust-regression estimation is also supported, based on M-estimation (22M) or MM-estimation (2SMM).
regressor matrix.
vector for the response variable.
instruments matrix.
an optional vector of weights to be used in the fitting process.
an optional offset that can be used to specify an a priori known component to be included during fitting.
the method used to fit the stage 1 and 2 regression:
"OLS"
for traditional 2SLS regression (the default),
"M"
for M-estimation, or "MM"
for MM-estimation, with the
latter two robust-regression methods implemented via the rlm
function in the MASS package.
a list of optional arguments to be passed to the rlm
function in the MASS package if robust regression is used for the stage 1 and 2 regressions.
further arguments passed to lm.fit
or lm.wfit
, respectively.
ivreg.fit
returns an unclassed list with the following
components:
parameter estimates, from the stage-2 regression.
vector of model residuals.
matrix of residuals from the stage-1 regression.
vector of residuals from the stage-2 regression.
vector of predicted means for the response.
either the vector of weights used (if any) or NULL
(if none).
either the offset used (if any) or NULL
(if none).
a matrix containing the empirical estimating functions.
number of observations.
number of observations with non-zero weights.
number of columns in the model matrix x of regressors.
number of columns in the instrumental variables model matrix z
numeric rank of the model matrix for the stage-2 regression.
residual degrees of freedom for fitted model.
unscaled covariance matrix for the coefficients.
residual standard error; when method is "M"
or "MM"
, this
is based on the MAD of the residuals (around 0) — see mad
.
projection of x matrix onto span of z.
QR decomposition for the stage-2 regression.
QR decomposition for the stage-1 regression.
numeric rank of the model matrix for the stage-1 regression.
matrix of coefficients from the stage-1 regression.
residual degrees of freedom for the stage-1 regression.
columns of the "regressors"
matrix that are exogenous.
columns of the "regressors"
matrix that are endogenous.
columns of the "instruments"
matrix that are
instruments for the endogenous variables.
the method used for the stage 1 and 2 regressions, one of "OLS"
,
"M"
, or "MM"
.
a matrix of robustness weights with columns for each of the stage-1
regressions and for the stage-2 regression (in the last column) if the fitting method is
"M"
or "MM"
, NULL
if the fitting method is "OLS"
.
a matrix of hatvalues. For method = "OLS"
, the matrix consists of two
columns, for each of the stage-1 and stage-2 regression; for method = "M"
or "MM"
,
there is one column for each stage-1 regression and for the stage-2 regression.
ivreg
is the high-level interface to the work-horse function
ivreg.fit
. ivreg.fit
is essentially a convenience interface to
lm.fit
(or lm.wfit
)
for first projecting x
onto the image of
z
, then running a regression of y
on the projected
x
, and computing the residual standard deviation.
## data
data("CigaretteDemand", package = "ivreg")
## high-level interface
m <- ivreg(log(packs) ~ log(rprice) + log(rincome) | salestax + log(rincome),
data = CigaretteDemand)
## low-level interface
y <- m$y
x <- model.matrix(m, component = "regressors")
z <- model.matrix(m, component = "instruments")
ivreg.fit(x, y, z)$coefficients
#> (Intercept) log(rprice) log(rincome)
#> 9.4306583 -1.1433751 0.2145153