help for tkdensity

Univariate kernel density estimation, calculation on transformed scale

tkdensity
varname
[if exp]
[in range]
[,
generate(newvar_x newvar_d)
trans(transformation)
graphopts(line_opts)
kdensity_options
]

Description

tkdensity estimates and graphs kernel density estimates for the
density function of numeric variable varname, doing the
calculations on a specified transformed scale and back-transforming to
show density versus the original scale. It is a convenience wrapper for
kdensity.

Remarks

For a monotone transformation t(x) the principle is that for densities f

estimate of f = estimate of f * |dt/dx|.

For discussion and references, see Cox (2004, pp.76-78).

On cube roots, see also Cox (2011).

Options

trans() specifies the transformation to be used. Transformations
implemented are

natural logarithm, which may be specified by ln or
logarithm, and which is the default; for this values must all be
strictly positive (>0);

cube root, which may be specified by cube root;
for this values may be negative, zero, or positive;

square root, which may be specified by root or square root;
for this values must all be zero or positive;

reciprocal, which may be specified by reciprocal;
for this values must all be strictly positive (>0);

logit, which may be specified by logit; for this values must all be
within (0,1) (and so not equal to 0 or 1).

See underlining above for permitted abbreviations of keywords.

generate() stores the results of the
estimation. newvar_x will contain the points at which the density is
estimated. newvar_d will contain the density estimate.

graphopts(line_options) specifies options of
line used to tune the graphical display of the density.

kdensity_options are options of kdensity. Note that
kdensity is called with option nograph and that in any case
the density estimates it would graph would be on the transformed scale,
so graphics options are excluded here. See also the option just above.
Note also that bandwidths are measured on the transformed scale.

Examples

. sysuse auto, clear

. tkdensity mpg, trans(ln) kernel(biweight) bw(0.25)

Author

Nicholas J. Cox, Durham University

n.j.cox@durham.ac.uk

References

Cox, N.J. 2004.
Graphing distributions.
Stata Journal 2: 66-88. See esp. pp.76-78.
http://www.stata-journal.com/sjpdf.html?articlenum=gr0003

Cox, N.J. 2011.
Stata tip 96: Cube roots.
Stata Journal 11: 149-154.

Also see

kdensity