univariate {descstat} | R Documentation |
Functions to compute statistics on univariate distributions
Description
descstat provide functions to compute statistics on an univariate distribution. This includes central tendency, dispersion, shape and concentration.
Usage
variance(x, ...)
gmean(x, r = 1, ...)
gini(x, ...)
stdev(x, ...)
madev(x, ...)
modval(x, ...)
medial(x, ...)
kurtosis(x, ...)
skewness(x, ...)
## Default S3 method:
variance(x, w = NULL, ...)
## Default S3 method:
gmean(x, r = 1, ...)
## Default S3 method:
stdev(x, w = NULL, ...)
## Default S3 method:
madev(x, w = NULL, center = c("median", "mean"), ...)
## Default S3 method:
skewness(x, ...)
## Default S3 method:
kurtosis(x, ...)
## S3 method for class 'freq_table'
mean(x, ...)
## S3 method for class 'freq_table'
gmean(x, r = 1, ...)
## S3 method for class 'freq_table'
variance(x, ...)
## S3 method for class 'freq_table'
stdev(x, ...)
## S3 method for class 'freq_table'
skewness(x, ...)
## S3 method for class 'freq_table'
kurtosis(x, ...)
## S3 method for class 'freq_table'
madev(x, center = c("median", "mean"), ...)
## S3 method for class 'freq_table'
modval(x, ...)
## S3 method for class 'freq_table'
quantile(x, y = c("value", "mass"), probs = c(0.25, 0.5, 0.75), ...)
## S3 method for class 'freq_table'
median(x, ..., y = c("value", "mass"))
## S3 method for class 'freq_table'
medial(x, ...)
## S3 method for class 'freq_table'
gini(x, ...)
## S3 method for class 'cont_table'
modval(x, ...)
## S3 method for class 'cont_table'
gini(x, ...)
## S3 method for class 'cont_table'
skewness(x, ...)
## S3 method for class 'cont_table'
kurtosis(x, ...)
## S3 method for class 'cont_table'
madev(x, center = c("median", "mean"), ...)
## S3 method for class 'cont_table'
mean(x, ...)
## S3 method for class 'cont_table'
variance(x, ...)
## S3 method for class 'cont_table'
stdev(x, ...)
Arguments
x |
a series or a |
... |
further arguments, |
r |
the order of the mean for the |
w |
a vector of weights, |
center |
the center value used to compute the mean absolute
deviations, one of |
y |
for the quantile method, one of |
probs |
the probabilities for which the quantiles have to be computed. |
Details
The following functions are provided:
central tendency:
mean
,median
,medial
,modval
(for the mode),dispersion:
variance
,stdev
,maddev
(for mean absolute deviation) and quantile,shape:
skewness
andkurtosis
,concentration:
gini
.
When a generic function exists in base R (or in the stats
package), methods are provided for freq_table
or cont_table
,
this is a case for mean
, median
and quantile
. When a function
exists, but is not generic, we provide a generic and relevant
methods using different names (stdev
, variance
and madev
instead respectively of sd
, var
and mad
). Finally some
function don't exist in base R and recommended packages, we
therefore provide a modval
function to compute the mode, gini
for the Gini concentration index, skewness
and kurtosis
for
Fisher's shape statistics and gmean
for generalized means (which
include the geometric, the quadratic and the harmonic means).
madev
has a center argument which indicates whether the
deviations should be computed respective to the mean or to the
median.
gmean
has a r
argument: values of -1, 0, 1 and 2 lead
respectively to the harmonic, geometric, arithmetic and quadratic
means.
Value
a numeric or a tibble.
Author(s)
Yves Croissant
Examples
library("dplyr")
z <- wages %>% freq_table(wage)
z %>% median
# the medial is the 0.5 quantile of the mass of the distribution
z %>% medial
# the modval function returns the mode, it is a one line tibble
z %>% modval
z %>% quantile(probs = c(0.25, 0.5, 0.75))
# quantiles can compute for the frequency (the default) or the mass
# of the series
z %>% quantile(y = "mass", probs = c(0.25, 0.5, 0.75))
# univariate statistics can be computed on the joint, marginal or
# conditional distributions for cont_table objects
wages %>% cont_table(wage, size) %>% joint
wages %>% cont_table(wage, size) %>% marginal(size) %>% mean
wages %>% cont_table(wage, size) %>% conditional(size) %>% mean