Learn R Programming

sjmisc (version 1.0.0)

chisq_gof: Performs a Chi-square goodness-of-fit-test

Description

Performs a Chi-square goodness-of-fit-test

Usage

chisq_gof(var, prob, weights = NULL)

Arguments

var
a numeric vector / variable.
prob
a vector of probabilities (indicating the population probabilities) of the same length as var's amount of categories / factor levels. Use nrow(table(var)) to determine the amount of necessary values for prob.
weights
a vector with weights, used to weight var.

Value

  • (insisibly) returns the object of the computed chisq.test.

Examples

Run this code
data(efc)
# differing from population
chisq_gof(efc$e42dep, c(0.3,0.2,0.22,0.28))
# equal to population
chisq_gof(efc$e42dep, prop.table(table(efc$e42dep)))

Run the code above in your browser using DataLab