diag_foc_rwgt returns the "focal reweighting variable" model diagnostic described in see Buja et al. (2019) . 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.

diag_foc_rwgt(mod_fit, coef_rwgt, term_chosen)

Arguments

mod_fit

An object of class lm or glm to fit on the data. This object should contain the formula, the data, and, in case of glm, the family.

coef_rwgt

A tibble containing the number of the bootstrapped data set (b), the size of each bootstrapped data set (m), the value of the reweighting centers (term_rwgt_center) and of the reweighted term (term_rwgt), and the estimates of the regression coefficients (term and estimate). This tibble can be created via the diag_fit_reg_rwgt function.

term_chosen

A character corresponding to the coefficient of interest to be analyzed.

Value

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.

References

Buja A, Brown L, Kuchibhotla AK, Berk R, George E, Zhao L (2019). “Models as approximations II: A model-free theory of parametric regression.” Statist. Sci., 34(4), 545--565. ISSN 0883-4237.

Examples

if (FALSE) { 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") }