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.
q_skew(x, type = 6, na.rm = FALSE)
skew(x, na.rm = FALSE)
A numeric vector or matrix.
Relevant to q_skew
only. Argument type
used in
the call to quantile
to estimate the 25%, 50% and 75% quantiles.
A logical scalar. If true, any NA
and NaNs
are removed from x
before the constituent parts of the sample
skewness are computed.
A numeric scalar (if the input was a vector) or vector (if the input was a matrix).
See Chapter 2 of the STAT002 notes.
Sample quartile skewness. Let qL, m and qU be the sample lower quartile, mean and upper quartile respectively. A measure of skewness often called the quartile skewness is given by [(qU−m)−(m−qL)]/(qU−qL).
Standardized sample skewness. Denote a vector of data by (x1,...,xn) and let ˉx and s be the sample mean and sample standard deviation respectively. The standardized sample skewness is given by (1/n)n∑i=1(xi−ˉx)3/s3.
birth_times <- ox_births[, "time"]
skew(birth_times)
#> [1] 0.6254774
q_skew(birth_times)
#> [1] -0.07216495