L_1way_cat: Likelihood Support for One-way Categorical Data

View source: R/L_1way_cat.R

L_1way_catR Documentation

Likelihood Support for One-way Categorical Data

Description

This function calculates the support for one-way categorical data (multinomial), also gives chi-squared and likelihood ratio test (G) statistics. If there are only 2 categories then binomial information is given too with likelihood interval, including the likelihood-based % confidence interval. Support for the variance being more different than expected (Edwards p 187, Cahusac p 158) is also calculated. It uses the optimize function to locate desired limits for both intervals.

Usage

L_1way_cat(obs, exp.p=NULL, L.int=2, alpha=0.05, toler=0.0001,
logplot=FALSE, supplot=-10, verb=TRUE)

Arguments

obs

a vector containing the number of counts in each category.

exp.p

a vector containing expected probabilities. If NULL then this is 1/#cats.

L.int

likelihood interval given as support values, e.g. 2 or 3, default = 2.

alpha

the significance level used, 1 - alpha interval calculated, default = 0.05.

toler

the desired accuracy using optimise, default = 0.0001.

logplot

plot vertical axis as log likelihood, default = FALSE

supplot

set minimum likelihood display value in plot, default = -10

verb

show output, default = TRUE.

Value

$S.val - support for one-way observed versus expected.

$uncorrected.sup - uncorrected support.

$df - degrees of freedom for table.

$observed - observed counts.

$exp.p - expected probabilities.

$too.good - support for the variance of counts being more different than expected.

$chi.sq - chi-squared value.

$p.value - p value for chi-squared.

$LR.test = the likelihood ratio test statistic.

$lrt.p = the p value for the likelihood ratio test statistic

Additional outputs for binomial:

$prob.val - MLE probability from data.

$succ.fail - number of successes and failures.

$like.int - likelihood interval.

$like.int.spec - specified likelihood interval in units of support.

$conf.int - likelihood-based confidence interval.

$alpha.spec - specified alpha for confidence interval.

$err.acc - error accuracy for optimize function.

References

Aitkin, M. et al (1989) Statistical Modelling in GLIM, Clarendon Press, ISBN : 978-0198522041

Cahusac, P.M.B. (2020) Evidence-Based Statistics, Wiley, ISBN : 978-1119549802

Royall, R. M. (1997). Statistical evidence: A likelihood paradigm. London: Chapman & Hall, ISBN : 978-0412044113

Edwards, A.W.F. (1992) Likelihood, Johns Hopkins Press, ISBN : 978-0801844430

Examples

# example for binomial, p 123
obs <- c(6,4)
L_1way_cat(obs, L.int=2, toler=0.0001, logplot=FALSE, supplot=-10, verb = TRUE)

# example for multinomial, p 134
obs <- c(60,40,100)
exp <- c(0.25,0.25,0.5)
L_1way_cat(obs, exp.p=exp, L.int=2, toler=0.0001, logplot=FALSE, supplot=-10,
verb = TRUE)


likelihoodR documentation built on Oct. 22, 2024, 5:06 p.m.