Summary method, including Wald tests and (by default) certain diagnostic tests, for
"ivreg"
model objects, as well as other related inference functions.
# S3 method for class 'ivreg'
confint(
object,
parm,
level = 0.95,
component = c("stage2", "stage1"),
complete = TRUE,
vcov. = NULL,
df = NULL,
...
)
# S3 method for class 'ivreg'
summary(object, vcov. = NULL, df = NULL, diagnostics = NULL, ...)
# S3 method for class 'summary.ivreg'
print(
x,
digits = max(3, getOption("digits") - 3),
signif.stars = getOption("show.signif.stars"),
...
)
# S3 method for class 'ivreg'
anova(object, object2, test = "F", vcov. = NULL, ...)
# S3 method for class 'ivreg'
Anova(mod, test.statistic = c("F", "Chisq"), vcov. = NULL, ...)
# S3 method for class 'ivreg'
linearHypothesis(
model,
hypothesis.matrix,
rhs = NULL,
test = c("F", "Chisq"),
vcov. = NULL,
...
)
An object of class "ivreg"
.
parameters for which confidence intervals are to be computed; a vector or numbers or names; the default is all parameters.
confidence level; the default is 0.95
.
Character indicating "stage2"
or "stage1"
.
If TRUE
, the default, the returned coefficient vector (for coef
) or coefficient-covariance matrix (for vcov
) includes elements for aliased regressors.
Optionally either a coefficient covariance matrix or a function to compute such a covariance
matrix from fitted ivreg
model objects. If NULL
(the default) the standard covariance matrix
(based on the information matrix) is used. Alternatively, covariance matrices (e.g., clustered and/or
heteroscedasticity-consistent) can be plugged in to adjust Wald tests or confidence intervals etc.
In summary
, if diagnostics = TRUE
, vcov.
must be a function (not a matrix) because
the alternative covariances are also needed for certain auxiliary models in the diagnostic tests.
If vcov.
is a function, the ...
argument can be used to pass on further arguments to
this function.
For summary
, optional residual degrees of freedom to use in computing model summary.
arguments to pass down.
Report 2SLS "diagnostic" tests in model summary (default is TRUE
).
These tests are not to be confused with the regression diagnostics provided elsewhere in the ivreg
package: see ivregDiagnostics
.
An object of class "summary.ivreg"
.
Minimal number of significant digits for printing.
Show "significance stars" in summary output?
Test statistics for ANOVA table computed by anova
, Anova
,
or linearHypothesis
. Only test = "F"
is supported by anova
; this is also
the default for Anova
and linearHypothesis
, which also allow test = "Chisq"
for
asymptotic tests.
For formulating a linear hypothesis; see the documentation
for linearHypothesis
for details.
## data and model
data("CigaretteDemand", package = "ivreg")
m <- ivreg(log(packs) ~ log(rincome) | log(rprice) | salestax, data = CigaretteDemand)
## summary including diagnostics
summary(m)
#>
#> Call:
#> ivreg(formula = log(packs) ~ log(rincome) | log(rprice) | salestax,
#> data = CigaretteDemand)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -0.611000 -0.086072 0.009423 0.106912 0.393159
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 9.4307 1.3584 6.943 1.24e-08 ***
#> log(rprice) -1.1434 0.3595 -3.181 0.00266 **
#> log(rincome) 0.2145 0.2686 0.799 0.42867
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Residual standard error: 0.1896 on 45 degrees of freedom
#> Multiple R-Squared: 0.4189, Adjusted R-squared: 0.3931
#> Wald test: 6.534 on 2 and 45 DF, p-value: 0.003227
#>
## replicate global F test from summary (against null model) "by hand"
m0 <- ivreg(log(packs) ~ 1, data = CigaretteDemand)
anova(m0, m)
#> Analysis of Variance Table
#>
#> Model 1: log(packs) ~ 1
#> Model 2: log(packs) ~ log(rprice) + log(rincome) | salestax + log(rincome)
#> Res.Df RSS Df Sum of Sq F Pr(>F)
#> 1 47 2.7832
#> 2 45 1.6172 2 1.166 6.5337 0.003227 **
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
## or via linear hypothesis test
car::linearHypothesis(m, c("log(rincome)", "log(rprice)"))
#>
#> Linear hypothesis test:
#> log(rincome) = 0
#> log(rprice) = 0
#>
#> Model 1: restricted model
#> Model 2: log(packs) ~ log(rprice) + log(rincome) | salestax + log(rincome)
#>
#> Res.Df Df F Pr(>F)
#> 1 47
#> 2 45 2 6.5337 0.003227 **
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
## confidence intervals
confint(m)
#> 2.5 % 97.5 %
#> (Intercept) 6.6947684 12.1665482
#> log(rprice) -1.8674172 -0.4193330
#> log(rincome) -0.3264423 0.7554729
## just the Wald tests for the coefficients
library("lmtest")
coeftest(m)
#>
#> t test of coefficients:
#>
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 9.43066 1.35837 6.9426 1.239e-08 ***
#> log(rprice) -1.14338 0.35949 -3.1806 0.002662 **
#> log(rincome) 0.21452 0.26858 0.7987 0.428667
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
## plug in a heteroscedasticity-consistent HC1 covariance matrix (from sandwich)
library("sandwich")
## - as a function passing additional type argument through ...
coeftest(m, vcov = vcovHC, type = "HC1")
#>
#> t test of coefficients:
#>
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 9.43066 1.25939 7.4883 1.935e-09 ***
#> log(rprice) -1.14338 0.37230 -3.0711 0.003611 **
#> log(rincome) 0.21452 0.31175 0.6881 0.494917
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
## - as a function without additional arguments
hc1 <- function(object, ...) vcovHC(object, type = "HC1", ...)
coeftest(m, vcov = hc1)
#>
#> t test of coefficients:
#>
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 9.43066 1.25939 7.4883 1.935e-09 ***
#> log(rprice) -1.14338 0.37230 -3.0711 0.003611 **
#> log(rincome) 0.21452 0.31175 0.6881 0.494917
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
## - as a matrix
vc1 <- vcovHC(m, type = "HC1")
coeftest(m, vcov = vc1)
#>
#> t test of coefficients:
#>
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 9.43066 1.25939 7.4883 1.935e-09 ***
#> log(rprice) -1.14338 0.37230 -3.0711 0.003611 **
#> log(rincome) 0.21452 0.31175 0.6881 0.494917
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
## in summary() with diagnostics = TRUE use one of the function specifications,
## the matrix is only possible when diagnostics = FALSE
summary(m, vcov = vcovHC, type = "HC1") ## function + ...
#>
#> Call:
#> ivreg(formula = log(packs) ~ log(rincome) | log(rprice) | salestax,
#> data = CigaretteDemand)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -0.611000 -0.086072 0.009423 0.106912 0.393159
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 9.4307 1.3538 6.966 1.15e-08 ***
#> log(rprice) -1.1434 0.4032 -2.836 0.00682 **
#> log(rincome) 0.2145 0.3319 0.646 0.52137
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Residual standard error: 0.1896 on 45 degrees of freedom
#> Multiple R-Squared: 0.4189, Adjusted R-squared: 0.3931
#> Wald test: 7.262 on 2 and 45 DF, p-value: 0.001848
#>
summary(m, vcov = hc1) ## function
#>
#> Call:
#> ivreg(formula = log(packs) ~ log(rincome) | log(rprice) | salestax,
#> data = CigaretteDemand)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -0.611000 -0.086072 0.009423 0.106912 0.393159
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 9.4307 1.2594 7.488 1.93e-09 ***
#> log(rprice) -1.1434 0.3723 -3.071 0.00361 **
#> log(rincome) 0.2145 0.3117 0.688 0.49492
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Residual standard error: 0.1896 on 45 degrees of freedom
#> Multiple R-Squared: 0.4189, Adjusted R-squared: 0.3931
#> Wald test: 8.191 on 2 and 45 DF, p-value: 0.0009254
#>
summary(m, vcov = vc1, diagnostics = FALSE) ## matrix
#>
#> Call:
#> ivreg(formula = log(packs) ~ log(rincome) | log(rprice) | salestax,
#> data = CigaretteDemand)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -0.611000 -0.086072 0.009423 0.106912 0.393159
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 9.4307 1.2594 7.488 1.93e-09 ***
#> log(rprice) -1.1434 0.3723 -3.071 0.00361 **
#> log(rincome) 0.2145 0.3117 0.688 0.49492
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Residual standard error: 0.1896 on 45 degrees of freedom
#> Multiple R-Squared: 0.4189, Adjusted R-squared: 0.3931
#> Wald test: 8.191 on 2 and 45 DF, p-value: 0.0009254
#>
## in confint() and anova() any of the three specifications can be used
anova(m0, m, vcov = vcovHC, type = "HC1") ## function + ...
#> Wald test
#>
#> Model 1: log(packs) ~ 1
#> Model 2: log(packs) ~ log(rprice) + log(rincome) | salestax + log(rincome)
#> Res.Df Df F Pr(>F)
#> 1 47
#> 2 45 2 7.262 0.001848 **
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
anova(m0, m, vcov = hc1) ## function
#> Wald test
#>
#> Model 1: log(packs) ~ 1
#> Model 2: log(packs) ~ log(rprice) + log(rincome) | salestax + log(rincome)
#> Res.Df Df F Pr(>F)
#> 1 47
#> 2 45 2 8.1911 0.0009254 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
anova(m0, m, vcov = vc1) ## matrix
#> Wald test
#>
#> Model 1: log(packs) ~ 1
#> Model 2: log(packs) ~ log(rprice) + log(rincome) | salestax + log(rincome)
#> Res.Df Df F Pr(>F)
#> 1 47
#> 2 45 2 8.1911 0.0009254 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1