Description Usage Arguments Details Value Author(s) See Also Examples
This function performs sensitivity analysis for two stage least squared estimator. When output of OLS and EX analyses are also supplied as an object of class "ivregEX" all three sensitivity analyses for the three estimates are performed.
1 2 3 4 5 6 7 8 9 10 11 | ## S3 method for class 'ivregEX'
sensIvreg(ivregfit, coeftestIVres, variable,
delta1 = seq(-0.1, 0.1, 0.01), delta2 = seq(-0.1, 0.1, 0.01),
effect = 0, g = sqrt, errType = c("homoscedastic",
"heteroscedastic"), alpha = 0.05, show = FALSE, ...)
## S3 method for class 'ivreg'
sensIvreg(ivregfit, coeftestIVres, variable,
delta2 = seq(-.1, .1, .01),
g = sqrt, errType = c("homoscedastic", "heteroscedastic"),
alpha = 0.05, ...)
|
ivregfit |
An object of class |
coeftestIVres |
An object of class "coeftest". Must be supplied if |
variable |
The endogenous variable of interest in the instrumental variables regression model. |
delta1 |
A numeric vector of values of the first sensitivity parameter. Default value |
delta2 |
A numeric vector of values of the second sensitivity parameter. Default value |
effect |
A numeric vector of null treat effects of interest. Default 0. |
g |
A function describing the mechanism by which the assumptions of an instrument may be violated. Default sqrt. |
errType |
What kind of error structure to be assumed: "homoscedastic" or "heteroscedastic". |
alpha |
Significance level. Default at 0.05. |
show |
Whether result is to be printed. |
... |
Optional. May be ignored. used in |
delta1 and delta2 are the two sensitivity parameters. delta1 is the partial correlation of the unobservable and the treatment. It measures the amount of violation in the assumption of no-unmeasured confounding. delta2 is the partial correlation of the outcome and g(instruments) measuring the amount of violation in the exogeneity and no direct effect assumption of the instruments.
Only the 2SLS analysis uses delta2, OLS and EX analysis uses delta1 to perform sensitivity analysis.
Returns an object of class "sensIvregEX" if input is of type ivregEX
.
If the input is of type ivreg
, returns an object of class "si".
An object if class "si" is essentially a matrix of two columns for the the upper and lower sensitivity limits corresponding to the sensitivity parameters.
An object of class "sensIvregEX" consists of an object of class "ivregDecisionList"
and three objects of class "si" for the three estimators. "ivregDecisionList"
is a list of overall sensitivity analyses (based on primary OLS and
secondary 2SLS and EX analysis. Each list element correspond to the deferent
effect
values and tells you the sensitivity of the problem
for all possible pairs of (delta1, delta2).
Bikram Karmakar
senslm
, plot.sensIvregEX
, plot.si
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | data("CigarettesSW", package = "AER")
CigarettesSW$rprice <- with(CigarettesSW, price/cpi)
CigarettesSW$rincome <- with(CigarettesSW, income/population/cpi)
CigarettesSW$tdiff <- with(CigarettesSW, (taxs - tax)/cpi)
######################
library(AER)
fm1 <- ivreg(log(packs) ~ log(rprice) + log(rincome) | tdiff + log(rincome),
data = CigarettesSW, subset = year == "1995", x=TRUE)
z <- sensIvreg(fm1, variable = 'log(rprice)')
######################
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)')
z <- sensIvreg(fm2, res, 'log(rprice)', effect = c(-.1, 0, .1, .15, .17))
###################
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')
z <- sensIvreg(fm3, res, 'rprice', effect = c(-.1, 0, .1, .15, .17))
##################
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.