-------------------------------------------------------------------------------
help for moments
-------------------------------------------------------------------------------

Moment-based statistics

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

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

by ... : may be used with moments: see help on by.

aweights and fweights are allowed; see help weights.

Description

moments calculates mean, standard deviation, skewness and kurtosis for varlist. Any string variables in varlist are ignored.

Options

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 moments, 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

. moments

. moments price-foreign . moments price-foreign, format(%5.1f %5.1f)

. bysort rep78: moments mpg

Author

Nicholas J. Cox, University of Durham, U.K. n.j.cox@durham.ac.uk

Also see

help for summarize, help for tabstat