Skip to content

@description

Usage

chisq_stat(x, formula, response = NULL, explanatory = NULL, ...)

Arguments

x

A data frame that can be coerced into a tibble.

formula

A formula with the response variable on the left and the explanatory on the right. Alternatively, a response and explanatory argument can be supplied.

response

The variable name in x that will serve as the response. This is an alternative to using the formula argument.

explanatory

The variable name in x that will serve as the explanatory variable. This is an alternative to using the formula argument.

...

Additional arguments for chisq.test().

Details

A shortcut wrapper function to get the observed test statistic for a chisq test. Uses chisq.test(), which applies a continuity correction. This function has been deprecated in favor of the more general observe().

See also

Other wrapper functions: chisq_test(), observe(), prop_test(), t_stat(), t_test()

Other functions for calculating observed statistics: observe(), t_stat()

Examples

# chi-squared test statistic for test of independence
# of college completion status depending and one's
# self-identified income class
chisq_stat(gss, college ~ finrela)
#> Warning: `chisq_stat()` was deprecated in infer 1.0.0.
#>  Please use `observe()` instead.
#> X-squared 
#>  30.68252 

# chi-squared test statistic for a goodness of fit
# test on whether self-identified income class
# follows a uniform distribution
chisq_stat(gss,
           response = finrela,
           p = c("far below average" = 1/6,
                 "below average" = 1/6,
                 "average" = 1/6,
                 "above average" = 1/6,
                 "far above average" = 1/6,
                 "DK" = 1/6))
#> X-squared 
#>   487.984