goodness_of_fit {flatr} | R Documentation |
Calculate the Chi^2 and G^2 Statistics
Description
Calculates the goodness of fit test statistics for contingency tables
Usage
goodness_of_fit(model, type = "Chisq", ...)
Arguments
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. |
Value
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.
Examples
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()
[Package flatr version 0.1.1 Index]