Description Usage Arguments Value References Examples
diag_nl_detect
returns the "nonlinearity detection" model
diagnostic as described in
\insertCite@see @buja2019modelsasapproximationspart2;textualmaars.
This graphical tool provides insights into the marginal nonlinear behavior
of response surfaces for each of the 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 estimate of each coefficient varies under
reweighting of its own regressor and compares it with the original
estimates from mod_fit
.
1 | diag_nl_detect(mod_fit, coef_rwgt)
|
mod_fit |
An object of class |
coef_rwgt |
A tibble containing the number of the bootstrapped data set
( |
A ggplot2 object which shows how the estimates of all coefficients
vary under reweighting of their own regressors.
The vertical axis represents the estimates of the coefficients under
reweighting of the one regressor, 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(1332423)
# Get nonlinearity detection plot
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_nl_detect(mod_fit, ols_rwgt)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.