makeFx | R Documentation |
Create an Edgeworth series F(x)
of orders 1 - 5 for various versions
of t-statistic.
makeFx(
stats,
n,
r = NULL,
type = "short",
base = "normal",
df = NULL,
moder = FALSE,
verbose = TRUE
)
stats |
named vector of distribution parameters or estimates needed for
Edgeworth expansion. If no names for the vector are provided and the type
is
|
n |
a single value for a sample size summary to be used in Edgeworth expansion. Important: an average (not sum!) of two group sizes for a two-sample test. |
r |
square root of variance adjustment. Provide if wish to use a value
that is different from the one that will be calculated from |
type |
which Edgeworth expansions are to be evaluated: |
base |
base distribution of Edgeworth expansions. Classic expansions are
based on standard normal distribution ( |
df |
degrees of freedom for Student's t-distribution if |
moder |
|
verbose |
if |
Given sample statistics or distribution parameters, produce Edgeworth
expansions (EE) for t-statistic as a function of x
(quantile).
Includes short (for ordinary one-sample t-statistic) and general versions,
which can be used for ordinary and moderated one- and two-sample t-statistics
and Welch t-test. Variance adjustment r
is incorporated and there is
not need to pass it to the resulting function.
A function F(x)
that takes a quantile x
as an input and
outputs a vector of values for five orders of approximation. If x
is
a vector, each order of approximation will contain length(x)
values.
smpStats
that creates stats
vector from the
sample, and makeQx
that creates q(x)
functions used in
EE terms.
n <- 10 # sample size
# Gamma distribution with shape parameter \code{shp}
shp <- 3
ord <- 3:6 # orders of scaled cumulants
lambdas <- factorial(ord - 1)/shp^((ord - 2)/2)
Ft <- makeFx(lambdas, n, base = "t")
quant <- -(3:5)
Fmat <- matrix(Ft(quant), nrow = length(quant))
rownames(Fmat) <- quant
colnames(Fmat) <- paste("order", 1:5)
Fmat
Ftnorm <- makeFx(lambdas, n, r = 1, base = "normal")
p <- 0.025
Ftnorm(qnorm(p))[1]
# from sample
smp <- rgamma(n, shape = shp) - shp
stats <- smpStats(smp)
t <- sqrt(n)*mean(smp)/sd(smp)
Ft <- makeFx(stats, n, base = "t")
Ft(t)
# two-sample test
n2 <- 8
smp2 <- c(smp, rnorm(n2))
a <- rep(0:1, c(n, n2))
stats2 <- smpStats(smp2, a)
Ft2 <- makeFx(stats2, n, type = "two-sample", base = "t", df = n + n2 - 2)
Ft2(qt(p, df = n + n2 - 2)) # note 1st order not equal to p because r != 1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.