View source: R/plot_residuals.R
plot_residuals | R Documentation |
This function plots observed and predicted values of the response of linear (mixed) models for each coefficient and highlights the observed values according to their distance (residuals) to the predicted values. This allows to investigate how well actual and predicted values of the outcome fit across the predictor variables.
plot_residuals(
fit,
geom.size = 2,
remove.estimates = NULL,
show.lines = TRUE,
show.resid = TRUE,
show.pred = TRUE,
show.ci = FALSE
)
fit |
Fitted linear (mixed) regression model (including objects of class
|
geom.size |
size resp. width of the geoms (bar width, line thickness or point size, depending on plot type and function). Note that bar and bin widths mostly need smaller values than dot sizes. |
remove.estimates |
Numeric vector with indices (order equals to row index of |
show.lines |
Logical, if |
show.resid |
Logical, if |
show.pred |
Logical, if |
show.ci |
Logical, if |
A ggplot-object.
The actual (observed) values have a coloured fill, while the predicted values have a solid outline without filling.
data(efc)
# fit model
fit <- lm(neg_c_7 ~ c12hour + e17age + e42dep, data = efc)
# plot residuals for all independent variables
plot_residuals(fit)
# remove some independent variables from output
plot_residuals(fit, remove.estimates = c("e17age", "e42dep"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.