Stata 15 help for lnskew0

[R] lnskew0 -- Find zero-skewness log or Box-Cox transform

Syntax

Zero-skewness log transform

lnskew0 newvar = exp [if] [in] [, options]

Zero-skewness Box-Cox transform

bcskew0 newvar = exp [if] [in] [, options]

options Description ------------------------------------------------------------------------- Main delta(#) increment for derivative of skewness function; default is delta(0.02) for lnskew0 and delta(0.01) for bcskew0 zero(#) value for determining convergence; default is zero(0.001) level(#) set confidence level; default is level(95) -------------------------------------------------------------------------

lnskew0

Data > Create or change data > Other variable-creation commands > Zero-skewness log transform

bcskew0

Data > Create or change data > Other variable-creation commands > Box-Cox transform

Description

lnskew0 creates newvar = ln(+/-exp - k), choosing k and the sign of exp so that the skewness of newvar is zero.

bcskew0 creates newvar = (exp^lambda - 1)/lambda, the Box-Cox power transformation (Box and Cox 1964), choosing lambda so that the skewness of newvar is zero. exp must be strictly positive.

Options

+------+ ----+ Main +-------------------------------------------------------------

delta(#) specifies the increment used for calculating the derivative of the skewness function with respect to k (lnskew0) or lambda (bcskew0). The default values are 0.02 for lnskew0 and 0.01 for bcskew0.

zero(#) specifies a value for skewness to determine convergence that is small enough to be considered zero and is, by default, 0.001.

level(#) specifies the confidence level for the confidence interval for k (lnskew0) or lambda (bcskew0). The confidence interval is calculated only if level() is specified. # is specified as an integer; 95 means 95% confidence intervals. The level() option is honored only if the number of observations exceeds 7.

Examples

Setup . sysuse auto

Create lnmpg containing ln(mpg-k) with skewness 0 . lnskew0 lnmpg = mpg

Same as above and report 95% confidence intervals for k . lnskew0 lnmpg2 = mpg, level(95)

Create bcmpg containing (mpg^lambda-1)/lambda with skewness 0 . bcskew0 bcmpg = mpg

Same as above and report 90% confidence interval for lambda . bcskew0 bcmpg2 = mpg, level(90)

Stored results

lnskew0 and bcskew0 store the following in r():

Scalars r(gamma) k (lnskew0) r(lambda) lambda (bcskew0) r(lb) lower bound of confidence interval r(ub) upper bound of confidence interval r(skewness) resulting skewness of transformed variable

Reference

Box, G. E. P., and D. R. Cox. 1964. An analysis of transformations. Journal of the Royal Statistical Society, Series B 26: 211-252.