Description Usage Arguments Value References Examples
diag_foc_rwgt
returns the "focal reweighting variable" model
diagnostic described in
\insertCite@see @buja2019modelsasapproximationspart2;textualmaars.
More specifically, based on the estimates under reweighting of the regressors
returned by diag_fit_reg_rwgt
and specified in coef_rwgt
, this
function shows how the estimates of all coefficients vary under
reweighting of only one regressor specified in term_chosen
and
compares them with the original estimates from mod_fit
.
1 | diag_foc_rwgt(mod_fit, coef_rwgt, term_chosen)
|
mod_fit |
An object of class |
coef_rwgt |
A tibble containing the number of the bootstrapped data set
( |
term_chosen |
A character corresponding to the coefficient of interest to be analyzed. |
A ggplot2 object which shows how coefficients estimates vary
under reweighting of only one regressor (term_chosen
).
The vertical axis represents the estimates of the coefficient under
reweighting of their own regressors, whose names appear in the panels
titles. The horizontal axis shows the values of the regressors. The grey
lines correspond to the traces of bootstrapped estimates forming the
"spaghetti plot". The black vertical lines indicate 95% confidence
intervals computed via the percentile method for the estimates on the
bootstrapped data sets for the estimates based on each of the centers of
reweighting (term_rwgt_center
). The black line in the middle
corresponds to the mean of the estimates and is approximately equal to the
estimates on the original data (under reweighting). The blue dashed lines
correspond exactly to the original estimate of the coefficients from
mod_fit
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ## Not run:
set.seed(1232312)
# Get focal reweighting variable plot of X1
n <- 1e3
X1 <- stats::rnorm(n, 0, 1)
X2 <- stats::rnorm(n, 0, 3)
y <- 2 + X1 + X2 * 0.3 + stats::rnorm(n, 0, 1)
reg_df <- tibble::tibble(y = y, X1 = X1, X2 = X2, n_obs = 1:length(X1))
mod_fit <- stats::lm(y ~ X1 + X2, reg_df)
ols_rwgt <- diag_fit_reg_rwgt(mod_fit, c("X1", "X2"), B = 300)
# Display the output
diag_foc_rwgt(mod_fit, ols_rwgt, "X1")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.