1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/skewness_kurtosis.R
\name{skewness}
\alias{skewness}
\alias{skewness.numeric}
\alias{kurtosis}
\alias{kurtosis.numeric}
\alias{print.parameters_kurtosis}
\alias{print.parameters_skewness}
\alias{summary.parameters_skewness}
\alias{summary.parameters_kurtosis}
\title{Compute Skewness and (Excess) Kurtosis}
\usage{
skewness(x, ...)
\method{skewness}{numeric}(
x,
remove_na = TRUE,
type = "2",
iterations = NULL,
verbose = TRUE,
...
)
kurtosis(x, ...)
\method{kurtosis}{numeric}(
x,
remove_na = TRUE,
type = "2",
iterations = NULL,
verbose = TRUE,
...
)
\method{print}{parameters_kurtosis}(x, digits = 3, test = FALSE, ...)
\method{print}{parameters_skewness}(x, digits = 3, test = FALSE, ...)
\method{summary}{parameters_skewness}(object, test = FALSE, ...)
\method{summary}{parameters_kurtosis}(object, test = FALSE, ...)
}
\arguments{
\item{x}{A numeric vector or data.frame.}
\item{...}{Arguments passed to or from other methods.}
\item{remove_na}{Logical. Should \code{NA} values be removed before computing (\code{TRUE})
or not (\code{FALSE}, default)?}
\item{type}{Type of algorithm for computing skewness. May be one of \code{1}
(or \code{"1"}, \code{"I"} or \code{"classic"}), \code{2} (or \code{"2"},
\code{"II"} or \code{"SPSS"} or \code{"SAS"}) or \code{3} (or \code{"3"},
\code{"III"} or \code{"Minitab"}). See 'Details'.}
\item{iterations}{The number of bootstrap replicates for computing standard
errors. If \code{NULL} (default), parametric standard errors are computed.}
\item{verbose}{Toggle warnings and messages.}
\item{digits}{Number of decimal places.}
\item{test}{Logical, if \code{TRUE}, tests if skewness or kurtosis is
significantly different from zero.}
\item{object}{An object returned by \code{skewness()} or \code{kurtosis()}.}
}
\value{
Values of skewness or kurtosis.
}
\description{
Compute Skewness and (Excess) Kurtosis
}
\details{
\subsection{Skewness}{
Symmetric distributions have a \code{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:
\itemize{
\item Normal distribution (and other symmetric distribution) has a skewness
of 0
\item Half-normal distribution has a skewness just below 1
\item Exponential distribution has a skewness of 2
\item Lognormal distribution can have a skewness of any positive value,
depending on its parameters
}
(\cite{https://en.wikipedia.org/wiki/Skewness})
}
\subsection{Types of Skewness}{
\code{skewness()} supports three different methods for estimating skewness,
as discussed in \cite{Joanes and Gill (1988)}:
\itemize{
\item Type "1" is the "classical" method, which is \code{g1 = (sum((x - mean(x))^3) / n) / (sum((x - mean(x))^2) / n)^1.5}
\item Type "2" first calculates the type-1 skewness, then adjusts the result:
\code{G1 = g1 * sqrt(n * (n - 1)) / (n - 2)}. This is what SAS and SPSS
usually return.
\item Type "3" first calculates the type-1 skewness, then adjusts the result:
\code{b1 = g1 * ((1 - 1 / n))^1.5}. This is what Minitab usually returns.
}
}
\subsection{Kurtosis}{
The \code{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
\emph{fatter} tails. A kurtosis value below zero indicates a "platykurtic"
distribution with \emph{thinner} tails
(\cite{https://en.wikipedia.org/wiki/Kurtosis}).
}
\subsection{Types of Kurtosis}{
\code{kurtosis()} supports three different methods for estimating kurtosis,
as discussed in \cite{Joanes and Gill (1988)}:
\itemize{
\item Type "1" is the "classical" method, which is \code{g2 = n * sum((x - mean(x))^4) / (sum((x - mean(x))^2)^2) - 3}.
\item Type "2" first calculates the type-1 kurtosis, then adjusts the result:
\code{G2 = ((n + 1) * g2 + 6) * (n - 1)/((n - 2) * (n - 3))}. This is what
SAS and SPSS usually return
\item Type "3" first calculates the type-1 kurtosis, then adjusts the result:
\code{b2 = (g2 + 3) * (1 - 1 / n)^2 - 3}. This is what Minitab usually
returns.
}
}
\subsection{Standard Errors}{
It is recommended to compute empirical (bootstrapped) standard errors (via
the \code{iterations} argument) than relying on analytic standard errors
(\cite{Wright & Herrington, 2011}).
}
}
\examples{
skewness(rnorm(1000))
kurtosis(rnorm(1000))
}
\references{
\itemize{
\item D. N. Joanes and C. A. Gill (1998). Comparing measures of sample
skewness and kurtosis. The Statistician, 47, 183–189.
\item Wright, D. B., & Herrington, J. A. (2011). Problematic standard
errors and confidence intervals for skewness and kurtosis. Behavior
research methods, 43(1), 8-17.
}
}
|