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).

ivreg.fit(
  x,
  y,
  z,
  weights,
  offset,
  method = c("OLS", "M", "MM"),
  rlm.args = list(),
  ...
)

Arguments

x

regressor matrix.

y

vector for the response 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.

method

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.

rlm.args

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.

Value

ivreg.fit returns an unclassed list with the following components:

coefficients

parameter estimates, from the stage-2 regression.

residuals

vector of model residuals.

residuals1

matrix of residuals from the stage-1 regression.

residuals2

vector of residuals from the stage-2 regression.

fitted.values

vector of predicted means for the response.

weights

either the vector of weights used (if any) or NULL (if none).

offset

either the offset used (if any) or NULL (if none).

estfun

a matrix containing the empirical estimating functions.

n

number of observations.

nobs

number of observations with non-zero weights.

p

number of columns in the model matrix x of regressors.

q

number of columns in the instrumental variables model matrix z

rank

numeric rank of the model matrix for the stage-2 regression.

df.residual

residual degrees of freedom for fitted model.

cov.unscaled

unscaled covariance matrix for the coefficients.

sigma

residual standard error; when method is "M" or "MM", this is based on the MAD of the residuals (around 0) — see mad.

x

projection of x matrix onto span of z.

qr

QR decomposition for the stage-2 regression.

qr1

QR decomposition for the stage-1 regression.

rank1

numeric rank of the model matrix for the stage-1 regression.

coefficients1

matrix of coefficients from the stage-1 regression.

df.residual1

residual degrees of freedom for the stage-1 regression.

exogenous

columns of the "regressors" matrix that are exogenous.

endogenous

columns of the "regressors" matrix that are endogenous.

instruments

columns of the "instruments" matrix that are instruments for the endogenous variables.

method

the method used for the stage 1 and 2 regressions, one of "OLS", "M", or "MM".

rweights

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".

hatvalues

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.

Details

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.

See also

ivreg, lm.fit, lm.wfit, rlm, mad

Examples

## 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