HIST

See also graphics version

Output     Options    Examples

HIST produces histograms (bar charts or frequency distributions) of series. It is convenient for obtaining a rough picture of the univariate distribution of your data.

HIST (BOT, DISCRETE, MAX=<maximum for x-axis>, MIN=<minimum for x-axis>, NBINS=<number of bins>, PERCENT, PRINT, WIDTH=<width of bin>) <list of series> ;

Usage

Follow HIST with the names of one or more series for which you would like to see a frequency distribution. The default options for output yield a histogram with ten equally spaced bins or cells running from the minimum value of the series to the maximum value. The bars for each cell have a width of two lines on the printed page, and are based on the left hand axis of the graph.

Output

If the PRINT option is on, a plot of the histogram for each series is produced.

The following is stored in data storage:

variable

type

length

description

@HIST

matrix

#nbins*#series

matrix with observation counts for each series

@HISTVAL

matrix

#nbins*#series

matrix with bin lower bounds for each histogram

Options

BOT/NOBOT causes the printed histogram to be based on the left side of the page. The default is the middle of the page.

DISCRETE/NODISCRE specifies whether the series are discrete or continuous. If the series are discrete, there will be one cell for each unique value (limited by NBINS).

MAX= upper bound on the last cell. The default is the maximum value of the series.

MIN= lower bound on the first cell. The default is the minimum value of the series.

NBINS= the number of bins or cells (The default is 10 for NODISCRETE and 20 for DISCRETE).

PERCENT/NOPERCEN causes the percent in each cell rather than the absolute number to be printed (the graph looks the same, but the labels on the horizontal axis are different).

PRINT/NOPRINT tells whether the histogram is to be printed or just stored.

WIDTH= the width of the bars (the default is 2 printer lines).

Examples

HIST X ;

produces a plot with the vertical axis containing ten cells running from the minimum value of X to the maximum value of X, and the horizontal axis showing the number of observations of X which take on values within each of the cells.

HIST (MAX=100,MIN=0,NBINS=40,PERCENT) Y1 Y2 ;

produces two histograms, each with 40 cells which have a width equal to 2.5. The percent of observations of Y1 (or Y2) which fall in each cell are shown.

Suppose the variable REASON takes on the values 0,1,2, and 3. The command

HIST (DISCRETE) REASON ;

will produce a histogram with four cells, containing the number of observations taking on each one of the four values of REASON.