tailDiag: Tail diagnostic for Edgeworth expansions

View source: R/tailDiag.R

tailDiagR Documentation

Tail diagnostic for Edgeworth expansions

Description

Evaluate tail behavior and usability for 2nd - 5th order (terms 1-4) Edgeworth expansions for a t-statistic.

Usage

tailDiag(
  stats,
  n,
  type = "short",
  df = NULL,
  moder = FALSE,
  ncheck = 30,
  lim = c(1, 7),
  verbose = TRUE
)

Arguments

stats

named vector of distribution parameters or estimates needed for Edgeworth expansion. If no names for the vector are provided and the type is "short", elements are assumed to be scaled cumulants \lambda (3 - 6). If the elements are named, the order of the elements is arbitrary. Required names:

  • for ordinary one-sample t-statistic only (type = "short"): "lam3", "lam4", "lam5", "lam6" (scaled cumulants);

  • for more complicated one-sample versions, such as a moderated t-statistic (type = "one-sample"): "mu2", "mu3", "mu4", "mu5", "mu6" (central moments), "A", and "B";

  • for a two-sample t-statistic (type = "two-sample"): "mu_x2", "mu_x3", "mu_x4", "mu_x5", "mu_x6" (central moments for a treatment group), "mu_y2", "mu_y3", "mu_y4", "mu_y5", "mu_y6" (central moments for a control group), "A", "B_x", "B_y", "b_x", and "b_y". Note that if the same distribution is assumed for the two groups, the values for central moments for these groups should be the same (e.g. pooled variance for a second moment).

  • optionally for a moderated t-statistic: "d0" (prior degrees of freedom). Ignored if df is provided.

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.

type

which Edgeworth expansions are to be evaluated: "short" for ordinary one-sample t-statistic, "one-sample" for a more complicated version such as a moderated t-statistic, and "two-sample" for any kind of two-sample t-statistic.

df

degrees of freedom for a first order approximation, a parameter of Student's t-distribution. If not provided, the value will be calculated based on arguments type and moder.

moder

logical value for calculating augmented degrees of freedom for a moderated t-statistic; if TRUE, the value for prior degrees of freedom shoud be included in stats. Ignored if df is provided.

ncheck

number of intervals for tail diagnostic.

lim

Tail region for tail diagnostic. Provide the endpoints for the right tail (positive values).

verbose

if TRUE, the warning message will be printed when the elements of stats are not named.

Details

Determine if the tails of the Edgeworth expansion behave similarly to a cumulative distribution function and therefore can be used for approximating sampling distribution. The results also provide information on the thickness of the tails of that distribution (thicker tail will behave nicely). The function is evaluated according to three criteria: monotonicity, boundedness by 0 and 1, and being no less conservative than the first order approximation (Student's t-distribution).

Both left and right tails are evaluated. t-distribution-based expansions are used.

If values for stats are calculated from a sample and type != "short", it is recommended that smpStats() is used to create stats to make sure that all the necessary statsitics are provided and are not searched for in parent environments.

Value

A matrix of logical values: four columns for orders 2 through 5, two rows for left and right tails.

See Also

smpStats that creates stats vector from the sample.

Examples

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)
tailDiag(lambdas, n)

# from sample
smp <- rgamma(n, shape = 3)
stats <- smpStats(smp)
tailDiag(stats, n)

# two-sample test
n2 <- 8
smp2 <- c(smp, rnorm(n2))
a <- rep(0:1, c(n, n2))
stats2 <- smpStats(smp2, a)
tailDiag(stats2, (n + n2)/2, type = "two-sample")


innager/edgee documentation built on April 24, 2024, 8:14 p.m.