Partial out controls
idid_partial_out.RdCompute the partialled out version of a variable based on the regression model provided.
Details
The partialling out procedure is implemented using the same estimation
method as the one used in reg.
If var_interest is specified (and different from var_to_partial),
var_interest is not partialled out. This is espetially interesting if one
wants to partial out controls but not the variable of interest.
Examples
# example with a lm regression
reg_ex_lm <- ggplot2::txhousing |>
lm(formula = log(sales) ~ median + listings + city + as.factor(date))
idid_partial_out(reg_ex_lm, "median") |>
head()
#> 1 2 3 4 5 6
#> 10160.214 -3303.202 -4227.209 3889.547 2092.269 -3574.464
idid_partial_out(reg_ex_lm, "log(sales)", "median") |>
head()
#> 1 2 3 4 5 6
#> -0.050652563 -0.045605122 0.005417663 -0.160510848 -0.033033531 0.002041210
# example with a fixest regression
reg_ex_fixest <- ggplot2::txhousing |>
fixest::feols(fml = log(sales) ~ median + listings | as.factor(date) + city)
#> NOTE: 1,434 observations removed because of NA values (LHS: 568, RHS: 1,434).
idid_partial_out(reg_ex_fixest, "median") |>
head()
#> NOTE: 1,434 observations removed because of NA values (LHS: 616, RHS: 1,424).
#> [1] 10160.214 -3303.202 -4227.209 3889.547 2092.269 -3574.464
idid_partial_out(reg_ex_fixest, "log(sales)", "median") |>
head()
#> NOTE: 1,426 observations removed because of NA values (LHS: 568, RHS: 1,424).
#> [1] -0.050652563 -0.045605122 0.005417663 -0.160510848 -0.033033530
#> [6] 0.002041210