Description Usage Arguments Value Examples
Run a regression and return the results in a tibble. Useful for running multiple regressions with purrr::pmap. All inputs are fed directly into as.formula, and should follow the relevant specifications.
1 2 |
lhs |
Character vector with left hand side variable. |
rhs |
Character vector with right hand side variable(s). |
fe |
Character vector with fixed effects. Optional. |
iv |
Character vector with instruments. Optional. |
clus |
Character vector of clustering variable(s). Optional. |
data_str |
String to be evaluated to produce dataset. Use single quotes inside double quotes to avoid need for escaping. |
tidy |
TRUE/FALSE. Return a tidied data.frame rather than a fitted felm object? Optional. |
tibble with summary statistics and fitted output (felm or tidied data.frame).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # Load data
data("Wages", package="plm")
setDT(Wages)
reg_tibble <- as_tibble(
expand.grid(lhs = "lwage", rhs = c("exp", "exp + wks"),
fe = "married", clus = "0", data_str = c("Wages", "Wages[bluecol == 'no']"),
stringsAsFactors = F))
reg_output <- cbind(reg_tibble, purrr::pmap_dfr(reg_tibble, reg_felm))
# Can also save regression output as a tidied data.frame
reg_output_tidy <- cbind(reg_tibble, purrr::pmap_dfr(reg_tibble, reg_felm, tidy = T))
# These can be used directly in stargazer or huxtable
stargazer::stargazer(reg_output$fit)
huxtable::huxreg(reg_output$fit)
huxtable::huxreg(reg_output_tidy$fit_tidy)
# Easy to select which regressions to display
stargazer::stargazer(reg_output %>% filter(rhs == "exp + wks") %>% pull(fit))
huxtable::huxreg(reg_output %>% filter(rhs == "exp + wks") %>% pull(fit))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.