-------------------------------------------------------------------------------
help for moments2
-------------------------------------------------------------------------------

Moment-based statistics

moments2 [varlist] [if exp] [in range] [weight] [, type(name) allobs format(numeric_format(s)) matname(matrix_name) tabdisp_options variablenames ]

moments2 varname [if exp] [in range] [weight] [, type(name) allobs by(varlist) format(numeric_format(s)) matname(matrix_name) tabdisp_options ]

by ... : may be used with moments2; see help on by.

aweights and fweights are allowed; see help weights.

Description

moments2 calculates mean, standard deviation, skewness and kurtosis of type() for varlist. Any string variables in varlist are ignored. Definitions and a discussion of the measures specified by type() can be found in: Joanes, D. N. & Gill, C. A. (1998). Comparing measures of sample skewness and kurtosis. The Statistician, 47, 183-189.

Options

type() (default: type(G)) specifies the type of skewness and kurtosis measure as follows [mr = sum((xi-mean(X))^r)/n and s = sqrt(sum((xi-mean(X))^2)/(n-1)) with r = the r-th moment, xi = values of variable X, n = number of cases]:

g : g1 (skewness) and g2 (kurtosis) as used in many textbooks (Joanes & Gill's "type 1" measure); g1 = m3/m2^(3/2) and g2 = m4/m2^2-3

g3 : as type(g) without subtracting 3 from the kurtosis measure as used in Stata's summarize command

G : G1 (skewness) and G2 (kurtosis) as used in SAS and SPSS (Joanes & Gill's "type 2" measure); G1 = g1*sqrt(n*(n-1))/(n-2) and G2 = ((n+1)*g2+6)*(n-1)/((n-2)*(n-3)); this is the default

G3 : as type(G) adding 3 to the kurtosis measure

b : b1 (skewness) and b2 (kurtosis) as used in MINITAB and BMDP (Joanes & Gill's "type 3" measure); b1 = m3/s^3 and b2 = m4/s^4-3

b3 : as type(b) without subtracting 3 from the kurtosis measure

allobs specifies use of the maximum possible number of observations for each variable. The default is to use only those observations for which all variables in varlist are not missing.

by() specifies one or more variables defining distinct groups for which moment-based statistics should be calculated. by() is allowed only with a single varname. The choice between by: and by() is one of precisely what kind of output display is required. The display with by: is clearly structured by groups while that with by() is more compact. To show moments for several variables and several groups with a single call to moments2, the display with by: is essential.

format() controls the display format of mean, standard deviation, skewness and kurtosis, as follows. Up to four numeric formats may be given. The first numeric format given controls the display of the mean; any second numeric format that of the standard deviation; any third numeric format that of the skewness, and any fourth numeric format that of the kurtosis. Formats not specified default to %9.3f.

matname() specifies the name of a matrix in which to save the results of (the last set of) calculations. There will be 5 columns. The columns will contain n, mean, standard deviation, skewness and kurtosis.

tabdisp_options are options of tabdisp other than format().

variablenames specifies that the variable names of varlist should be used in display. The default is to use variable labels to indicate a set of variables.

Examples

. sysuse auto . moments2 price . moments2 price, t(G3) . moments2 price, t(g3) . moments2 price-foreign . moments2 price-foreign, format(%5.1f %5.1f) . bysort rep78: moments2 mpg

Saved results

moments2 saves the following results (of the last variable/by-group) in r():

Scalars r(N) number of observations r(sum_w) sum of the weights r(mean) mean r(Var) variance r(sd) standard deviation r(skewness) skewness r(kurtosis) kurtosis r(sum) sum of variable r(min) minimum r(max) maximum r(p1) 1st percentile r(p5) 5th percentile r(p10) 10th percentile r(p25) 25th percentile r(p50) 50th percentile r(p75) 75th percentile r(p90) 90th percentile r(p95) 95th percentile r(p99) 99th percentile

Macros r(type) type of skewness and kurtosis measure

References

Joanes, D. N. & Gill, C. A. (1998). Comparing measures of sample skewness and kurtosis. The Statistician, 47, 183-189.

Acknowledgments

moments2 (and this help file) leans heavily on Nicholas Cox's moments (see: click here). moments2 does nothing more than adding the type()-option and making "type 2" (i.e. type(G)) measures of skewness and kurtosis the default.

Author

Dirk Enzmann, University of Hamburg, Germany dirk.enzmann@uni-hamburg.de

Also see