knitr::opts_chunk$set( fig.path = "man/figures/README-" )
An implementation of instrumental variables regression using two-stage least-squares
(2SLS) estimation, based on the ivreg()
function previously in the
AER package. In addition to standard regression
functionality (parameter estimation, inference, predictions, etc.) the package provides
various regression diagnostics, including hat values, deletion diagnostics such as
studentized residuals and Cook's distances; graphical diagnostics such as
component-plus-residual plots and added-variable plots; and effect plots with partial
residuals.
Instrumental variables regression:
library("ivreg") ivreg(Q ~ P + D | D + F + A, data = Kmenta)
Via two-stage least squares (2SLS):
exams::tex2image("\\begin{eqnarray*} y & = & X \\beta + \\varepsilon \\\\ \\widehat{X} & = & Z (Z^\\top Z)^{-1} Z^\\top X \\\\ \\widehat{\\beta}_{\\mathrm{2SLS}} & = & (\\widehat{X}^\\top \\widehat{X})^{-1} \\widehat{X}^\\top y \\end{eqnarray*}", format = "svg", header = "", pt = 14, dir = file.path(getwd(), "man", "figures"), name = "README-2sls")
With diagnostics:
library("ivreg") library("effects") library("car") deq <- ivreg(Q ~ P + D | D + F + A, data = Kmenta) plot(predictorEffect("P", deq, residuals = TRUE), partial.residuals = list(span = 1))
qqPlot(deq, main = "QQ plot") ## mtext("QQ plot", line = 1.5, cex = 1.2, font = 2)
influencePlot(deq, main = "") mtext("Influence plot", line = 2, cex = 1.2, font = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.