Type: | Package |
Title: | Likelihood Ratio Statistics for One or Two Sample T-Tests |
Version: | 0.2.3 |
Maintainer: | John Maindonald <john@statsresearch.co.nz> |
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'. |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
Encoding: | UTF-8 |
Suggests: | knitr, rmarkdown, bookdown, MASS, magrittr |
Imports: | lattice, latticeExtra |
VignetteBuilder: | knitr |
RoxygenNote: | 7.2.3 |
NeedsCompilation: | no |
Packaged: | 2023-09-12 09:06:32 UTC; johnm1 |
Author: | John Maindonald |
Repository: | CRAN |
Date/Publication: | 2023-09-12 12:50:02 UTC |
Maximum Likelihood ratio for H1 versus H0, given t-statistic or p-value
Description
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
.
Usage
tTOlr(
t = NULL,
df = NULL,
nsamp = NULL,
pval = NULL,
delta = NULL,
sd = 1,
twoSided = TRUE,
showMax = TRUE
)
Arguments
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 |
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.
Value
List, with elements
t -
t
-statisticdf - 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
Note
The likelihood estimate for H1 versus H0 is unchanged if the roles of H0 and H1 are reversed.
Examples
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)
Maximum Likelihood Under H1, Given T-statistic
Description
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.
Usage
tTOmaxlik(t, df)
Arguments
t |
|
df |
Degrees of freedom. |
Details
#' @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.
Value
List, with elements
maxlik - Maximum likelihood under H1
tmax -
t
-statistic for difference in means that makes likelihood a maximum under H1lik0 - Density (one-sided) under H0
References
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.
Examples
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