| compute_data_summary | R Documentation |
compute_data_summary() computes a comprehensive set of descriptive
statistics for a numeric vector and returns them as a named list.
It is called automatically by fitverse() and
summary.fitverse(), but can also be used independently for
exploratory data analysis.
compute_data_summary(x, xlab = "x", n_raw = NULL)
x |
A numeric vector, already cleaned of non-finite values (or not – the function removes them internally). |
xlab |
Character: variable name, stored in the returned list for labelling.
Default |
n_raw |
Integer or |
Skewness and kurtosis are computed using the bias-corrected (unbiased) estimators:
g_1 = \frac{n}{(n-1)(n-2)} \sum_{i=1}^n
\left(\frac{x_i - \bar{x}}{s}\right)^3
g_2 = \frac{n(n+1)}{(n-1)(n-2)(n-3)}
\sum_{i=1}^n \left(\frac{x_i - \bar{x}}{s}\right)^4
- \frac{3(n-1)^2}{(n-2)(n-3)}
These correspond to the skewness and kurtosis functions in
the moments package (type 3 in e1071) and are consistent with
the convention in Applied Statistics textbooks. The Normal
distribution has skewness 0 and excess kurtosis 0.
compute_data_summary() returns a named list with the following
elements:
nInteger: number of finite (non-missing) observations used.
n_missingInteger or NA: number of non-finite values removed.
meanArithmetic mean.
sdStandard deviation (denominator n-1).
cvCoefficient of variation (sd / mean).
NA when mean == 0.
medianSample median.
iqrInterquartile range (Q_{0.75} - Q_{0.25}).
skewnessSample skewness (Fisher's g_1).
kurtosisExcess kurtosis (Fisher's g_2).
minSample minimum.
maxSample maximum.
rangeRange (max - min).
q2525th percentile.
q7575th percentile.
xlabCharacter: the variable label.
Karuna G. Reddy karuna.reddy@auckland.ac.nz
M. G. M. Khan mgm.khan@usp.ac.fj
fitverse (calls this automatically),
summary.fitverse.
set.seed(3)
x <- rlnorm(500, meanlog = 1, sdlog = 0.5)
ds <- compute_data_summary(x, xlab = "Claim amount", n_raw = 510)
ds$skewness
ds$cv
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.