MyNixOS website logo
Description

Diagnostic Tools for Asymptotic Theory.

Leveraging Monte Carlo simulations, this package provides tools for diagnosing regression models. It implements a parametric bootstrap framework to compute statistics, generates diagnostic envelopes to assess goodness-of-fit, and evaluates type I error control for Wald tests. By simulating data under the assumption that the model is true, it helps to identify model mis-specifications and enhances the reliability of the model inferences.

asympDiag

badge

The asympDiag package provides tools for diagnosing statistical regression models using Monte Carlo simulations. It helps assess the adequacy of asymptotic approximations for Wald tests and verify residuals with envelopes. Most of the functions uses generic methods from the stats package and are compatible with models fitted with the functions lm, glm, glm.nb, lmer and glmer. If your model class is not compatible, you can still generate the diagnostic plots with the responses and refit_fn arguments.

Installation

You can install the development version of asympDiag from GitHub with:

# install.packages("devtools")
devtools::install_github("Alvaro-Kothe/asympDiag")

Example

Below is an example using envelope() to create a residual diagnostic plot based on Monte Carlo simulations.

library(asympDiag)

# Example data
counts <- c(18, 17, 15, 20, 10, 20, 25, 13, 12)
outcome <- gl(3, 1, 9)
treatment <- gl(3, 3)

# Fitting a Poisson regression model
glm.D93 <- glm(counts ~ outcome + treatment, family = poisson())

# Creating an envelope plot for residual diagnostics
envelope(glm.D93)

envelope

The envelope() function generates an envelope plot that compares observed residuals to those expected under the model, helping to identify potential model misspecifications.

Next, after fitting a valid model, you can use simulate_wald_pvalues() to generate p-values through simulation and check if the sample size is sufficient for the Wald test's asymptotic approximation:

# Simulating p-values to assess asymptotic approximation validity
simulate_wald_pvalues(glm.D93, nsim = 10000)

pvalues

The function simulate_wald_pvalues() provides a distribution of p-values from the Monte Carlo simulation, enabling a deeper assessment of whether the sample size supports reliable inference based on the Wald test.

Metadata

Version

0.3.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows