Version: | 0.2.0 |
Title: | Flexible Tools for Estimating Interactions |
Imports: | stats, fixest, glmnet |
Depends: | R (≥ 3.0.0) |
Suggests: | knitr, ggplot2, lmtest, rmarkdown |
Description: | A set of functions to estimate interactions flexibly in the face of possibly many controls. Implements the procedures described in Blackwell and Olson (2022) <doi:10.1017/pan.2021.19>. |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
URL: | https://mattblackwell.github.io/inters/ |
BugReports: | https://github.com/mattblackwell/inters/issues |
VignetteBuilder: | knitr |
LazyData: | true |
Encoding: | UTF-8 |
RoxygenNote: | 7.2.1 |
NeedsCompilation: | no |
Packaged: | 2023-01-10 19:22:14 UTC; mblackwell |
Author: | Matthew Blackwell |
Maintainer: | Matthew Blackwell <mblackwell@gov.harvard.edu> |
Repository: | CRAN |
Date/Publication: | 2023-01-10 20:10:02 UTC |
Post-double selection estimator for interactions
Description
post_ds_interaction
applies post-double selection to the
estimation of an interaction in a linear model.
Usage
post_ds_interaction(
data,
treat,
moderator,
outcome,
control_vars,
panel_vars = NULL,
moderator_marg = TRUE,
cluster = NULL,
method = "double selection"
)
Arguments
data |
data.frame to find the relevant variables. |
treat |
string with the name of the treatment variable. |
moderator |
string with the name of the moderating variable. |
outcome |
string with the name of the outcome variable. |
control_vars |
vector of strings with the names of the control variables to include. |
panel_vars |
vector of strings with the names of categorical variables to include as fixed effects. |
moderator_marg |
logical indicating if the lower-order term of the moderator should be included () |
cluster |
string with the name of the cluster variable. |
method |
string indicating which method to use. The default
is |
Details
The post_ds_interaction
implements the post-double
selection estimator of Belloni et al (2014) as applied to
interactions, which was proposed by Blackwell and Olson (2019).
Variables passed to panel_vars
are considered factors
for fixed effects and whose "base effects" are removed by
demeaning all variables by those factors. Interactions between
the moderator and all variables (including the factors generated
by panel_vars
) are generated and passed to the
post-double selection procedure. Base terms for the treatment,
moderator, and control variables are forced to be included in
the final post-double selection OLS. The cluster
argument
adjusts the lasso
Value
Returns an object of the class lm
with an
additional clustervcv
object containing the
cluster-robust variance matrix estimate when cluster
is
provided.
References
Alexandre Belloni, Victor Chernozhukov, Christian Hansen, Inference on Treatment Effects after Selection among High-Dimensional Controls, The Review of Economic Studies, Volume 81, Issue 2, April 2014, Pages 608-650, doi:10.1093/restud/rdt044
Matthew Blackwell and Michael Olson.. "Reducing Model Misspectation and Bias in the Estimation of Interactions." Political Analysis, 2021.
Examples
data(remit)
controls <- c("l1gdp", "l1pop", "l1nbr5", "l12gr", "l1migr",
"elec3")
post_ds_out <- post_ds_interaction(
data = remit, treat = "remit",
moderator = "dict", outcome = "Protest",
control_vars = controls,
cluster = "caseid"
)
Data on the direct primary in US congressional elections
Description
A data set on the presence of the direct primary in U.S. congressional elections and the vote shares for the Democratic, Republican, and third parties. Based on ICPSR Study 6985
Usage
primary
Format
A data frame with 1164 observations and the following 7 variables:
- state
name of the state
- year
year of the congressional election
- dem_share
percentage of the total vote cast for the Democratic candidate, 0-100
- rep_share
percentage of the total vote cast for the Republican candidate, 0-100
- other_share
percentage of the total vote cast for other parties, 0-100
- primary
binary variable indicating if the state had the direct primary (=1) or not (=0)
- south
binary variable indicating if the state is in the South (=1) or not (=0)
Source
https://www.icpsr.umich.edu/icpsrweb/ICPSR/studies/6895
References
David, Paul T., and Claggett, William. Party Strength in the United States: 1872-1996. Ann Arbor, MI: Inter-university Consortium for Political and Social Research [distributor], 2008-09-10. https://doi.org/10.3886/ICPSR06895.v1
Cross-national data on remittances and protest
Description
A data set to replicate the findings of Escrib\'a-Folch, Meseguer, and Wright (2018). Data and data descriptions are from that paper's replication data, available at doi:10.7910/DVN/TVZQG6
Usage
remit
Format
A data frame with 2429 observations and 14 variables:
- Protest
standardized measure of latent protest from Chenoweth et al. (2014)
- remit
natural log of the 2-year lagged moving average of total remittances received in constant US dollars
- dict
binary indicator of autocracy or democracy from Geddes, Wright, and Frantz (2014)
- l1gdp
natural log of one-period lagged gdp per capita
- l1pop
natural log of one-period lag of population
- l1nbr5
lagged mean latent level of protest in countries with capital cities within 4000km of the target country's capital
- l12gr
two-year lagged moving average of GDP per capita growth (in percent)
- l1migr
natural log of lagged net migration in millions
- elec3
indicator for multiparty election in that year, year prior, or year after
- cowcode
country code from correlates of war dataset
- period
six ordinal time periods
- caseid
numerical code for autocratic regime case name
- year
year
Source
References
Escrib\'a-Folch, A., Meseguer, C. and Wright, J. (2018), Remittances and Protest in Dictatorships. American Journal of Political Science, 62: 889-904. doi:10.1111/ajps.12382
Wright, Joseph, 2018, "Replication Data for: Remittances and Protest in Dictatorships", doi:10.7910/DVN/TVZQG6, Harvard Dataverse, V1, UNF:6:IE6OqUb3EB5AIDYKI28mgA== [fileUNF]