View source: R/ModelDiagnostics.R
model_diagnostics_data | R Documentation |
This function prepares the data-frame with necessary attributes for creating
regression diagnostics plots for a model with compositional predictors where
points are replaced by pie-glyphs making it easier to track various data points
in the plots. The output data-frame can be passed to
model_diagnostics_plot
to create the visualisation.
model_diagnostics_data(model, prop = NULL)
model |
A statistical regression model object fit using |
prop |
A character vector giving names of the compositional predictors in the model. If this is not specified then plots prepared using the data would not contain pie-glyphs. |
The original data used for fitting the model with the response and all model predictors along with the following additional columns
Diagonal of the hat matrix.
Estimate of residual standard deviation when corresponding observation is dropped from model.
The cook's distance (cooks.distance()
) for each observation.
Fitted values of model.
The residuals for the observations.
The standardised (Pearson) residuals for the observations.
A unique identifier for each observation.
The labels to be displayed besides the observations in the plot.
The quantile values for the standardised residuals generated using qqnorm()
.
The weights for each observation in the model (useful in the context of weighted regression).
library(DImodels)
## Load data
data(sim1)
## Fit model
mod1 <- lm(response ~ 0 + (p1 + p2 + p3 + p4)^2, data = sim1)
## Get data for diagnostics plot
diagnostics_data <- model_diagnostics_data(mod1,
prop = c("p1", "p2", "p3", "p4"))
print(head(diagnostics_data))
## The compositional predictors in the data are added as attributes to the data
attr(diagnostics_data, "prop")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.