Type: Package
Title: Unbiased Central Moment Estimates
Version: 1.0.1
Maintainer: Inna Gerlovina <innager@berkeley.edu>
Description: Calculates one-sample unbiased central moment estimates and two-sample pooled estimates up to 6th order, including estimates of powers and products of central moments. Provides the machinery for obtaining unbiased central moment estimators beyond 6th order by generating expressions for expectations of raw sample moments and their powers and products. Gerlovina and Hubbard (2019) <doi:10.1080/25742558.2019.1701917>.
Depends: R (≥ 3.4.0)
Imports: stats, utils
License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
Encoding: UTF-8
RoxygenNote: 7.3.1
Suggests: knitr, rmarkdown, testthat
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2024-10-02 07:27:24 UTC; innars
Author: Inna Gerlovina [aut, cre], Alan Hubbard [aut]
Repository: CRAN
Date/Publication: 2024-10-02 08:10:02 UTC

Generate symbolic expression for expectation

Description

Generate a string with symbolic expression for expectation of powers and products of non-central (raw) sample moments of an arbitrary order.

Usage

one_combination(powvect, smpsize = "n")

Arguments

powvect

vector of non-negative integers representing exponents j_1, \dots, j_m of non-central moments in expectation (see "Details"). The position (index) of an element of this vector indicates a corresponding moment, e.g. for E(\overline{X}^5 \overline{X^4}), powvect = c(5, 0, 0, 1). Thus the vector will have m elements if m'th is the highest moment.

smpsize

symbol to be used for sample size. Defaults to "n".

Details

For a zero-mean random variable X and a sample X_1, \dots, X_n, find E(\bar{X}^{j_1} \overline{X^2}^{j_2} \overline{X^3}^{j_3} \cdots \overline{X^m}^{j_m}), where overline{X^k} = 1/n \sum_{i = 1}^n X_i^{k} is a k'th non-central sample moment. The expression is given in terms of sample size and true moments \mu_k of X. These expectations can subsequently be used for generating unbiased central moment estimators of an arbitrary order, Edgeworth expansions, and possibly solving other higher-order problems.

Value

A string representing a symbolic expression for further processing using computer algebra (e.g. with Sage or SymPy), for calculating numeric values, or to be rendered with Latex.

Examples

one_combination(c(5, 0, 2, 1))


Unbiased central moment estimates

Description

Calculate unbiased estimates of central moments and their powers and products up to specified order.

Usage

uM(smp, order)

Arguments

smp

sample.

order

highest order of the estimates to calclulate. Estimates of lower orders will be included.

Details

Unbiased estimates up to the 6th order can be calculated. Second and third orders contain estimates of the variance and third central moment, fourth order includes estimates of fourth moment and squared variance (\mu_2^2), fifth order - of fifth moment and a product of second and third moments (\mu_2 \mu_3), sixth order - of sixth moment, a product of second and fourth moments (\mu_2 \mu_4), squared third moment (\mu_3^2), and cubed variance (\mu_2^3).

Value

A named vector of estimates of central moments and their powers and products up to order. The highest order available is 6th. The names of the elements are "M2", "M3", "M4", "M5", "M6" for corresponding central moments, "M2M3", "M2M4" for products of the moments (second and third, second and fourth), and "M2pow2", "M2pow3", "M3pow2" for powers of the moments - corresponding to estimates of squared variance, cubed variance, and squared third moment.

References

Gerlovina, I. and Hubbard, A.E. (2019). Computer algebra and algorithms for unbiased moment estimation of arbitrary order. Cogent Mathematics & Statistics, 6(1).

See Also

uMpool for two-sample pooled estimates.

Examples

smp <- rgamma(10, shape = 3)
uM(smp, 6)

Unbiased central moment estimates

Description

Calculate unbiased estimates of central moments and their powers and products.

Usage

uM2(m2, n)

Arguments

m2

naive biased variance estimate m_2 = 1/n \sum_{i = 1}^n ((X_i - \bar{X})^2 for a vector X.

n

sample size.

Value

Unbiased variance estimate.

See Also

Other unbiased estimates (one-sample): uM2M3(), uM2M4(), uM2pow2(), uM2pow3(), uM3(), uM3pow2(), uM4(), uM5(), uM6()

Examples

n <- 10
smp <- rgamma(n, shape = 3)
m <- mean(smp)
m <- c(m, mean((smp - m[1])^2))
uM2(m[2], n) - var(smp)

Unbiased central moment estimates

Description

Calculate unbiased estimates of central moments and their powers and products.

Usage

uM2M3(m2, m3, m5, n)

Arguments

m2

naive biased variance estimate m_2 = 1/n \sum_{i = 1}^n ((X_i - \bar{X})^2 for a vector X.

m3

naive biased third central moment estimate m_3 = 1/n \sum_{i = 1}^n ((X_i - \bar{X})^3 for a vector X.

m5

naive biased fifth central moment estimate m_5 = \sum_{i = 1}^n ((X_i - \bar{X})^5 for a vector X.

n

sample size.

Value

Unbiased estimate of a product of second and third central moments \mu_2 \mu_3, where \mu_2 and \mu_3 are second and third central moments respectively.

See Also

Other unbiased estimates (one-sample): uM2(), uM2M4(), uM2pow2(), uM2pow3(), uM3(), uM3pow2(), uM4(), uM5(), uM6()

Examples

n <- 10
smp <- rgamma(n, shape = 3)
m <- mean(smp)
for (j in 2:5) {
  m <- c(m, mean((smp - m[1])^j))
}
uM2M3(m[2], m[3], m[5], n)

Pooled central moment estimates - two-sample

Description

Calculate pooled unbiased estimates of central moments and their powers and products.

Usage

uM2M3pool(m2, m3, m5, n_x, n_y)

Arguments

m2

naive biased variance estimate m_2 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^2 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^2 for vectors X and Y.

m3

naive biased third central moment estimate m_3 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^3 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^3 for vectors X and Y.

m5

naive biased fifth central moment estimate m_5 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^5 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^5 for vectors X and Y.

n_x

number of observations in the first group.

n_y

number of observations in the second group.

Value

Pooled estimate of a product of second and third central moments \mu_2 \mu_3, where \mu_2 and \mu_3 are second and third central moments respectively.

See Also

Other pooled estimates (two-sample): uM2M4pool(), uM2pool(), uM2pow2pool(), uM2pow3pool(), uM3pool(), uM3pow2pool(), uM4pool(), uM5pool(), uM6pool()

Examples

nx <- 10
ny <- 8
shp <- 3
smpx <- rgamma(nx, shape = shp) - shp
smpy <- rgamma(ny, shape = shp)
mx <- mean(smpx)
my <- mean(smpy)
m  <- numeric(5)
for (j in 2:5) {
  m[j] <- mean(c((smpx - mx)^j, (smpy - my)^j))
}
uM2M3pool(m[2], m[3], m[5], nx, ny)

Unbiased central moment estimates

Description

Calculate unbiased estimates of central moments and their powers and products.

Usage

uM2M4(m2, m3, m4, m6, n)

Arguments

m2

naive biased variance estimate m_2 = 1/n \sum_{i = 1}^n ((X_i - \bar{X})^2 for a vector X.

m3

naive biased third central moment estimate m_3 = 1/n \sum_{i = 1}^n ((X_i - \bar{X})^3 for a vector X.

m4

naive biased fourth central moment estimate m_4 = 1/n \sum_{i = 1}^n ((X_i - \bar{X})^4 for a vector X.

m6

naive biased sixth central moment estimate m_6 = 1/n \sum_{i = 1}^n ((X_i - \bar{X})^6 for a vector X.

n

sample size.

Value

Unbiased estimate of a product of second and fourth central moments \mu_2 \mu_4, where \mu_2 and \mu_4 are second and fourth central moments respectively.

See Also

Other unbiased estimates (one-sample): uM2(), uM2M3(), uM2pow2(), uM2pow3(), uM3(), uM3pow2(), uM4(), uM5(), uM6()

Examples

n <- 10
smp <- rgamma(n, shape = 3)
m <- mean(smp)
for (j in 2:6) {
  m <- c(m, mean((smp - m[1])^j))
}
uM2M4(m[2], m[3], m[4], m[6], n)

Pooled central moment estimates - two-sample

Description

Calculate pooled unbiased estimates of central moments and their powers and products.

Usage

uM2M4pool(m2, m3, m4, m6, n_x, n_y)

Arguments

m2

naive biased variance estimate m_2 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^2 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^2 for vectors X and Y.

m3

naive biased third central moment estimate m_3 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^3 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^3 for vectors X and Y.

m4

naive biased fourth central moment estimate m_4 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^4 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^4 for vectors X and Y.

m6

naive biased sixth central moment estimate m_6 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^6 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^6 for vectors X and Y.

n_x

number of observations in the first group.

n_y

number of observations in the second group.

Value

Pooled estimate of a product of second and fourth central moments \mu_2 \mu_4, where \mu_2 and \mu_4 are second and fourth central moments respectively.

See Also

Other pooled estimates (two-sample): uM2M3pool(), uM2pool(), uM2pow2pool(), uM2pow3pool(), uM3pool(), uM3pow2pool(), uM4pool(), uM5pool(), uM6pool()

Examples

nx <- 10
ny <- 8
shp <- 3
smpx <- rgamma(nx, shape = shp) - shp
smpy <- rgamma(ny, shape = shp)
mx <- mean(smpx)
my <- mean(smpy)
m  <- numeric(6)
for (j in 2:6) {
  m[j] <- mean(c((smpx - mx)^j, (smpy - my)^j))
}
uM2M4pool(m[2], m[3], m[4], m[6], nx, ny)

Pooled central moment estimates - two-sample

Description

Calculate pooled unbiased estimates of central moments and their powers and products.

Usage

uM2pool(m2, n_x, n_y)

Arguments

m2

naive biased variance estimate m_2 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^2 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^2 for vectors X and Y.

n_x

number of observations in the first group.

n_y

number of observations in the second group.

Value

Pooled variance estimate.

See Also

Other pooled estimates (two-sample): uM2M3pool(), uM2M4pool(), uM2pow2pool(), uM2pow3pool(), uM3pool(), uM3pow2pool(), uM4pool(), uM5pool(), uM6pool()

Examples

nx <- 10
ny <- 8
shp <- 3
smpx <- rgamma(nx, shape = shp) - shp
smpy <- rgamma(ny, shape = shp)
m2 <- mean(c((smpx - mean(smpx))^2, (smpy - mean(smpy))^2))
uM2pool(m2, nx, ny)

Unbiased central moment estimates

Description

Calculate unbiased estimates of central moments and their powers and products.

Usage

uM2pow2(m2, m4, n)

Arguments

m2

naive biased variance estimate m_2 = 1/n \sum_{i = 1}^n ((X_i - \bar{X})^2 for a vector X.

m4

naive biased fourth central moment estimate m_4 = 1/n \sum_{i = 1}^n ((X_i - \bar{X})^4 for a vector X.

n

sample size.

Value

Unbiased estimate of squared variance \mu_2^2, where \mu_2 is a variance.

See Also

Other unbiased estimates (one-sample): uM2(), uM2M3(), uM2M4(), uM2pow3(), uM3(), uM3pow2(), uM4(), uM5(), uM6()

Examples

n <- 10
smp <- rgamma(n, shape = 3)
m <- mean(smp)
for (j in 2:4) {
  m <- c(m, mean((smp - m[1])^j))
}
uM2pow2(m[2], m[4], n)

Pooled central moment estimates - two-sample

Description

Calculate pooled unbiased estimates of central moments and their powers and products.

Usage

uM2pow2pool(m2, m4, n_x, n_y)

Arguments

m2

naive biased variance estimate m_2 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^2 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^2 for vectors X and Y.

m4

naive biased fourth central moment estimate m_4 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^4 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^4 for vectors X and Y.

n_x

number of observations in the first group.

n_y

number of observations in the second group.

Value

Pooled estimate of squared variance \mu_2^2, where \mu_2 is a variance.

See Also

Other pooled estimates (two-sample): uM2M3pool(), uM2M4pool(), uM2pool(), uM2pow3pool(), uM3pool(), uM3pow2pool(), uM4pool(), uM5pool(), uM6pool()

Examples

nx <- 10
ny <- 8
shp <- 3
smpx <- rgamma(nx, shape = shp) - shp
smpy <- rgamma(ny, shape = shp)
mx <- mean(smpx)
my <- mean(smpy)
m  <- numeric(4)
for (j in 2:4) {
  m[j] <- mean(c((smpx - mx)^j, (smpy - my)^j))
}
uM2pow2pool(m[2], m[4], nx, ny)

Unbiased central moment estimates

Description

Calculate unbiased estimates of central moments and their powers and products.

Usage

uM2pow3(m2, m3, m4, m6, n)

Arguments

m2

naive biased variance estimate m_2 = 1/n \sum_{i = 1}^n ((X_i - \bar{X})^2 for a vector X.

m3

naive biased third central moment estimate m_3 = 1/n \sum_{i = 1}^n ((X_i - \bar{X})^3 for a vector X.

m4

naive biased fourth central moment estimate m_4 = 1/n \sum_{i = 1}^n ((X_i - \bar{X})^4 for a vector X.

m6

naive biased sixth central moment estimate m_6 = 1/n \sum_{i = 1}^n ((X_i - \bar{X})^6 for a vector X.

n

sample size.

Value

Unbiased estimate of cubed second central moment \mu_2^3, where \mu_2 is a variance.

See Also

Other unbiased estimates (one-sample): uM2(), uM2M3(), uM2M4(), uM2pow2(), uM3(), uM3pow2(), uM4(), uM5(), uM6()

Examples

n <- 10
smp <- rgamma(n, shape = 3)
m <- mean(smp)
for (j in 2:6) {
  m <- c(m, mean((smp - m[1])^j))
}
uM2pow3(m[2], m[3], m[4], m[6], n)

Pooled central moment estimates - two-sample

Description

Calculate pooled unbiased estimates of central moments and their powers and products.

Usage

uM2pow3pool(m2, m3, m4, m6, n_x, n_y)

Arguments

m2

naive biased variance estimate m_2 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^2 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^2 for vectors X and Y.

m3

naive biased third central moment estimate m_3 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^3 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^3 for vectors X and Y.

m4

naive biased fourth central moment estimate m_4 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^4 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^4 for vectors X and Y.

m6

naive biased sixth central moment estimate m_6 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^6 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^6 for vectors X and Y.

n_x

number of observations in the first group.

n_y

number of observations in the second group.

Value

Pooled estimate of cubed variance central moment \mu_2^3, where \mu_2 is a variance.

See Also

Other pooled estimates (two-sample): uM2M3pool(), uM2M4pool(), uM2pool(), uM2pow2pool(), uM3pool(), uM3pow2pool(), uM4pool(), uM5pool(), uM6pool()

Examples

nx <- 10
ny <- 8
shp <- 3
smpx <- rgamma(nx, shape = shp) - shp
smpy <- rgamma(ny, shape = shp)
mx <- mean(smpx)
my <- mean(smpy)
m  <- numeric(6)
for (j in 2:6) {
  m[j] <- mean(c((smpx - mx)^j, (smpy - my)^j))
}
uM2pow3pool(m[2], m[3], m[4], m[6], nx, ny)

Unbiased central moment estimates

Description

Calculate unbiased estimates of central moments and their powers and products.

Usage

uM3(m3, n)

Arguments

m3

naive biased third central moment estimate m_3 = 1/n \sum_{i = 1}^n ((X_i - \bar{X})^3 for a vector X.

n

sample size.

Value

Unbiased estimate of a third central moment.

See Also

Other unbiased estimates (one-sample): uM2(), uM2M3(), uM2M4(), uM2pow2(), uM2pow3(), uM3pow2(), uM4(), uM5(), uM6()

Examples

n <- 10
smp <- rgamma(n, shape = 3)
m <- mean(smp)
for (j in 2:3) {
  m <- c(m, mean((smp - m[1])^j))
}
uM3(m[3], n)

Pooled central moment estimates - two-sample

Description

Calculate pooled unbiased estimates of central moments and their powers and products.

Usage

uM3pool(m3, n_x, n_y)

Arguments

m3

naive biased third central moment estimate m_3 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^3 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^3 for vectors X and Y.

n_x

number of observations in the first group.

n_y

number of observations in the second group.

Value

Pooled estimate of a third central moment.

See Also

Other pooled estimates (two-sample): uM2M3pool(), uM2M4pool(), uM2pool(), uM2pow2pool(), uM2pow3pool(), uM3pow2pool(), uM4pool(), uM5pool(), uM6pool()

Examples

nx <- 10
ny <- 8
shp <- 3
smpx <- rgamma(nx, shape = shp) - shp
smpy <- rgamma(ny, shape = shp)
mx <- mean(smpx)
my <- mean(smpy)
m  <- numeric(3)
for (j in 2:3) {
  m[j] <- mean(c((smpx - mx)^j, (smpy - my)^j))
}
uM3pool(m[3], nx, ny)

Unbiased central moment estimates

Description

Calculate unbiased estimates of central moments and their powers and products.

Usage

uM3pow2(m2, m3, m4, m6, n)

Arguments

m2

naive biased variance estimate m_2 = 1/n \sum_{i = 1}^n ((X_i - \bar{X})^2 for a vector X.

m3

naive biased third central moment estimate m_3 = 1/n \sum_{i = 1}^n ((X_i - \bar{X})^3 for a vector X.

m4

naive biased fourth central moment estimate m_4 = 1/n \sum_{i = 1}^n ((X_i - \bar{X})^4 for a vector X.

m6

naive biased sixth central moment estimate m_6 = 1/n \sum_{i = 1}^n ((X_i - \bar{X})^6 for a vector X.

n

sample size.

Value

Unbiased estimate of squared third central moment \mu_3^2, where \mu_3 is a third central moment.

See Also

Other unbiased estimates (one-sample): uM2(), uM2M3(), uM2M4(), uM2pow2(), uM2pow3(), uM3(), uM4(), uM5(), uM6()

Examples

n <- 10
smp <- rgamma(n, shape = 3)
m <- mean(smp)
for (j in 2:6) {
  m <- c(m, mean((smp - m[1])^j))
}
uM3pow2(m[2], m[3], m[4], m[6], n)

Pooled central moment estimates - two-sample

Description

Calculate pooled unbiased estimates of central moments and their powers and products.

Usage

uM3pow2pool(m2, m3, m4, m6, n_x, n_y)

Arguments

m2

naive biased variance estimate m_2 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^2 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^2 for vectors X and Y.

m3

naive biased third central moment estimate m_3 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^3 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^3 for vectors X and Y.

m4

naive biased fourth central moment estimate m_4 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^4 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^4 for vectors X and Y.

m6

naive biased sixth central moment estimate m_6 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^6 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^6 for vectors X and Y.

n_x

number of observations in the first group.

n_y

number of observations in the second group.

Value

Pooled estimate of squared third central moment \mu_3^2, where \mu_3 is a third central moment.

See Also

Other pooled estimates (two-sample): uM2M3pool(), uM2M4pool(), uM2pool(), uM2pow2pool(), uM2pow3pool(), uM3pool(), uM4pool(), uM5pool(), uM6pool()

Examples

nx <- 10
ny <- 8
shp <- 3
smpx <- rgamma(nx, shape = shp) - shp
smpy <- rgamma(ny, shape = shp)
mx <- mean(smpx)
my <- mean(smpy)
m  <- numeric(6)
for (j in 2:6) {
  m[j] <- mean(c((smpx - mx)^j, (smpy - my)^j))
}
uM3pow2pool(m[2], m[3], m[4], m[6], nx, ny)

Unbiased central moment estimates

Description

Calculate unbiased estimates of central moments and their powers and products.

Usage

uM4(m2, m4, n)

Arguments

m2

naive biased variance estimate m_2 = 1/n \sum_{i = 1}^n ((X_i - \bar{X})^2 for a vector X.

m4

naive biased fourth central moment estimate m_4 = 1/n \sum_{i = 1}^n ((X_i - \bar{X})^4 for a vector X.

n

sample size.

Value

Unbiased estimate of a fourth central moment.

See Also

Other unbiased estimates (one-sample): uM2(), uM2M3(), uM2M4(), uM2pow2(), uM2pow3(), uM3(), uM3pow2(), uM5(), uM6()

Examples

n <- 10
smp <- rgamma(n, shape = 3)
m <- mean(smp)
for (j in 2:4) {
  m <- c(m, mean((smp - m[1])^j))
}
uM4(m[2], m[4], n)

Pooled central moment estimates - two-sample

Description

Calculate pooled unbiased estimates of central moments and their powers and products.

Usage

uM4pool(m2, m4, n_x, n_y)

Arguments

m2

naive biased variance estimate m_2 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^2 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^2 for vectors X and Y.

m4

naive biased fourth central moment estimate m_4 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^4 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^4 for vectors X and Y.

n_x

number of observations in the first group.

n_y

number of observations in the second group.

Value

Pooled estimate of a fourth central moment.

See Also

Other pooled estimates (two-sample): uM2M3pool(), uM2M4pool(), uM2pool(), uM2pow2pool(), uM2pow3pool(), uM3pool(), uM3pow2pool(), uM5pool(), uM6pool()

Examples

nx <- 10
ny <- 8
shp <- 3
smpx <- rgamma(nx, shape = shp) - shp
smpy <- rgamma(ny, shape = shp)
mx <- mean(smpx)
my <- mean(smpy)
m  <- numeric(4)
for (j in 2:4) {
  m[j] <- mean(c((smpx - mx)^j, (smpy - my)^j))
}
uM4pool(m[2], m[4], nx, ny)

Unbiased central moment estimates

Description

Calculate unbiased estimates of central moments and their powers and products.

Usage

uM5(m2, m3, m5, n)

Arguments

m2

naive biased variance estimate m_2 = 1/n \sum_{i = 1}^n ((X_i - \bar{X})^2 for a vector X.

m3

naive biased third central moment estimate m_3 = 1/n \sum_{i = 1}^n ((X_i - \bar{X})^3 for a vector X.

m5

naive biased fifth central moment estimate m_5 = \sum_{i = 1}^n ((X_i - \bar{X})^5 for a vector X.

n

sample size.

Value

Unbiased estimate of a fifth central moment.

See Also

Other unbiased estimates (one-sample): uM2(), uM2M3(), uM2M4(), uM2pow2(), uM2pow3(), uM3(), uM3pow2(), uM4(), uM6()

Examples

n <- 10
smp <- rgamma(n, shape = 3)
m <- mean(smp)
for (j in 2:5) {
  m <- c(m, mean((smp - m[1])^j))
}
uM5(m[2], m[3], m[5], n)

Pooled central moment estimates - two-sample

Description

Calculate pooled unbiased estimates of central moments and their powers and products.

Usage

uM5pool(m2, m3, m5, n_x, n_y)

Arguments

m2

naive biased variance estimate m_2 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^2 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^2 for vectors X and Y.

m3

naive biased third central moment estimate m_3 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^3 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^3 for vectors X and Y.

m5

naive biased fifth central moment estimate m_5 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^5 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^5 for vectors X and Y.

n_x

number of observations in the first group.

n_y

number of observations in the second group.

Value

Pooled estimate of a fifth central moment.

See Also

Other pooled estimates (two-sample): uM2M3pool(), uM2M4pool(), uM2pool(), uM2pow2pool(), uM2pow3pool(), uM3pool(), uM3pow2pool(), uM4pool(), uM6pool()

Examples

nx <- 10
ny <- 8
shp <- 3
smpx <- rgamma(nx, shape = shp) - shp
smpy <- rgamma(ny, shape = shp)
mx <- mean(smpx)
my <- mean(smpy)
m  <- numeric(5)
for (j in 2:5) {
  m[j] <- mean(c((smpx - mx)^j, (smpy - my)^j))
}
uM5pool(m[2], m[3], m[5], nx, ny)

Unbiased central moment estimates

Description

Calculate unbiased estimates of central moments and their powers and products.

Usage

uM6(m2, m3, m4, m6, n)

Arguments

m2

naive biased variance estimate m_2 = 1/n \sum_{i = 1}^n ((X_i - \bar{X})^2 for a vector X.

m3

naive biased third central moment estimate m_3 = 1/n \sum_{i = 1}^n ((X_i - \bar{X})^3 for a vector X.

m4

naive biased fourth central moment estimate m_4 = 1/n \sum_{i = 1}^n ((X_i - \bar{X})^4 for a vector X.

m6

naive biased sixth central moment estimate m_6 = 1/n \sum_{i = 1}^n ((X_i - \bar{X})^6 for a vector X.

n

sample size.

Value

Unbiased estimate of a sixth central moment.

See Also

Other unbiased estimates (one-sample): uM2(), uM2M3(), uM2M4(), uM2pow2(), uM2pow3(), uM3(), uM3pow2(), uM4(), uM5()

Examples

n <- 10
smp <- rgamma(n, shape = 3)
m <- mean(smp)
for (j in 2:6) {
  m <- c(m, mean((smp - m[1])^j))
}
uM6(m[2], m[3], m[4], m[6], n)

Pooled central moment estimates - two-sample

Description

Calculate pooled unbiased estimates of central moments and their powers and products.

Usage

uM6pool(m2, m3, m4, m6, n_x, n_y)

Arguments

m2

naive biased variance estimate m_2 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^2 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^2 for vectors X and Y.

m3

naive biased third central moment estimate m_3 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^3 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^3 for vectors X and Y.

m4

naive biased fourth central moment estimate m_4 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^4 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^4 for vectors X and Y.

m6

naive biased sixth central moment estimate m_6 = 1/(n_x + n_y) \sum_{i = 1}^{n_x} ((X_i - \bar{X})^6 + \sum_{i = 1}^{n_y} ((Y_i - \bar{Y})^6 for vectors X and Y.

n_x

number of observations in the first group.

n_y

number of observations in the second group.

Value

Unbiased estimate of a sixth central moment.

See Also

Other pooled estimates (two-sample): uM2M3pool(), uM2M4pool(), uM2pool(), uM2pow2pool(), uM2pow3pool(), uM3pool(), uM3pow2pool(), uM4pool(), uM5pool()

Examples

nx <- 10
ny <- 8
shp <- 3
smpx <- rgamma(nx, shape = shp) - shp
smpy <- rgamma(ny, shape = shp)
mx <- mean(smpx)
my <- mean(smpy)
m  <- numeric(6)
for (j in 2:6) {
  m[j] <- mean(c((smpx - mx)^j, (smpy - my)^j))
}
uM6pool(m[2], m[3], m[4], m[6], nx, ny)

Pooled central moment estimates - two-sample

Description

Calculate unbiased pooled estimates of central moments and their powers and products up to specified order.

Usage

uMpool(smp, a, order)

Arguments

smp

sample.

a

vector of the same length as smp specifying categories of observations (should contain two unique values).

order

highest order of the estimates to calclulate. Estimates of lower orders will be included.

Details

Pooled estimates up to the 6th order can be calculated. Second and third orders contain estimates of the variance and third central moment, fourth order includes estimates of fourth moment and squared variance (\mu_2^2), fifth order - of fifth moment and a product of second and third moments (\mu_2 \mu_3), sixth order - of sixth moment, a product of second and fourth moments (\mu_2 \mu_4), squared third moment (\mu_3^2), and cubed variance (\mu_2^3).

Value

A named vector of estimates of central moments and their powers and products up to order. The highest order available is 6th. The names of the elements are "M2", "M3", "M4", "M5", "M6" for corresponding central moments, "M2M3", "M2M4" for products of the moments (second and third, second and fourth), and "M2pow2", "M2pow3", "M3pow2" for powers of the moments - corresponding to estimates of squared variance, cubed variance, and squared third moment.

References

Gerlovina, I. and Hubbard, A.E. (2019). Computer algebra and algorithms for unbiased moment estimation of arbitrary order. Cogent Mathematics & Statistics, 6(1).

See Also

uM for one-sample unbiased estimates.

Examples

nsmp <- 23
smp <- rgamma(nsmp, shape = 3)
treatment <- sample(0:1, size = nsmp, replace = TRUE)
uMpool(smp, treatment, 6)