Package 'param2moment'

Title: Raw, Central and Standardized Moments of Parametric Distributions
Description: To calculate the raw, central and standardized moments from distribution parameters. To solve the distribution parameters based on user-provided mean, standard deviation, skewness and kurtosis. Normal, skew-normal, skew-t and Tukey g-&-h distributions are supported, for now.
Authors: Tingting Zhan [aut, cre, cph]
Maintainer: Tingting Zhan <[email protected]>
License: GPL-2
Version: 0.1.2
Built: 2024-10-31 22:24:28 UTC
Source: CRAN

Help Index


Moments of Tukey gg-&-hh Distribution

Description

Moments of Tukey gg-&-hh distribution.

Usage

moment_GH(A = 0, B = 1, g = 0, h = 0)

Arguments

A

numeric scalar or vector, location parameter AA

B

numeric scalar or vector, scale parameter BB

g

numeric scalar or vector, skewness parameter gg

h

numeric scalar or vector, elongation parameter hh

Value

Function moment_GH returns a moment object.

References

Raw moments of Tukey gg-&-hh distribution: doi:10.1002/9781118150702.ch11

Examples

A = 3; B = 1.5; g = .7; h = .01
moment_GH(A = A, B = B, g = 0, h = h)
moment_GH(A = A, B = B, g = g, h = 0)
moment_GH(A = A, B = B, g = g, h = h)

Moments of Normal Distribution

Description

Moments of normal distribution, parameter nomenclature follows dnorm function.

Usage

moment_norm(mean = 0, sd = 1)

Arguments

mean

numeric scalar or vector, mean parameter μ\mu

sd

numeric scalar or vector, standard deviation σ\sigma

Value

Function moment_norm returns a moment object.

Examples

moment_norm(mean = 1.2, sd = .7)

Moments of Skew-Normal Distribution

Description

Moments of skew-normal distribution, parameter nomenclature follows dsn function.

Usage

moment_sn(xi = 0, omega = 1, alpha = 0)

Arguments

xi

numeric scalar or vector, location parameter ξ\xi

omega

numeric scalar or vector, scale parameter ω\omega

alpha

numeric scalar or vector, slant parameter α\alpha

Value

Function moment_sn returns a moment object.

Examples

xi = 2; omega = 1.3; alpha = 3
moment_sn(xi, omega, alpha)
curve(sn::dsn(x, xi = 2, omega = 1.3, alpha = 3), from = 0, to = 6)

Moments of Skew-tt Distribution

Description

Moments of skew-tt distribution, parameter nomenclature follows dst function.

Usage

moment_st(xi = 0, omega = 1, alpha = 0, nu = Inf)

Arguments

xi

numeric scalar or vector, location parameter ξ\xi

omega

numeric scalar or vector, scale parameter ω\omega

alpha

numeric scalar or vector, slant parameter α\alpha

nu

numeric scalar or vector, degree of freedom ν\nu

Value

Function moment_st returns a moment object.

References

Raw moments of skew-tt: https://arxiv.org/abs/0911.2342

Examples

xi = 2; omega = 1.3; alpha = 3; nu = 6
curve(sn::dst(x, xi = xi, omega = omega, alpha = alpha, nu = nu), from = 0, to = 6)
moment_st(xi, omega, alpha, nu)

Raw, Central and Standardized Moments, and other Distribution Characteristics

Description

Up to 4th raw E(Yn)\text{E}(Y^n), central E[(Yμ)n]\text{E}[(Y-\mu)^n] and standardized moments E[(Yμ)n/σn]\text{E}[(Y-\mu)^n/\sigma^n] of the random variable

Y=(Xlocation)/scaleY = (X - \text{location})/\text{scale}

Also, the mean, standard deviation, skewness and excess kurtosis of the random variable XX.

Details

For Y=(Xlocation)/scaleY = (X - \text{location})/\text{scale}, let μ=E(Y)\mu = \text{E}(Y), then, according to Binomial theorem, the 2nd to 4th central moments of YY are,

E[(Yμ)2]=E(Y2)2μE(Y)+μ2=E(Y2)μ2\text{E}[(Y-\mu)^2] = \text{E}(Y^2) - 2\mu \text{E}(Y) + \mu^2 = \text{E}(Y^2) - \mu^2

E[(Yμ)3]=E(Y3)3μE(Y2)+3μ2E(Y)μ3=E(Y3)3μE(Y2)+2μ3\text{E}[(Y-\mu)^3] = \text{E}(Y^3) - 3\mu \text{E}(Y^2) + 3\mu^2 \text{E}(Y) - \mu^3 = \text{E}(Y^3) - 3\mu \text{E}(Y^2) + 2\mu^3

E[(Yμ)4]=E(Y4)4μE(Y3)+6μ2E(Y2)4μ3E(Y)+μ4=E(Y4)4μE(Y3)+6μ2E(Y2)3μ4\text{E}[(Y-\mu)^4] = \text{E}(Y^4) - 4\mu \text{E}(Y^3) + 6\mu^2 \text{E}(Y^2) - 4\mu^3 \text{E}(Y) + \mu^4 = \text{E}(Y^4) - 4\mu \text{E}(Y^3) + 6\mu^2 \text{E}(Y^2) - 3\mu^4

The distribution characteristics of YY are,

μY=μ\mu_Y = \mu

σY=E[(Yμ)2]\sigma_Y = \sqrt{\text{E}[(Y-\mu)^2]}

skewnessY=E[(Yμ)3]/σY3\text{skewness}_Y = \text{E}[(Y-\mu)^3] / \sigma^3_Y

kurtosisY=E[(Yμ)4]/σY43\text{kurtosis}_Y = \text{E}[(Y-\mu)^4] / \sigma^4_Y - 3

The distribution characteristics of XX are μX=location+scaleμY\mu_X = \text{location} + \text{scale}\cdot \mu_Y, σX=scaleσY\sigma_X = \text{scale}\cdot \sigma_Y, skewnessX=skewnessY\text{skewness}_X = \text{skewness}_Y, and kurtosisX=kurtosisY\text{kurtosis}_X = \text{kurtosis}_Y.

Slots

distname

character scalar, name of distribution, e.g., 'norm' for normal, 'sn' for skew-normal, 'st' for skew-tt, and 'GH' for Tukey gg-&-hh distribution, following the nomenclature of dnorm, dsn, dst and QuantileGH::dGH

location,scale

numeric scalars or vectors, location and scale parameters

mu

numeric scalar or vector, 1st raw moment μ=E(Y)\mu = \text{E}(Y). Note that the 1st central moment E(Yμ)\text{E}(Y-\mu) and standardized moment E(Yμ)/σ\text{E}(Y-\mu)/\sigma are both 0.

raw2,raw3,raw4

numeric scalars or vectors, 2nd or higher raw moments E(Yn)\text{E}(Y^n), n2n\geq 2

central2,central3,central4

numeric scalars or vectors, 2nd or higher central moments, σ2=E[(Yμ)2]\sigma^2 = \text{E}[(Y-\mu)^2] and E[(Yμ)n]\text{E}[(Y-\mu)^n], n3n\geq 3

standardized3,standardized4

numeric scalars or vectors, 3rd or higher standardized moments, skewness E[(Yμ)3]/σ3\text{E}[(Y-\mu)^3]/\sigma^3 and kurtosis E[(Yμ)4]/σ4\text{E}[(Y-\mu)^4]/\sigma^4. Note that the 2nd standardized moment is 1

Note

Potential name clash with function e1071::moment.


Solve Tukey gg-&-hh Parameters from Moments

Description

Solve Tukey gg-, hh- and gg-&-hh distribution parameters from mean, standard deviation, skewness and kurtosis.

Usage

moment2GH(mean = 0, sd = 1, skewness, kurtosis)

moment2GH_h_demo(sd = 1, kurtosis)

moment2GH_g_demo(mean = 0, sd = 1, skewness)

Arguments

mean

numeric scalar, mean μ\mu, default value 0

sd

numeric scalar, standard deviation σ\sigma, default value 1

skewness

numeric scalar

kurtosis

numeric scalar

Details

Function moment2GH solves the location AA, scale BB, skewness gg and elongation hh parameters of Tukey gg-&-hh distribution, from user-specified mean μ\mu (default 0), standard deviation σ\sigma (default 1), skewness and kurtosis.

An educational and demonstration function moment2GH_h_demo solves (B,h)(B, h) parameters of Tukey hh-distribution, from user-specified σ\sigma and kurtosis. This is a non-skewed distribution, thus the location parameter A=μ=0A=\mu=0, and the skewness parameter g=0g=0.

An educational and demonstration function moment2GH_g_demo solves (A,B,g)(A, B, g) parameters of Tukey gg-distribution, from user-specified μ\mu, σ\sigma and skewness. For this distribution, the elongation parameter h=0h=0.

Value

Function moment2GH returns a length-4 numeric vector (A,B,g,h)(A, B, g, h).

Function moment2GH_h_demo returns a length-2 numeric vector (B,h)(B, h).

Function moment2GH_g_demo returns a length-3 numeric vector (A,B,g)(A, B, g).

Examples

moment2GH(skewness = .2, kurtosis = .3)

moment2GH_h_demo(kurtosis = .3)

moment2GH_g_demo(skewness = .2)

Moment to Parameters: A Batch Process

Description

Converts multiple sets of moments to multiple sets of distribution parameters.

Usage

moment2param(distname, FUN = paste0("moment2", distname), ...)

Arguments

distname

character scalar, distribution name. Currently supported are 'GH' for Tukey gg-&-hh distribution, 'sn' for skew-normal distribution and 'st' for skew-tt distribution

FUN

name or character scalar, (name of) function used to solve the distribution parameters from moments. Default is paste0('moment2', distname), e.g., moment2GH will be used for distname = 'GH'. To use one of the educational functions, specify FUN = moment2GH_g_demo or FUN = 'moment2GH_g_demo'.

...

numeric scalars, some or all of mean, sd, skewness and kurtosis (length will be recycled).

Value

Function moment2param returns a list of numeric vectors.

Examples

skw = c(.2, .5, .8)
krt = c(.5, 1, 1.5)
moment2param(distname = 'GH', skewness = skw, kurtosis = krt)
moment2param(distname = 'st', skewness = skw, kurtosis = krt)

Solve Skew-Normal Parameters from Moments

Description

Solve skew-normal parameters from mean, standard deviation and skewness.

Usage

moment2sn(mean = 0, sd = 1, skewness)

Arguments

mean

numeric scalar, mean μ\mu, default value 0

sd

numeric scalar, standard deviation σ\sigma, default value 1

skewness

numeric scalar

Details

Function moment2sn solves the location ξ\xi, scale ω\omega and slant α\alpha parameters of skew-normal distribution, from user-specified mean μ\mu (default 0), standard deviation σ\sigma (default 1) and skewness.

Value

Function moment2sn returns a length-3 numeric vector (ξ,ω,α)(\xi, \omega, \alpha).

Examples

moment2sn(skewness = .3)

Solve Skew-tt Parameters from Moments

Description

Solve skew-tt parameters from mean, standard deviation, skewness and kurtosis.

Usage

moment2st(mean = 0, sd = 1, skewness, kurtosis)

moment2t_demo(sd = 1, kurtosis)

Arguments

mean

numeric scalar, mean μ\mu, default value 0

sd

numeric scalar, standard deviation σ\sigma, default value 1

skewness

numeric scalar

kurtosis

numeric scalar

Details

Function moment2st solves the location ξ\xi, scale ω\omega, slant α\alpha and degree of freedom ν\nu parameters of skew-tt distribution, from user-specified mean μ\mu (default 0), standard deviation σ\sigma (default 1), skewness and kurtosis.

An educational and demonstration function moment2t_demo solves (ω,ν)(\omega, \nu) parameters of tt-distribution, from user-specified σ\sigma and kurtosis. This is a non-skewed distribution, thus the location parameter ξ=μ=0\xi=\mu=0, and the slant parameter α=0\alpha=0.

Value

Function moment2st returns a length-4 numeric vector (ξ,ω,α,ν)(\xi, \omega, \alpha, \nu).

Function moment2t_demo returns a length-2 numeric vector (ω,ν)(\omega, \nu).

Examples

moment2st(skewness = .2, kurtosis = .3)

moment2t_demo(kurtosis = .3)

Show moment

Description

Print S4 object moment in a pretty manner.

Usage

## S4 method for signature 'moment'
show(object)

Arguments

object

a moment object

Value

The show method for moment object does not have a returned value.