goodness_of_fit: Calculate the Chi^2 and G^2 Statistics

Description Usage Arguments Value Examples

Description

Calculates the goodness of fit test statistics for contingency tables

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
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()

flatr documentation built on May 1, 2019, 8:17 p.m.