Calculates the binomial aproximation using stirling's formula (Version of function: V 1.0 - November 2013)
stirling_cfa(
observed,
expected = NULL,
n = sum(observed),
p = NULL,
cum = T,
verb = T
)
a integer vector with observed freqencies
a vector giving the expected frequencies. expected can be set to expected=NULL
if an vector of cell probabilities is given in argument p
.
number of trials (scalar) default is n = sum(observed)
.
a vector of cell probabilities. If p is not NULL the argument expected
is ignored and this vector p of cell probabilities is used for calculatio instead of expected counts
a logical - computation of cumulative density. If cum=TRUE
(default) computes tail probability. If cum=FALSE
computes prob. only for one cell (i.e. execute stircore only).
logical - verbose results: If verb=TRUE
(default) builds a results table. If verb=FALSE
returns vector of cell p-values only.
R.W. Alexandrowicz
Vector p must be of same length as observed _or_ p may be a scalar (e.g. in case of the zero-order CFA).
The routine autoselects the upper or lower tail:
if obs > exp then sum obs:n
else sum 0:obs
The stirling approximation cannot be evaluated if the observed frequency is 0 or n. Therefore, the proposal of A. von Eye (20xx) is adopted, taking the sum up to 1 or n-1, respectively.
von Eye, A. (2002). Configural Frequency Analysis. Methods, Models, and Applications. Mahwah, NJ, LEA.