Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Deviance Goodness of fit tests #527

Open
itsdebartha opened this issue Apr 27, 2023 · 2 comments
Open

Feature Request: Deviance Goodness of fit tests #527

itsdebartha opened this issue Apr 27, 2023 · 2 comments

Comments

@itsdebartha
Copy link

I was thinking of implementing the deviance goodness of fit tests while calling the glm function. It'll be nice to know if the fitted model is meaningful or not right from the summary.

The null hypothesis could be the fact that the fitted model is as good as the null model, while the alternative is the fitted model is better than the null model. The distribution of the test statistic for this test follows asymptotically a chi-squared distribution

@nalimilan
Copy link
Member

You mean something like the output of lrtest(null_model, model)?

One concern is that currently when an offset is provided, we have to fit the null model just to compute its log-likelihood. So this has a cost. Maybe that's not a problem if we assume that the summary is only printed for interactive use and not e.g. when bootstrapping or fitting hundreds of models.

@itsdebartha
Copy link
Author

itsdebartha commented Jun 15, 2023

@nalimilan Yes, like the lrtest. But I was proposing to print a short result directly below the output of glm. Something like:

StatsModels.TableRegressionModel{GeneralizedLinearModel{GLM.GlmResp{Vector{Float64}, Binomial{Float64}, LogitLink}, GLM.DensePredChol{Float64, LinearAlgebra.CholeskyPivoted{Float64, Matrix{Float64}, Vector{Int64}}}}, Matrix{Float64}}

y ~ 1 + x1 + x2

Coefficients:
────────────────────────────────────────────────────────────────────────────
                  Coef.  Std. Error      z  Pr(>|z|)    Lower 95%  Upper 95%
────────────────────────────────────────────────────────────────────────────
(Intercept)  -6.94463     4.63484    -1.50    0.1340  -16.0287       2.13949
x1            0.0723796   0.0632414   1.14    0.2524   -0.0515712    0.19633
x2            0.978977    0.523473    1.87    0.0615   -0.0470123    2.00497
────────────────────────────────────────────────────────────────────────────

Deviance goodness of fit measure
null deviance: 27.725887222397812
residual deviance: 21.124205303875755
value under h_0: fitted model is as good as null model
outcome with 95% confidence: reject h_0
one-sided p-value: 0.03685216319850078

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants