Previous Page | Next Page

The SGPANEL Procedure

DENSITY Statement


Creates a density curve that shows the distribution of values in your data.
Interaction: The DENSITY statement can be combined only with the DENSITY and HISTOGRAM statements in the SGPANEL procedure.
Featured in: Creating a Panel of Graph Cells with Histograms and Density Plots


Syntax

DENSITY response-variable < / option(s)>;

option(s) can be one or more options from the following categories:


Required Arguments

response-variable

specifies the variable for the x axis. The variable must be numeric.


Options

FREQ= numeric-variable

specifies that each observation is repeated n times for computational purposes, where n is the value of the numeric variable. If n is not an integer, then it is truncated to an integer. If n is less than 1 or missing, then it is excluded from the analysis.

LEGENDLABEL= "text-string"

specifies a label that identifies the density plot in the legend. By default, the label identifies the type of density curve. If you specify TYPE=NORMAL, then the default label is "Normal." If you specify TYPE=KERNEL, then the default label is "Kernel."

Note:   User-specified parameters from the TYPE= option are included in the label by default.  [cautionend]

LINEATTRS= style-element <(options)> | (options)

specifies the appearance of the density line. You can specify the appearance by using a style element or by using suboptions. If you specify a style element, you can additionally specify suboptions to override specific appearance attributes.

options can be one or more of the following:

COLOR= color

specifies the color of the line. For more information about specifying colors, see SAS/GRAPH Colors and Images in the SAS/GRAPH: Reference, Second Edition.

Default: The default color is specified by the ContrastColor attribute of the GraphFit style element in the current style.
PATTERN= line-pattern

specifies the line pattern for the line. You can reference SAS patterns by number or by name. See Line Patterns for a list of line patterns.

Default: The default line pattern is specified by the LineStyle attribute of the GraphFit style element in the current style.
THICKNESS= n <units>

specifies the thickness of the line. You can also specify the unit of measure. The default unit is pixels. See Units of Measurement for a list of the measurement units that are supported.

Default: The default line thickness is specified by the LineThickness attribute of the GraphFit style element in the current style.
NAME= "text-string"

specifies a name for the plot. You can use the name to refer to this plot in other statements.

SCALE= COUNT | DENSITY | PERCENT | PROPORTION

specifies the scaling that is used for the response axis. Specify one of the following values:

COUNT

the axis displays the frequency count.

DENSITY

the axis displays the density estimate values.

PERCENT

the axis displays values as a percentage of the total.

PROPORTION

the axis displays values in proportion to the total.

Default: PERCENT
TRANSPARENCY= numeric-value

specifies the degree of transparency for the density curve. Specify a value from 0.0 (completely opaque) to 1.0 (completely transparent).

Default: 0.0
TYPE = NORMAL < (normal-opts)>| KERNEL < (kernel-opts)>

specifies the type of distribution curve that is used for the density plot. Specify one of the following keywords:

NORMAL < (normal-opts)>

specifies a normal density estimate, with a mean and a standard deviation.

normal-opts can be one or more of the following values:

MU= numeric-value

specifies the mean value that is used in the density function equation. By default, the mean value is calculated from the data.

SIGMA= numeric-value

specifies the standard deviation value that is used in the density function equation. The value that you specify for the SIGMA= suboption must be a positive number. By default, the standard deviation value is calculated from the data.

KERNEL < (kernel-opts)>

specifies a nonparametric kernel density estimate.

kernel-opts can be:

C= numeric-value

specifies the standardized bandwidth for a number that is greater than 0 and less than or equal to 100.

The value that you specify for the C= suboption affects the value of [lambda] as shown in the following equation:

[equation]

In this equation c is the standardized bandwidth, Q is the interquartile range, and n is the sample size.

WEIGHT= NORMAL | QUADRATIC | TRIANGULAR

specifies the weight function. You can specify either normal, quadratic, or triangular weight function.

Default: NORMAL
Default: NORMAL

Details


Normal Density Function

When the type of the density curve is NORMAL, the fitted density function equation is as follows:

[equation]

In the equation, [mu] is the mean, and [sigma] is the standard deviation. You can specify [mu] by using the MU= suboption and [sigma] by using the SIGMA= suboption.


Kernel Density Function

When the TYPE of the density curve is KERNEL, the general form of the kernel density estimator is as follows:

[equation]

In the equation, [equation] is the weight function, [lambda] is the bandwidth, n is the sample size, and [equation] is the ith observation. You can use the C= suboption to specify the bandwidth and the WEIGHT= suboption to specify the weight function [equation].


Kernel Density Weight Functions

The formulas for the weight functions are as follows:

NORMAL

[equation]

QUADRATIC

[equation]

TRIANGULAR

[equation]

Previous Page | Next Page | Top of Page