Bootstrap-Based Goodness-of-Fit Tests for Parametric Regression

Provides statistical methods to check if a parametric family of conditional density functions fits to some given dataset of covariates and response variables. Different test statistics can be used to determine the goodness-of-fit of the assumed model, see Andrews (1997) , Bierens & Wang (2012) , Dikta & Scheer (2021) and Kremling & Dikta (2024) . As proposed in these papers, the corresponding p-values are approximated using a parametric bootstrap method.


R-CMD-check

gofreg

This R package provides classes and methods to fit parametric regression models to given data and to perform bootstrap-based goodness-of-fit tests using different test statistics.

The data can either consist of $(X,Y)$ pairs of covariates and response variables or in case of random censorship it consists of tuples $(X, Z, \delta)$ denoting covariates, censored survival times and censoring indicators. The package includes different parametric regression models (mostly generalized linear models) and test statistics (based on different papers). It can easily be extended by other user-defined models and test statistics.

Installation

You can install it from CRAN

install.packages("gofreg")

or github

devtools::install_github("gkremling/gofreg")

Example

This is a basic example which shows how to fit a parametric regression model to a given dataset and afterwards perform a goodness-of-fit test. In this example, we use the dataset datasets::cars, a generalized linear model with normal distribution and the conditional Kolmogorov test statistic of the marginal distribution of $Y$ defined in Kremling & Dikta (2024) arXiv:2409.20262.

library(gofreg)

set.seed(123)

data <- dplyr::tibble(x = datasets::cars$speed, y = datasets::cars$dist)
model <- GLM.new(distr = "normal", linkinv = identity)
model$fit(data, params_init = list(beta = 3, sd = 2), inplace = TRUE)
print(model$get_params())
#> $beta
#> [1] 2.908838
#> 
#> $sd
#> [1] 16.09429
gt <- GOFTest$new(data = data, model_fitted = model, test_stat = CondKolmY$new(), nboot = 100)
print(gt$get_pvalue())
#> [1] 0.01
gt$plot_procs()

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("gofreg")

1.0.0 by Gitte Kremling, 2 years ago


https://github.com/gkremling/gofreg, https://gkremling.github.io/gofreg/


Report a bug at https://github.com/gkremling/gofreg/issues


Browse source code at https://github.com/cran/gofreg


Authors: Gitte Kremling [aut, cre, cph]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports checkmate, dplyr, ggplot2, R6, survival

Suggests knitr, rmarkdown, testthat


See at CRAN