coeftestIV: Coefficient test of output of ivreg.EX.

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/coeftestIV.R

Description

For a given set of endogenous variables in an instrumental variables model coeftestIV provides you the coefficients matrix with estimates, std errs, t-ratios and p-values for both homoscedastic and heteroscedastic errors. Also, clustered standard error can be calculated.

Usage

1
coeftestIV(ivregfit, lmfit, vars, cls = NULL, vcov)

Arguments

ivregfit

An object of class 'ivregEX', an output of ivreg.EX or ivreg.fit.Ex function.

lmfit

An object of class 'lm', an output of lmfit or lm function.

vars

A vector of endogenous variables of the instrumental variables model for which the standard error calculation and significance test to be performed.

cls

A numeric vector specifying the stratification strata structure of the model. Default setting of NULL assumes no stratification.

vcov

A specification of the covariance matrix of the estimated coefficients. This can be specified as a matrix or as a function yielding a matrix when applied to x. Only used for the computation under heteroscedastic errors. Default is vcovHC.

Details

For details on vcov see the documentation of coeftest in "lmtest" package.

Value

An object of class 'coeftest'. A matrix of coefficient estimates, standard errors, t-ratios and p-values.

Author(s)

Bikram Karmakar

See Also

coeftest

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
data("CigarettesSW", package = "AER")
CigarettesSW$rprice <- with(CigarettesSW, price/cpi)
CigarettesSW$rincome <- with(CigarettesSW, income/population/cpi)
CigarettesSW$tdiff <- with(CigarettesSW, (taxs - tax)/cpi)

fm2 <- ivreg.EX(log(packs) ~ log(rprice) + log(rincome) | tdiff + log(rincome),
			data = CigarettesSW, subset = year == "1995")
lmfit <- lm(log(packs) ~ log(rprice) + log(rincome), data = CigarettesSW, 
			subset = year == "1995")

res = coeftestIV(fm2, lmfit, 'log(rprice)')

##############
x = CigarettesSW[CigarettesSW[,'year'] == "1995", c('rprice', 'rincome')]
y = CigarettesSW[CigarettesSW[,'year'] == "1995", c('packs')]
z = CigarettesSW[CigarettesSW[,'year'] == "1995", c('tdiff', 'rincome')]

fm3 <- ivreg.fit.EX(as.matrix(x), y, z)
lmfit <- lm(packs ~ rprice + rincome, data = CigarettesSW, subset = year == "1995")
res = coeftestIV(fm3, lmfit, 'rprice')
res

ivregEX documentation built on May 1, 2019, 10:08 p.m.