goodness_of_fit {flatr} | R Documentation |
Calculates the goodness of fit test statistics for contingency tables
goodness_of_fit(model, type = "Chisq", ...)
model |
a GLM regression model. |
type |
either "Chisq" or "Gsq", which determines the type of goodness of fit test that is ran. Defaults to "Chisq". |
... |
Further arguments passed to or from other methods. |
A list with class "ct_goodness_of_fit
" containing the following components:
test
the type of test used.
model
the name of the inputted model.
statistic
The value of the test statistic as determined by the type parameter
df
The number of degrees of freedom.
This equals the number of combinations for explanatory variables less the number of parameters in the model
p.value
The p-value calculated under a Chi-Squared distribution.
lung_logit <-
lung_cancer %>%
flatten_ct() %>%
glm(
Lung ~ Smoking
,family = binomial
,data = .
)
goodness_of_fit(model = lung_logit, type = "Chisq")
lung_logit %>%
goodness_of_fit(type = "Gsq")
lung_cancer %>%
flatten_ct() %>%
glm(
Lung ~ City + Smoking
,family = binomial
,data = .
) %>%
goodness_of_fit()