Description Usage Arguments Details Examples
This command runs the magnified instrumental variables estimator, of either the group-based or weighted variety.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
formula |
A formula of the form |
data |
A data.frame. |
ngroups |
Number of groups to split the data into. |
grouping |
A string variable indicating either the name of a variable in |
groupformula |
If using |
est |
A string variable equal to |
p |
If using |
ivsubset, ivna.action, ivweights, ivcontrasts |
Additional options to be passed to |
silent |
Set to TRUE to suppress any messages related to group-creation slow times. |
... |
Additional options to be passed to |
This function will:
1. Use groupSearch()
, groupCF
or a supplied grouping variable, as requested, to find appropriate groupings over which the effects of the instruments vary.
2. If the weighted version of Magnified IV is requested, uses factorPull()
to estimate effects within each group, and calculates sample weights for each observation, which are the first-stage F statistic that would be achieved if all observations in the sample had the same instrument effect as that observation, to the power p
, then runs AER::ivreg()
with those weights.
3. If the grouped version of Magnified IV is requested, runs AER::ivreg()
with those groups included as controls and interacted with the instrument.
You can get more control over the estimation process (say, using a different command than AER::ivreg()
) by making use of the constituent parts to get groups or weights and then setting the interaction or weights yourself.
One instance in which you may want to get more control over the estimation process is if you have multiple endogenous variables. With multiple endogenous variables and multiple instruments, there are lots of different ways to determine groupings. The magnifiedIV
function will only allow one grouping per instrument, and if you want groupSearch
or groupCF
to determine that grouping for you, you must be able to specify a single formula like x1 ~ z1 | w1 + w2
to create that grouping. Can't do x1 + x2 ~ z1 + z2 | w1 + w2
, that doesn't work. So with multiple excluded instruments that are each "for" multiple endogenous variables, you will want to do something by hand.
It is recommended that you read Huntington-Klein (2019) before using this command to understand which versions appear to work well, and what the Super-Local Average Treatment Effect (SLATE) is.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # This repeats the Stock-Watson textbook cigarette tax IV model
# from the AER::ivreg() help file.
# ... but it's magnified!
# Get data
data(CigarettesSW, package = 'AER')
CigarettesSW$rprice <- CigarettesSW$price/CigarettesSW$cpi
CigarettesSW$rincome <- CigarettesSW$income/CigarettesSW$population/CigarettesSW$cpi
CigarettesSW$tdiff <- (CigarettesSW$taxs - CigarettesSW$tax)/CigarettesSW$cpi
Cig95 <- CigarettesSW[CigarettesSW$year == "1995",]
# Run magnified IV, using causal forest to create effect quantiles
magIV <- magnifiedIV(log(packs) ~ log(rprice) + log(rincome) | log(rincome) + tdiff + I(tax/cpi),
data = Cig95,
ngroups = 5,
grouping = 'groupCF',
groupformula = list(log(rprice) ~ tdiff | I(tax/cpi) + population + taxs,
log(rprice) ~ I(tax/cpi) | tdiff + population + taxs))
summary(magIV)
summary(magIV, vcov = sandwich, df = Inf, diagnostics = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.