View source: R/cf_LogRV_MeansRatio.R
| cf_LogRV_MeansRatio | R Documentation |
N independent
LOG-TRANSFORMED MEANS-RATIO random variablescf_LogRV_MeansRatio(t, n, alpha, coef, niid) evaluates characteristic function
of a linear combination (resp. convolution) of N independent LOG-TRANSFORMED MEANS-RATIO
random variables (RVs), W_i = log(R_i) for i = 1,...,N , where each R_i = G_i/A_i is a ratio
of G_i (the geometric mean) and A_i (the arithmetic mean) of a random sample
X_{i,1},...,X_{i,n_i} from a GAMMA distribution.
That is, cf_LogRV_MeansRatio evaluates the characteristic function
of a random variable Y = coef_1*W_1 +...+ coef_N*W_N, such that
cf_Y(t) = cf_W_1(coef_1*t) *...* cf_W_N(coef_N*t), where cf_W_i(t)
is CF of W_i = log(R_i), and R_i ~ MeansRatio(n_i,\alpha_i),
where MeansRatio(n_i,\alpha_i) denotes the distribution of R_i, for i = 1,...,N.
Here, we define G_i = (X_{i,1} *...* X_{i,n_i})^(1/n_i) and
A_i = (X_{i,1} +...+ X_{i,n_i})/n_i, with X_{i,j} ~ Gamma(\alpha_i,\beta_i)
for all j = 1,...,n_i, where \alpha_i is the shape parameter and \beta_i
is the rate parameter of the GAMMA distribution in the i-th random sample.
Note that the R_i random variables are scale invariant,
so the distribution does not depend on the rate (scale) parameters \beta_i.
The MeansRatio distribution of R_i ~ MeansRatio(k_i,\alpha_i),
with R_i in (0,1), is defined by R_i ~ (Prod_{j=1}^{k_i-1} B_{i,j})^(1/k_i),
where B_{i,j} ~ Beta{\alpha_i, j/k_i)} for j = 1,...,k_{i-1},
i.e. B_{i,j} follow independent Beta distributions for all i = 1,...,N and
j = 1,...,k_{i-1}. Alternatively, log(R_i) ~ (log(B_{i,1}) +...+ log(B_{i,k_{i-1}}))/k_i.
cf_LogRV_MeansRatio(t, n, alpha, coef, niid)
t |
vector or array of real values, where the CF is evaluated. |
n |
vector of sample size parameters |
alpha |
vector of the 'shape' parameters |
coef |
vector of the coefficients of the linear combination of the
log-transformed random variables. If |
niid |
scalar convolution coeficient |
The MeansRatio distribution is the distribution of the Bartlett's test
statistitic for testing homogeneity of variances of k populations,
based on equal sample sizes of size m, i.e. with df = m-1
for all j = 1,...,k. Let DF = k*df. The Bartlett test statistic defined
in Glaser (1976b) is
L = Prod((df*S^2_j/sigma^2)^(df/DF)) / (df/DF)*Sum(df*S^2_j/sigma^2) = Prod((S^2_j)^(1/k))/Sum(S^2_j)/k,
where S^2_j = (1/(m-1))*Sum(X_jk - mean(X_jk))^2.
Notice that df*S^2_j/sigma^2 ~ Chi^2_df = Gamma(df/2,1/2) for all j = 1,...,k.
The exact critical values can be calculated from the distribution of W = -log(L)
by inverting the characteristic function cf_LogRV_MeansRatio.
Characteristic function cf(t) of a linear combination of N independent
LOG-TRANSFORMED MEANS-RATIO random variables.
Ver.: 05-Oct-2018 13:54:18 (consistent with Matlab CharFunTool v1.3.0, 17-Jun-2017 17:18:39).
Glaser, R. E. (1976a). The ratio of the geometric mean to the arithmetic mean for a random sample from a gamma distribution. Journal of the American Statistical Association, 71(354), 480-487.
Glaser, R. E. (1976b). Exact critical values for Bartlett's test for homogeneity of variances. Journal of the American Statistical Association, 71(354), 488-490.
Chao, M. T., & Glaser, R. E. (1978). The exact distribution of Bartlett's test statistic for homogeneity of variances with unequal sample sizes. Journal of the American Statistical Association, 73(362), 422-426.
For more details see WIKIPEDIA:
https://en.wikipedia.org/wiki/Beta_distribution,
https://en.wikipedia.org/wiki/Bartlett
Other Continuous Probability Distribution:
cfS_Arcsine(),
cfS_Beta(),
cfS_Gaussian(),
cfS_Laplace(),
cfS_Rectangular(),
cfS_Student(),
cfS_TSP(),
cfS_Trapezoidal(),
cfS_Triangular(),
cfS_Wigner(),
cfX_ChiSquare(),
cfX_Exponential(),
cfX_FisherSnedecor(),
cfX_Gamma(),
cfX_InverseGamma(),
cfX_LogNormal(),
cf_ArcsineSymmetric(),
cf_BetaNC(),
cf_BetaSymmetric(),
cf_Beta(),
cf_ChiSquare(),
cf_Exponential(),
cf_FisherSnedecorNC(),
cf_FisherSnedecor(),
cf_Gamma(),
cf_InverseGamma(),
cf_Laplace(),
cf_LogRV_BetaNC(),
cf_LogRV_Beta(),
cf_LogRV_ChiSquareNC(),
cf_LogRV_ChiSquare(),
cf_LogRV_FisherSnedecorNC(),
cf_LogRV_FisherSnedecor(),
cf_LogRV_MeansRatioW(),
cf_LogRV_WilksLambdaNC(),
cf_LogRV_WilksLambda(),
cf_Normal(),
cf_RectangularSymmetric(),
cf_Student(),
cf_TSPSymmetric(),
cf_TrapezoidalSymmetric(),
cf_TriangularSymmetric(),
cf_vonMises()
## EXAMPLE 1
# CF of log MeansRatio RV with n = 5 and alpha = 7/2
n <- 5
alpha <- 7/2
t <- seq(-100, 100, length.out = 201)
plotReIm(function(t) cf_LogRV_MeansRatio(t, n, alpha), t,
title = 'CF of log MeansRatio RV with n = 5 and alpha = 7/2')
## EXAMPLE 2
# CF of a weighted linear combination of minus log MeansRatio RVs
n <- c(5, 7, 10)
alpha <- c(7, 10, 15) / 2
coef <- -c(5, 7, 10) / 22
t <- seq(-100, 100, length.out = 201)
plotReIm(function(t) cf_LogRV_MeansRatio(t, n, alpha, coef), t,
title = 'CF of a weighted linear combination of -log MeansRatio RVs')
## EXAMPLE 3
# PDF/CDF of minus log MeansRatio RV, n = 5 and alpha = 7/2, from its CF
n <- 5
alpha <- 7/2
coef <- -1
cf <- function(t) cf_LogRV_MeansRatio(t, n, alpha, coef)
x <- seq(0, 0.6, length.out = 100)
prob <- c(0.9, 0.95, 0.99)
options <- list()
options$xMin <- 0
result <- cf2DistGP(cf, x, prob, options)
str(result)
## EXAMPLE 4
# Compare the exact distribution with the Bartlett's approximation
k <- 25 # number of normal populations
df <- 3 # degrees of freedom used in each of n populations
DF <- k * df
alpha <- df / 2
C_B <- (1 + 1 / (3 * (k - 1)) * (k / df - 1 / DF))
coef <- -DF / C_B
cf <- function(t) cf_LogRV_MeansRatio(t, k, alpha, coef)
prob <- c(0.9, 0.95, 0.99)
options <- list()
options$xMin <- 0
result <- cf2DistGP(cf, prob = prob, options = options)
str(result)
x <- result$x
matplot(cbind(x, x), cbind(result$cdf, pchisq(x, k - 1)),
xlab = 'corrected test statistic', ylab = 'CDF',
main = 'Exact CDF vs. the Bartlett approximation')
matplot(cbind(x, x), cbind(result$cdf, pchisq(x, k - 1)),
xlab = 'corrected test statistic', ylab = 'CDF',
main = 'Exact CDF vs. the Bartlett approximation', type = "l", lwd = 2)
prob
result$qf
qchisq(prob, k-1)
## EXAMPLE 5
# Exact Critical Values for Bartlett's Test for Homogeneity of Variances
# See and compare the selected results in Glaser (1976b, Table 1)
k <- 3
df <- c(4, 5, 6, 7, 8, 9, 10, 11, 14, 19, 24, 29, 49, 99)
alpha <- df / 2
coef <- -1
prob <- c(0.9, 0.95, 0.99)
options <- list()
options$N <- 2^12
options$SixSigmaRule <- 15
options$xMin <- 0
options$isPlot <- FALSE
critW = matrix(0, length(df), length(prob))
for(i in 1:length(df)) {
cf <- function(t) cf_LogRV_MeansRatio(t, k, alpha[i], coef)
result <- cf2DistGP(cf, prob = prob, options = options)
critW[i,] <- result$qf
}
critR <- exp(-critW)
cat('k = ', k, '\n')
cat('alpha = ', 1 - prob, '\n')
cat(critR)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.