Learn R Programming

GrowthCurveME (version 0.1.0)

growth_model_residual_plots: Create residual diagnostic plots for growth model

Description

This function provides a wrapper to ggplot2 for generating residual diagnostic plots and summary statistics for a growth model summary list object produced by growth_curve_model_fit.

Usage

growth_model_residual_plots(
  growth_model_summary_list,
  residual_type = "cluster",
  weighted = TRUE
)

Value

Returns a patchwork collage of ggplot2 model diagnostic plots with the following plots displayed:

  • Residual vs Fitted Values - a model diagnostic plot for assessing the distribution of the residuals vs the model fitted values, useful in detecting improper function specification, homogeneity of variance, and outlier detection.

  • Q-Q Plot - a model diagnostic plot (quantile-quantile) plot for comparing the residuals vs their theoretical quantiles, useful in assessing normality assumptions and outlier detection.

  • Residual Density Plot - a model diagnostic showing the distribution of the residuals (histogram) with a normal distribution curve overlaid based on the residuals mean and standard deviation, useful in assessing normality assumptions and skewness.

  • Residual Summary Statistics - a list of descriptive statistics of the the residuals including: mean, median, minimum, maximum, skewness, and kurtosis.

Arguments

growth_model_summary_list

A list object created by the growth_curve_model_fit function.

residual_type

A character string specifying the type of residuals to be displayed in the plot. Options include "population" for the fixed-effects residuals for mixed-effects and least-squares models and "cluster" for fixed and random-effects residuals for mixed-effects regression models. Defaults to "cluster".

weighted

A logical value, when TRUE displays weighted residuals for mixed-effects models or standardized residuals for least-squares models, when FALSE displays the raw residuals for mixed-effects and least-squares models. Defaults to "TRUE".

See Also

growth_curve_model_fit

Examples

Run this code
# Load example data (exponential data)
data(exp_mixed_data)
# Fit an mixed-effects growth model to the data and produce summary list
exp_mixed_model_summary <- growth_curve_model_fit(
data_frame = exp_mixed_data,
function_type = "exponential",
verbose = FALSE)
# Check residuals and model assumptions
residual_diag_plot <- growth_model_residual_plots(
  growth_model_summary_list = exp_mixed_model_summary)
print(residual_diag_plot)

Run the code above in your browser using DataLab