Calculates sample measures of skewness (the sample quartile skewness or standardized sample skewness) of a vector of data, or of each column of a matrix of data, based on the estimators described in the the STAT002 notes.
Arguments
- x
A numeric vector or matrix.
- type
Relevant to
q_skewonly. Argumenttypeused in the call toquantileto estimate the 25%, 50% and 75% quantiles.- na.rm
A logical scalar. If true, any
NAand NaNs are removed fromxbefore the constituent parts of the sample skewness are computed.
Details
See Chapter 2 of the STAT002 notes.
Sample quartile skewness. Let \(q_L\), \(m\) and \(q_U\) be the sample lower quartile, mean and upper quartile respectively. A measure of skewness often called the quartile skewness is given by $$[ (q_U - m) - (m - qL) ] / (q_U - q_L).$$
Standardized sample skewness. Denote a vector of data by \((x_1, ..., x_n)\) and let \(\bar{x}\) and \(s\) be the sample mean and sample standard deviation respectively. The standardized sample skewness is given by $$(1 / n) \sum_{i=1}^n (x_i - \bar{x}) ^ 3 / s ^ 3.$$