Prepares the data for dfbetas plot.
ols_prep_dfbeta_data(d, threshold)
d | A |
---|---|
threshold | The threshold for outliers. |
model <- lm(mpg ~ disp + hp + wt + qsec, data = mtcars) dfb <- dfbetas(model) n <- nrow(dfb) threshold <- 2 / sqrt(n) dbetas <- dfb[, 1] df_data <- tibble::tibble(obs = seq_len(n), dbetas = dbetas) ols_prep_dfbeta_data(df_data, threshold)#> # A tibble: 32 x 5 #> obs dbetas color fct_color txt #> <int> <dbl> <chr> <ord> <int> #> 1 1 -0.241 normal normal NA #> 2 2 -0.0894 normal normal NA #> 3 3 -0.0227 normal normal NA #> 4 4 0.0165 normal normal NA #> 5 5 -0.000179 normal normal NA #> 6 6 0.216 normal normal NA #> 7 7 0.0560 normal normal NA #> 8 8 0.0339 normal normal NA #> 9 9 0.448 outlier outlier 9 #> 10 10 -0.0178 normal normal NA #> # ... with 22 more rows