diag_foc_slope returns the "focal slope" model diagnostics described in see Buja et al. (2019) . This graphical tool provides insights into the interactions between the regressor specified in term_chosen and all other regressors. 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 term_chosen vary under reweighting of all other regressors and compares them with the original estimates from mod_fit.

diag_foc_slope(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 the coefficient of one regressor of interest (term_chosen) varies under reweighting of the regressors. The vertical axis indicates the magnitude of the estimates of the coefficient of the regressor of interest. The horizontal axis and panels titles show the values and names of the regressors respectively. 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(13123412) # Get focal slope 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_slope(mod_fit, ols_rwgt, "X1") }