Abstract
Generalized linear models are applied for data analysis in various areas. One of the most important steps in fitting the model is to check the goodness-of-fit; however, there is a lack of such tests. Modified chi-squared goodness-of-fit tests for generalized linear models were constructed. Models with continuous right-skewed, possibly censored responses were considered. Explicit formulas of test statistics are provided in the case of gamma and inverse Gaussian models. The test power was investigated by simulation. The article presents real data examples to illustrate the application of tests.
Keywords:
generalized linear models; gamma regression; inverse Gaussian regression; chi-squared test; goodness-of-fit; censoring MSC:
62G10; 62J12; 62N01
1. Introduction
Generalized linear models (GLMs) [1] are among the most commonly used regression models in practice. The most frequently applied continuous GLM models are normal (Gaussian), gamma, and inverse Gaussian. The gamma and inverse Gaussian regression models are used to model right-skewed response variables, for example, modeling the lifetime distribution in reliability theory [2,3], claims prediction and premium computations in insurance [4,5,6], healthcare costs analysis [7,8], and estimation of outcomes in psychology [9].
The Gaussian GLM coincides with the most applied normal regression model, and the theory of normal regression can be found in an enormous number of articles and books on theoretical or applied statistics.
The fitting of a regression model consists of a set of steps, and one of the key steps is to check the goodness-of-fit (GOF). However, there is a lack of such tests, especially for continuous GLM such as gamma and inverse Gaussian regression. Just a few articles consider formal tests.
In many textbooks, the chi-squared approximation of Pearson and deviance statistics is recommended to test the gamma and inverse Gaussian regression models’ fit. It can lead to erroneous conclusions because this approximation is true if the shape parameter is large. It is clearly demonstrated in [10,11], for example. In [11], the authors propose approximations of Pearson and deviance statistics quantiles for the gamma regression model. Unfortunately, these approximations are given only in the case of a known shape parameter . The case of unknown is not investigated, so these results can not be used for goodness-of-fit. In [10], GOF tests for gamma and inverse Gaussian models are proposed by applying modifications of Cramer–von Mises and Anderson–Darling statistics. These statistics are computed using transformations of the responses via parametric estimates of their cumulative distribution functions (c.d.f.) and the inverse of the c.d.f. of the standard normal distribution. The theory is not developed rigorously: the asymptotic distributions of the test statistics are not found, and approximations of the distributions of the test statistics for finite sample sizes are not given. These tests can not be applied if the data are censored.
The score test for inverse Gaussian regression against inverse Gaussian mixture was constructed in [12]. The authors considered cases with complete and censored data, and critical values were obtained using the bootstrap. The disadvantage is that this test is not the omnibus test. It is recommended only in the case when only one of the possible alternatives (mixture) is suspected.
The current paper is a natural continuation of our paper [13]. In [13], modified chi-square tests were constructed for parametric accelerated failure time (AFT) models (see also [14]). To obtain these tests, at first, some asymptotic results for general parametric regression models (the AFT models being particular cases of these models) were rigorously obtained. In particular, asymptotic properties of the random vector of differences between the numbers of observed and “expected” failures in the intervals of a data partition (the partition is received using a uniquely defined rule) are derived. Application of general results for the following AFT models was considered: exponential, shape-scale (Weibull, log-normal, and log-logistics).
In the current article, we apply the general theorems of our paper [13] to obtain modified chi-squared goodness-of-fit tests for continuous right-skewed possibly censored GLM models.
The inverse Gaussian regression is GLM but not the AFT; thus, new tests are needed. The gamma regression is GLM, and it is also the AFT model; however, the article [13] on GOF for AFT models did not consider this model. Thus, we are currently investigating it.
Tests for gamma and inverse Gaussian regression models were investigated in detail. The Gaussian GLM by exponential transformation is transferred to log-normal AFT, which is considered in [13]. We did not write the formulas for this model because GOF tests for the normal regression are well-known and investigated in many papers.
Some authors consider diagnostic plots based on residuals for the gamma and inverse Gaussian models, but they are not formal GOF tests, so they can not be compared with the proposed tests because their significance and power can not be investigated. However, diagnostic graphs are useful at the initial stage of analysis, and in conjunction with formal GOFs, provide a broader view of data. The authors [15] proposed two new methods for the detection of influential observations in the case of the inverse Gaussian regression, and also presented a review of existing methods. In the article [16], adjusted deviance residuals for the gamma regression model were proposed and used for influence diagnostics. The construction of partial residuals for the inverse Gaussian regression was carried out in [17] for graphical model diagnostics.
The structure of the article is as follows: firstly (see Section 2), continuous GLMs are discussed; furthermore, in Section 3, the methodology of the modified chi-squared test is provided, the approach of choosing grouping intervals is explained, and the limit distribution of the test statistic is obtained. The results of the simulation study and the application for real data are presented in Section 4 and Section 5, respectively.
2. Gamma and Inverse Gaussian Regression Models
Let us consider the parametrization of the gamma distribution, denoted by , , and , with the following probability density function (p.d.f.):
where is the shape parameter.
If T is a random variable with distribution , then the mean and the variance are
and the cumulative distribution function (c.d.f.) is
where is the c.d.f. of the chi-squared distribution with degrees of freedom; i.e., the lower incomplete gamma function.
Let us consider the parametrization of the inverse Gaussian distribution (also known as Wald distribution), denoted by , , , with the following p.d.f.:
where is the shape parameter. If T is a random variable with distribution , then the mean and the variance are
and the c.d.f. is
where is the c.d.f. of the standard normal distribution.
The gamma and the IG distributions belong to the exponential family with a p.d.f. of the following form:
For the gamma distribution,
and for the IG distribution,
Gamma regression model: The distribution of response T given the shape parameter and a vector of covariates is and the link function is logarithmic:
Thus, the p.d.f., c.d.f., mean, and variance given the vector of covariates are as follows:
where is the lower incomplete gamma function and
Sometimes the canonical (inverse) link function is used:
Inverse Gaussian regression model: The distribution of the response T given the shape parameter and a vector of covariates is and the link function is logarithmic:
Thus, the p.d.f, c.d.f, mean, and variance given the vector of covariates are as follows:
Sometimes, the canonical (inverse squared) link function is used:
The gamma regression model is also an AFT model, and the IG model is not an AFT model.
3. Chi-Squared GOF Tests for Gamma and Inverse Gaussian Regression
3.1. Parameter Estimation
Let us consider the possibility of right-censored regression data:
where are responses and are censorings.
Denote
as the hazard and the cumulative hazard functions, respectively, depending on a finite-dimensional parameter . In the case of gamma and inverse Gaussian regression models, .
The parametric log-likelihood function is the following:
where and are presented in Section 3.2 and Section 3.3.
3.2. Gamma Regression
In the case of gamma regression, the following results were obtained:
where is the c.d.f. of the ith response, and is the digamma function.
Note that the derivative of the probability density function of the ith response with respect to is
This implies that the derivative of the c.d.f. with respect to is the integral of the derivative of the p.d.f.:
where is the derivative of the lower incomplete gamma function with respect to the first argument (could be obtained using the function pgamma.deriv.unscaled of the R software version 4.4.3 package VGAM); the function gammainc of the R software version 4.4.3 package pracma computes the lower incomplete gamma functions, and functions gamma and digamma of the R version 4.4.3 package base return values of gamma and diggama functions, respectively.
where is defined by (6).
3.3. Inverse Gaussian Regression
In the case of inverse Gaussian regression, the following was obtained:
where is defined by (10) and
3.4. Grouping Intervals
Let be the ML estimator of Set
where is the number of responses in the interval . The mean of is
So, may be interpreted as the expected number of responses in the interval when the parametric model is true.
If the parametric model is true, then the difference should take smaller values than in the case when the model is false.
Denote as the ordered . Set ; here, is the vector of covariates corresponding to in the sample. Define
where is the estimator (under the true model) of the expected number of responses in the interval . If the model is true, then this value should not be far from n.
Divide the interval into k smaller intervals . and (do not identify with from Section 3.3) have the same expected number of responses in each interval. More precisely, the point is defined in the following way:
The function is strictly increasing: and .
Set . Let us use notation . Define
Note that , , and , . Hence, there exists such that , which implies that . So, at first, is found. Then, is obtained, which is the unique root of the function in the interval , and is easily found by the bisection method because , , and is strictly increasing. Note that in the interval the function may be written as follows:
3.5. Test Statistic
The numbers of observed and expected responses in the interval are as follows:
The chi-squared test is based on the random vector
i.e., on the differences between observed and expected values under the GLM model, including the number of responses in the intervals .
Set
If s is a dimension of , then are vectors and C is a matrix. Denote by the diagonal matrix with diagonal elements .
The limit distribution of the random vector Z is found by applying the results of Theorems 3.1 and 3.2 of our article [13] (these theorems are also provided in [18] and Appendix A of this article). Note that these theorems can be applied not only for AFT models but also in the case of GLM models, because we can choose various forms of parametric hazard functions for different i (see Appendix A).
The proof of the above-mentioned theorems in [13] was obtained by the following steps. At first, the asymptotic properties of the stochastic process,
were investigated ([13], Lemma 3.1; Appendix A, and Lemma A1) by applying the central limit theorem (CLT) for martingales under well-known assumptions (see [19]) on the asymptotic properties (consistency and asymptotic normality) of the ML estimator and the assumptions of CLT. Lemma 3.1 implies that the limit distribution of the random vector is Z (see [13], Theorem 3.1; Appendix A, and Theorem A1 ). This distribution is approximated by the normal distribution Theorem 3.2 (see Appendix A and Theorem A2) implies that the covariance matrix V is consistently estimated by the matrix:
where is a matrix (see [18]) that can be written in the following form:
where derivatives of are provided in (7) and (9) for the gamma regression, and in (11) and (12) for inverse Gaussian regression.
The chi-squared test for the hypothesis is based on the following statistic:
where is the general inverse of the matrix . The hypothesis is rejected with an approximate significance level of if , where r is the rank of the matrix V.
Note that in the case of the gamma regression, V is a full rank matrix (); thus, In the case of inverse Gaussian regression model,
4. Simulation Study
The data are simulated by taking two covariates: —dichotomous (0—for half of the observations and 1—for the remaining observations) and Different sample sizes n are considered. The Rice rule (see [20]) is used to determine the number of grouping intervals (see Table 1):
Table 1.
The number of grouping intervals using the Rice rule.
In the assumptions of the limit distribution of the test statistic, it is supposed that k is fixed and the limit distribution is obtained to be chi-squared with k or degrees-of-freedom. Is the approximation accurate if ? Note that if n is fixed, then is also fixed. We know that if the size of the sample is sufficiently large and , then the chi-squared approximation is accurate. But, taking into account that n is much larger than k (see Table 1), the approximation should also be good for sample size n. Simulations confirm this.
4.1. Simulation Under Hypotheses
The estimated significance levels are obtained using 5000 iterations. Tests with significance levels and are applied. Table 2 and Table 3 present the results for gamma and inverse Gaussian regression, respectively. Grouping intervals are computed using the Rice rule (15); moreover, different numbers of grouping intervals are considered to see how the convergence speed depends on the number of grouping intervals. The simulation results under the hypothesis demonstrate that the estimated significance levels approach the true value as the number of observations increases.
Table 2.
Estimates of the significance level under the hypothesis, inverse Gaussian regression with log link, .
Table 3.
Estimates of the significance level under the hypothesis, gamma regression with log link, .
4.2. Simulation Under Alternatives
The data are simulated under various alternatives and values of parameters. For each of the sample sizes considered, we simulate 1000 replications and compute values of the test power. The significance level is 0.05.
In the case of inverse Gaussian regression, the test power under the following alternatives is investigated (see Table 4): gamma regression, log-normal, log-logistic, and Weibull AFT models. For gamma regression, the following alternatives are considered: inverse Gaussian and normal regression, log-normal, and log-logistic and Weibull AFT models, i.e., gamma regression models with shape and scale depending on covariates.
Table 4.
Definitions of alternative models.
The results in the case of gamma regression are presented in Table 5. It has become evident that the test power under the IG regression alternative is large even for small sample sizes. The smallest test power values are in the case of the Weibull AFT model alternative, which is reasonable because gamma and Weibull models are very similar for some sets of parameters.
Table 5.
Gamma regression. Powers against various alternatives. n: number of observations; k: optimal number of grouping intervals.
The results in the case of IG regression are presented in Table 6. It turned out that the test power under all considered alternatives is large even for small sample sizes. The smallest test power values are obtained when the alternative is the log-logistic AFT model.
Table 6.
Inverse Gaussian regression. Powers against various alternatives. n: number of observations; k: optimal number of grouping intervals.
Moreover, the simulation study suggested that in the case of the gamma and inverse Gaussian regression, the Rice rule (15) provides optimal grouping intervals () for sample sizes , and for smaller samples the number of grouping intervals is
5. Real Data Examples
Example 1: Failure times (see Table 7) of 76 electrical insulating fluids tested at voltages, ranging from 26 to 38 kV ([21]), are considered.
Table 7.
Failure times for 76 electrical insulating fluids tested at voltages .
The diagnostic methods (see [2]) suggest that the Weibull AFT–power rule model, i.e., should be used. The results of applying the modified chi-squared test are presented in Table 8. The analysis demonstrated that the Weibull AFT–power rule and gamma regression models are not rejected; however, AIC and BIC are smaller in the case of the gamma regression model. The inverse Gaussian regression model is strongly rejected.
Table 8.
Modified chi-squared test, . Electrical insulating fluids data.
Example 2: Hospital cost data (the dataset hospcosts from R package robmixglm) consist of a sample of 100 patients hospitalized at the Centre Hospitalier Universitaire Vaudois in Lausanne during 1999 for “medical back problems”. The response is the cost of stay, and the covariates are as follows: length of stay (in days; the logarithmic transformation was applied), admission type (0: planned; 1: emergency), insurance type (0: regular; 1: private), age (in years), sex (0: female; 1: male) and discharge destination (1: home; 0: another health institution). Data were analyzed in [8] considering the gamma regression and [22] in the Weibull model context.
The results of applying the modified chi-squared test are presented in Table 9. It is clear that the Weibull AFT–power rule and gamma regression models are not rejected. However, AIC is smaller in the case of the Weibull AFT–power rule model. The inverse Gaussian regression model is strongly rejected.
Table 9.
Modified chi-squared test, . Hospital cost data.
Example 3: Table 10 presents the results of an experiment designed to compare the performances of high-speed turbine engine bearings made out of five different compounds (see [2]). Data were fitted using a three-parameter Weibull distribution. The experiment tested 10 bearings of each type, and the times to fatigue failure were measured in units of millions of cycles.
Table 10.
Failure times of bearing specimens.
The results using the modified chi-squared test are presented in Table 11. The gamma, Weibull AFT, and inverse Gaussian regression models are rejected. The results do not contradict the results in [2].
Table 11.
Chi-squared test, . Bearing specimens data.
6. Conclusions
The modified chi-squared goodness-of-fit tests were constructed for gamma and inverse Gaussian regression models with possibly censored data. The methodology for grouping intervals was proposed, and practical recommendations based on the simulation results were presented. The results indicated that the test power under various considered alternatives is large even for small sample sizes. Moreover, in the case of the gamma and inverse Gaussian regression the Rice rule (15) provides optimal grouping intervals () for sample sizes , and for smaller samples, the number of grouping intervals is The application of tests was shown using real data. The proposed tests are important in the data modeling process. They are robust to the model structure because in the case of misspecification of the model, the ”expected” number of responses will be far from the observed number of responses, and the test statistic will take large values; therefore, the hypothesis will be rejected. Thus, another model structure could be taken into consideration. The article fills the gap of formal omnibus tests for gamma and inverse Gaussian regression.
Author Contributions
Conceptualization, V.B. and R.L.; methodology, V.B. and R.L.; investigation, V.B. and R.L.; writing—original draft preparation, V.B. and R.L.; writing—review and editing, V.B. and R.L. All authors have read and agreed to the published version of the manuscript.
Funding
This research received no external funding.
Data Availability Statement
The original contributions presented in this study are included in the article.
Conflicts of Interest
The authors declare no conflicts of interest.
Appendix A
In [13], the following results were obtained.
Condition A (consistency and asymptotic normality of the ML estimator ):
where
Set
Condition B: This paragraph is with indentation. There exist a neighborhood of and continuous bounded on : functions
such that for ,
Condition B implies that uniformly for ,
where A and C are finite.
Lemma A1.
Under Conditions A and B, the following convergence holds:
where is space of cadlag functions with the Skorokhod metric; V is a zero-mean Gaussian martingale, such that for all ,
Theorem A1.
Under Conditions A and B,
where
Theorem A2.
Under conditions A and B, the following estimators of , , , and V are consistent:
and
References
- McCullagh, P.; Nelder, J.A. Generalized Linear Models, 2nd ed.; Chapman and Hall: London, UK, 1989. [Google Scholar] [CrossRef]
- Lawless, J.F. Statistical Models and Methods for Lifetime Data; John Wiley & Sons: Hoboken, NJ, USA, 2003. [Google Scholar] [CrossRef]
- Meeker, W.Q.; Escobar, L.A. Statistical Methods for Reliability Data; John Wiley & Sons: Hoboken, NJ, USA, 1998; ISBN 978-1-118-62597-2. [Google Scholar]
- De Jong, P.; Heller, G.Z. Generalized Linear Models for Insurance Data; Cambridge University Press: Cambridge, UK, 2008. [Google Scholar] [CrossRef]
- Haberman, S.; Renshaw, A.E. Generalized linear models and actuarial science. J. R. Stat. Soc. Ser. D (The Stat.) 1996, 45, 407–436. [Google Scholar] [CrossRef]
- Baione, F.; Biancalana, D. An individual risk model for premium calculation based on quantile: A comparison between generalized linear models and quantile regression. N. Am. Actuar. J. 2019, 23, 573–590. [Google Scholar] [CrossRef]
- Blough, D.K.; Ramsey, S.D. Using generalized linear models to assess medical care costs. Health Serv. Outcomes Res. Methodol. 2000, 1, 185–202. [Google Scholar] [CrossRef]
- Cantoni, E.; Ronchetti, E. A robust approach for skewed and heavy-tailed outcomes in the analysis of health care expenditures. J. Health Econ. 2006, 25, 198–213. [Google Scholar] [CrossRef]
- Ng, V.K.; Cribbie, R.A. Using the gamma generalized linear model for modeling continuous, skewed and heteroscedastic outcomes in psychology. Curr. Psychol. 2017, 36, 225–235. [Google Scholar] [CrossRef]
- Klar, B.; Meintanis, S.G. Specification tests for the response distribution in generalized linear models. Comput. Stat. 2012, 27, 251–267. [Google Scholar] [CrossRef]
- Shayib, M.A.; Young, D.H. Modified goodness of fit tests in gamma regression. J. Stat. Comput. Simul. 1989, 33, 125–133. [Google Scholar] [CrossRef]
- Desmond, A.F.; Yang, Z. Asymptotically refined score and GOF tests for inverse Gaussian models. J. Stat. Comput. Simul. 2016, 86, 3243–3269. [Google Scholar] [CrossRef]
- Bagdonavičius, V.B.; Levuliene, R.J.; Nikulin, M.S. Chi-squared goodness-of-fit tests for parametric accelerated failure time models. Commun.-Stat.-Theory Methods 2013, 42, 2768–2785. [Google Scholar] [CrossRef]
- Bagdonavičius, V.; Nikulin, M.S. Accelerated Life Models: Modeling and Statistical Analysis; Chapman & Hall/CRC: New York, NY, USA, 2002. [Google Scholar] [CrossRef]
- Amin, M.; Ullah, M.A.; Qasim, M. Diagnostic techniques for the inverse Gaussian regression model. Commun. Stat.-Theory Methods 2022, 51, 2552–2564. [Google Scholar] [CrossRef]
- Amin, M.; Amanullah, M.; Cordeiro, G.M. Influence diagnostics in the gamma regression model with adjusted deviance residuals. Commun. Stat.-Simul. Comput. 2017, 46, 6959–6973. [Google Scholar] [CrossRef]
- Imran, M.; Akbar, A. Diagnostics via partial residual plots in inverse Gaussian regression. J. Chemom. 2020, 34, e3203. [Google Scholar] [CrossRef]
- Bagdonavicius, V.; Kruopis, J.; Nikulin, M.S. Non-parametric Tests for Censored Data; John Wiley & Sons: Hoboken, NJ, USA, 2013. [Google Scholar] [CrossRef]
- Andersen, P.K.; Borgan, O.; Gill, R.D.; Keiding, N. Statistical Models Based on Counting Processes; Springer Science & Business Media: Berlin/Heidelberg, Germany, 1993. [Google Scholar] [CrossRef]
- De La Rubia, J.M. Rice university rule to determine the number of bins. Open J. Stat. 2024, 14, 119–149. [Google Scholar] [CrossRef]
- Nelson, W. Hazard plotting methods for analysis of life data with different failure modes. J. Qual. Technol. 1970, 2, 126–149. [Google Scholar] [CrossRef]
- Marazzi, A.; Yohai, V.J. Adaptively truncated maximum likelihood regression with asymmetric errors. J. Stat. Plan. Inference 2004, 122, 271–291. [Google Scholar] [CrossRef]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).