Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

skewness

Compute Skewness and (Excess) Kurtosis


Description

Compute Skewness and (Excess) Kurtosis

Usage

skewness(x, na.rm = TRUE, type = "2", iterations = NULL, ...)

kurtosis(x, na.rm = TRUE, type = "2", iterations = NULL, ...)

## S3 method for class 'parameters_kurtosis'
print(x, digits = 3, test = FALSE, ...)

## S3 method for class 'parameters_skewness'
print(x, digits = 3, test = FALSE, ...)

## S3 method for class 'parameters_skewness'
summary(object, test = FALSE, ...)

## S3 method for class 'parameters_kurtosis'
summary(object, test = FALSE, ...)

Arguments

x

A numeric vector or data.frame.

na.rm

Remove missing values.

type

Type of algorithm for computing skewness. May be one of 1 (or "1", "I" or "classic"), 2 (or "2", "II" or "SPSS" or "SAS") or 3 (or "3", "III" or "Minitab"). See 'Details'.

iterations

The number of bootstrap replicates for computing standard errors. If NULL (default), parametric standard errors are computed. See 'Details'.

...

Arguments passed to or from other methods.

digits

Number of decimal places.

test

Logical, if TRUE, tests if skewness or kurtosis is significantly different from zero.

object

An object returned by skewness() or kurtosis().

Details

Skewness

Symmetric distributions have a skewness around zero, while a negative skewness values indicates a "left-skewed" distribution, and a positive skewness values indicates a "right-skewed" distribution. Examples for the relationship of skewness and distributions are:

  • Normal distribution (and other symmetric distribution) has a skewness of 0

  • Half-normal distribution has a skewness just below 1

  • Exponential distribution has a skewness of 2

  • Lognormal distribution can have a skewness of any positive value, depending on its parameters

(https://en.wikipedia.org/wiki/Skewness)

Types of Skewness

skewness() supports three different methods for estimating skewness, as discussed in Joanes and Gill (1988):

  • Type "1" is the "classical" method, which is g1 = (sum((x - mean(x))^3) / n) / (sum((x - mean(x))^2) / n)^1.5

  • Type "2" first calculates the type-1 skewness, than adjusts the result: G1 = g1 * sqrt(n * (n - 1)) / (n - 2). This is what SAS and SPSS usually return

  • Type "3" first calculates the type-1 skewness, than adjusts the result: b1 = g1 * ((1 - 1 / n))^1.5. This is what Minitab usually returns.

Kurtosis

The kurtosis is a measure of "tailedness" of a distribution. A distribution with a kurtosis values of about zero is called "mesokurtic". A kurtosis value larger than zero indicates a "leptokurtic" distribution with fatter tails. A kurtosis value below zero indicates a "platykurtic" distribution with thinner tails (https://en.wikipedia.org/wiki/Kurtosis).

Types of Kurtosis

kurtosis() supports three different methods for estimating kurtosis, as discussed in Joanes and Gill (1988):

  • Type "1" is the "classical" method, which is g2 = n * sum((x - mean(x))^4) / (sum((x - mean(x))^2)^2) - 3.

  • Type "2" first calculates the type-1 kurtosis, than adjusts the result: G2 = ((n + 1) * g2 + 6) * (n - 1)/((n - 2) * (n - 3)). This is what SAS and SPSS usually return

  • Type "3" first calculates the type-1 kurtosis, than adjusts the result: b2 = (g2 + 3) * (1 - 1 / n)^2 - 3. This is what Minitab usually returns.

Standard Errors

It is recommended to compute empirical (bootstrapped) standard errors (via the iterations argument) than relying on analytic standard errors (Wright & Herrington, 2011).

Value

Values of skewness or kurtosis.

References

  • D. N. Joanes and C. A. Gill (1998). Comparing measures of sample skewness and kurtosis. The Statistician, 47, 183–189.

  • Wright, D. B., & Herrington, J. A. (2011). Problematic standard errors and confidence intervals for skewness and kurtosis. Behavior research methods, 43(1), 8-17.

Examples

skewness(rnorm(1000))
kurtosis(rnorm(1000))

parameters

Processing of Model Parameters

v0.13.0
GPL-3
Authors
Daniel Lüdecke [aut, cre] (<https://orcid.org/0000-0002-8895-3206>, @strengejacke), Dominique Makowski [aut] (<https://orcid.org/0000-0001-5375-9967>), Mattan S. Ben-Shachar [aut] (<https://orcid.org/0000-0002-4287-4801>), Indrajeet Patil [aut] (<https://orcid.org/0000-0003-1995-6531>, @patilindrajeets), Søren Højsgaard [aut], Zen J. Lau [ctb], Vincent Arel-Bundock [ctb] (<https://orcid.org/0000-0003-1995-6531>, @vincentab), Jeffrey Girard [ctb] (<https://orcid.org/0000-0002-7359-3746>, @jeffreymgirard)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.