ivreg (version 0.5-0)

ivreg.fit: Fitting Instrumental-Variable Regressions by 2SLS

Description

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.

Usage

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

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.

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.

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.

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

Examples

Run this code
# NOT RUN {
## 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

# }

Run the code above in your browser using DataCamp Workspace