| ivreg.fit | R Documentation | 
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(),
  ...
)
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: 
  | 
rlm.args | 
 a list of optional arguments to be passed to the   | 
... | 
 further arguments passed to   | 
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.
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   | 
offset | 
 either the offset used (if any) or   | 
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   | 
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   | 
endogenous | 
 columns of the   | 
instruments | 
 columns of the   | 
method | 
 the method used for the stage 1 and 2 regressions, one of   | 
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 
  | 
hatvalues | 
 a matrix of hatvalues. For   | 
ivreg, lm.fit, 
lm.wfit, rlm, mad
## 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.