Title: | Likelihood Ratio Statistics for One or Two Sample T-Tests |
---|---|
Description: | Likelihood ratio and maximum likelihood statistics are provided that can be used as alternatives to p-values Colquhoun (2017) <doi:10.1098/rsos.171085>. Arguments can be either p-values or t-statistics. together with degrees of freedom. For the function 'tTOlr', the argument 'twoSided' has the default 'twoSided = TRUE'. |
Authors: | John Maindonald [aut, cre]
|
Maintainer: | John Maindonald <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.2.3 |
Built: | 2025-03-05 04:02:13 UTC |
Source: | https://github.com/cran/tTOlr |
Given the t
-statistic for a difference in means,
or for a mean difference, and degrees of freedom,
determine the maximum likelihood under the alternative
H1, and the $t$-statistic for the difference in means
that makes the likelihood under H1 a maximum. Also
available is the likelihood that corresponds to a
particular value of a particular effect size (mean
divided by standard deviation) delta
.
tTOlr( t = NULL, df = NULL, nsamp = NULL, pval = NULL, delta = NULL, sd = 1, twoSided = TRUE, showMax = TRUE )
tTOlr( t = NULL, df = NULL, nsamp = NULL, pval = NULL, delta = NULL, sd = 1, twoSided = TRUE, showMax = TRUE )
t |
|
df |
Degrees of freedom. |
nsamp |
Sample size. For a two-sample test, this should be a vector of length 2. |
pval |
|
delta |
If not |
sd |
Standard deviation. |
twoSided |
Set either to |
showMax |
Set to |
The function returns the maximum likelihood estimate of the maximum likelihood on the scale of the $t$-statistic, for the likelihood under the alternative, when the when the $t$-statistic is used as non-centrality parameter. This results in a value for the likelihood ratio that differs from (and is smaller than) the standard likelihood ratio statistic. Additionally, return the likelihoods under H0 and H1.
List, with elements
t - t
-statistic
df - Degrees of freedom
pval - P-value
likDelta - Likelihood, given difference delta under H0
lrDelta - Likelihood ratio, given difference delta under H0
maxlik - Maximum likelihood, under allowed alternatives H1
lrmax - Maximum likelihood under H1, on the scale of the $t$-statistic
tmax - t
-statistic for difference in means
that makes likelihood under H1 a maximum
The likelihood estimate for H1 versus H0 is unchanged if the roles of H0 and H1 are reversed.
likStats <- tTOlr(pval=0.02, nsamp=c(9,9), twoSided=TRUE, delta=1.4, sd=1.2) print(likStats,digits=2) likStats <- tTOlr(t=2.58, df=16, nsamp=c(9,9), twoSided=TRUE, delta=1.4, sd=1.2) print(likStats,digits=2) likStats <- tTOlr(pval=0.02, nsamp=9, twoSided=FALSE, delta=1.4, sd=1.2) print(likStats,digits=2) likStats <- tTOlr(t=2.45, df=8, nsamp=9, twoSided=FALSE, delta=1.4, sd=1.2) print(likStats,digits=2)
likStats <- tTOlr(pval=0.02, nsamp=c(9,9), twoSided=TRUE, delta=1.4, sd=1.2) print(likStats,digits=2) likStats <- tTOlr(t=2.58, df=16, nsamp=c(9,9), twoSided=TRUE, delta=1.4, sd=1.2) print(likStats,digits=2) likStats <- tTOlr(pval=0.02, nsamp=9, twoSided=FALSE, delta=1.4, sd=1.2) print(likStats,digits=2) likStats <- tTOlr(t=2.45, df=8, nsamp=9, twoSided=FALSE, delta=1.4, sd=1.2) print(likStats,digits=2)
Given the t
-statistic for a difference in means,
or for a mean difference, and degrees of freedom,
determine the maximum likelihood under the alternative
H1, and the $t$-statistic for the difference in means
that makes the likelihood under H1 a maximum.
Additionally, return the likelihood under H0.
tTOmaxlik(t, df)
tTOmaxlik(t, df)
t |
|
df |
Degrees of freedom. |
#' @details The function returns the maximum likelihood estimate of the maximum likelihood on the scale of the $t$-statistic, for the likelihood under the alternative, when the when the $t$-statistic is used as non-centrality parameter. This results in a value for the likelihood ratio that differs from (and is smaller than) the standard likelihood ratio statistic. Additionally, return the likelihoods under H0 and H1.
List, with elements
maxlik - Maximum likelihood under H1
tmax - t
-statistic for difference in means that makes
likelihood a maximum under H1
lik0 - Density (one-sided) under H0
van Aubel, A; Gawronski, W (2003). Analytic properties of noncentral distributions. Applied Mathematics and Computation. 141: 3–12. doi:10.1016/S0096-3003(02)00316-8.
stats <- tTOmaxlik(t=2, df=5) ## Likelihood ratio, 1-sided test and 2-sided test, p=0.05 tvals1 <- qt(0.05, df=c(2,5,20), lower.tail=FALSE) tvals2 <- qt(0.025, df=c(2,5,20), lower.tail=FALSE) likrat1 <- likrat2 <- numeric(3) for(i in 1:3){ stats1 <- tTOmaxlik(t=tvals1[i], df=c(2,5,20)[i]) likrat1[i] <- stats1[['maxlik']]/stats1[['lik0']] stats2 <- tTOmaxlik(t=tvals2[i], df=c(2,5,20)[i]) likrat2[i] <- stats2[['maxlik']]/(2*stats2[['lik0']]) # NB: 2*stats2[['lik0']] in denominator. } likrat <- rbind('One-sided'=likrat1, 'Two-sided'=likrat2) colnames(likrat) <- paste0('df=',c(2,5,20)) likrat
stats <- tTOmaxlik(t=2, df=5) ## Likelihood ratio, 1-sided test and 2-sided test, p=0.05 tvals1 <- qt(0.05, df=c(2,5,20), lower.tail=FALSE) tvals2 <- qt(0.025, df=c(2,5,20), lower.tail=FALSE) likrat1 <- likrat2 <- numeric(3) for(i in 1:3){ stats1 <- tTOmaxlik(t=tvals1[i], df=c(2,5,20)[i]) likrat1[i] <- stats1[['maxlik']]/stats1[['lik0']] stats2 <- tTOmaxlik(t=tvals2[i], df=c(2,5,20)[i]) likrat2[i] <- stats2[['maxlik']]/(2*stats2[['lik0']]) # NB: 2*stats2[['lik0']] in denominator. } likrat <- rbind('One-sided'=likrat1, 'Two-sided'=likrat2) colnames(likrat) <- paste0('df=',c(2,5,20)) likrat