| Type: | Package |
| Title: | Comprehensive Diagnostics for Statistical Models |
| Version: | 0.1.0 |
| Description: | Provides a unified framework for diagnosing common issues in statistical models including linear models, generalized linear models (logistic and Poisson regression), and survival models. Implements tests for multicollinearity, heteroscedasticity, autocorrelation, normality, influential observations, overdispersion, zero-inflation, and proportional hazards assumptions. Includes visualization methods for graphical diagnostics. Methods are based on established approaches including Fox and Monette (1992) <doi:10.1080/01621459.1992.10475190>, Breusch and Pagan (1979) <doi:10.2307/1911963>, and Dean and Lawless (1989) <doi:10.1080/01621459.1989.10478792>. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| URL: | https://github.com/Teniola17/modeldiag |
| BugReports: | https://github.com/Teniola17/modeldiag/issues |
| Depends: | R (≥ 3.5.0) |
| Imports: | stats, graphics, car, lmtest, ResourceSelection, survival |
| Suggests: | testthat (≥ 3.0.0), knitr, rmarkdown |
| RoxygenNote: | 7.3.3 |
| VignetteBuilder: | knitr |
| Config/testthat/edition: | 3 |
| NeedsCompilation: | no |
| Packaged: | 2026-05-21 14:47:02 UTC; EmmanuelAdewuyi |
| Author: | Emmanuel Adewuyi [aut, cre], Adewale Lukman [aut], Abiola Owolabi [ctb] |
| Maintainer: | Emmanuel Adewuyi <emmanuel.adewuyi@lshtm.ac.uk> |
| Repository: | CRAN |
| Date/Publication: | 2026-05-28 12:40:02 UTC |
modeldiag: Comprehensive Diagnostics for Statistical Models
Description
Provides a unified framework for diagnosing common issues in statistical models including linear models, generalized linear models (logistic and Poisson regression), and survival models. Implements tests for multicollinearity, heteroscedasticity, autocorrelation, normality, influential observations, overdispersion, zero-inflation, and proportional hazards assumptions. Includes visualization methods for graphical diagnostics. Methods are based on established approaches including Fox and Monette (1992) doi:10.1080/01621459.1992.10475190, Breusch and Pagan (1979) doi:10.2307/1911963, and Dean and Lawless (1989) doi:10.1080/01621459.1989.10478792.
Author(s)
Maintainer: Emmanuel Adewuyi emmanuel.adewuyi@lshtm.ac.uk
Authors:
Adewale Lukman
Other contributors:
Abiola Owolabi [contributor]
See Also
Useful links:
Check Heteroskedasticity
Description
Performs Breusch-Pagan test for heteroskedasticity.
Usage
check_heteroskedasticity(model)
Arguments
model |
A fitted lm object. |
Value
An htest object or NA if computation fails.
Check Variance Inflation Factors
Description
Computes variance inflation factors to detect multicollinearity.
Usage
check_vif(model)
Arguments
model |
A fitted model object. |
Value
A numeric vector of VIF values or NA if computation fails.
Diagnose Statistical Models
Description
This is a generic function for performing diagnostic checks on statistical models. It dispatches to specific methods based on the model type.
Usage
## S3 method for class 'glm'
diagnose_model(model, ...)
## S3 method for class 'lm'
diagnose_model(model, ...)
## S3 method for class 'coxph'
diagnose_model(model, ...)
diagnose_model(model, ...)
Arguments
model |
A fitted model object. |
... |
Additional arguments passed to specific methods. |
Value
An object of class "model_diagnostics" containing the results of various diagnostic tests.
Examples
# Linear model diagnostics
model_lm <- lm(mpg ~ wt + hp, data = mtcars)
diag_lm <- diagnose_model(model_lm)
summary(diag_lm)
plot(diag_lm)
# Logistic regression diagnostics
model_glm <- glm(am ~ wt + hp, data = mtcars, family = binomial)
diag_glm <- diagnose_model(model_glm)
summary(diag_glm)
# Poisson regression diagnostics
model_pois <- glm(carb ~ wt + hp, data = mtcars, family = poisson)
diag_pois <- diagnose_model(model_pois)
summary(diag_pois)
# Cox proportional hazards diagnostics
library(survival)
data(lung)
model_cox <- coxph(Surv(time, status) ~ age + sex + ph.ecog, data = lung)
diag_cox <- diagnose_model(model_cox)
summary(diag_cox)
Plot Model Diagnostics
Description
Generates diagnostic plots for the fitted model.
Usage
## S3 method for class 'model_diagnostics'
plot(x, ...)
Arguments
x |
An object of class "model_diagnostics". |
... |
Additional arguments passed to plotting functions. |
Value
None (plots are displayed).
Print Model Diagnostics
Description
Prints a summary of the model diagnostics object.
Usage
## S3 method for class 'model_diagnostics'
print(x, ...)
Arguments
x |
An object of class "model_diagnostics". |
... |
Additional arguments passed to print. |
Value
The object x, invisibly.
Summarize Model Diagnostics
Description
Provides a detailed summary of diagnostic test results.
Usage
## S3 method for class 'model_diagnostics'
summary(object, ...)
Arguments
object |
An object of class "model_diagnostics". |
... |
Additional arguments (currently ignored). |
Value
The object, invisibly.