------------------------------------------------------------------------------- help formoments2-------------------------------------------------------------------------------

Moment-based statistics

moments2[varlist] [ifexp] [inrange] [weight] [,type(name)allobsformat(numeric_format(s))matname(matrix_name)tabdisp_optionsvariablenames]

moments2varname[ifexp] [inrange] [weight] [,type(name)allobsby(varlist)format(numeric_format(s))matname(matrix_name)tabdisp_options]

by ... :may be used withmoments2; see help on by.

aweights andfweights are allowed; see help weights.

Description

moments2calculates mean, standard deviation, skewness and kurtosis oftype()forvarlist. Any string variables invarlistare ignored. Definitions and a discussion of the measures specified bytype()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: astype(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: astype(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: astype(b)without subtracting 3 from the kurtosis measure

allobsspecifies use of the maximum possible number of observations for each variable. The default is to use only those observations for which all variables invarlistare 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 singlevarname. The choice betweenby:andby()is one of precisely what kind of output display is required. The display withby:is clearly structured by groups while that withby()is more compact. To show moments for several variables and several groups with a single call tomoments2, the display withby: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_optionsare options of tabdisp other thanformat().

variablenamesspecifies that the variable names ofvarlistshould 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

moments2saves the following results (of the last variable/by-group) inr():Scalars

r(N)number of observationsr(sum_w)sum of the weightsr(mean)meanr(Var)variancer(sd)standard deviationr(skewness)skewnessr(kurtosis)kurtosisr(sum)sum of variabler(min)minimumr(max)maximumr(p1)1st percentiler(p5)5th percentiler(p10)10th percentiler(p25)25th percentiler(p50)50th percentiler(p75)75th percentiler(p90)90th percentiler(p95)95th percentiler(p99)99th percentileMacros

r(type)type of skewness and kurtosis measure

ReferencesJoanes, 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'smoments(see: click here).moments2does nothing more than adding thetype()-option and making "type 2" (i.e.type(G)) measures of skewness and kurtosis the default.

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

Also see