help for esetran (Roger Newson)

Transforming estimates and standard errors in parmest resultssets

esetran est_varname se_varname
[if] [in] [ ,
transformation(transformation_name)
]

where est_varname and se_varname are existing numeric variables
containing the estimates and standard errors,
respectively,
and transformation_name can be one of

log | logit | loglog | cloglog | atanh | asin

Description

esetran is designed for use in parmest resultssets,
which have one observation per estimated parameter and data on parameter estimates.
It inputs 2 user-specified variables,
containing the estimates and the standard errors,
and replaces them with the estimates and standard errors
of the same parameters after a user-specified transformation,
promoting their storage types to double precision if necessary.
Parameter values at the boundaries of the parameter range
(such as the logit of 1 or 0 or the hyperbolic arctangent of 1 or -1)
are set to sensible non-missing boundary values.
The user can then use the parmcip option of the parmest package
to recalculate the t- and z-statistics, symmetric confidence limits and P-values
for the transformed parameters,
and use endpoint transformations on the estimates and confidence limits
to produce asymmetric confidence intervals for back-transformed parameters.
This practice is especially useful
if the user has produced symmetric confidence intervals
for scenario proportions and their differences,
using margins after a logistic regression,
and needs to replace them with asymmetric confidence intervals,
which are more likely to have the correct coverage probability.

Options

transformation(transformation_name) must be specified.
It can be one of log, logit, loglog, cloglog, atanh or asin,
specifying the log, the logit, the log-log, the complementary log-log,
the hyperbolic arctangent (Fisher's z), or the arcsine, respectively.
These are all standard Normalizing and/or variance-stabilizing transformations,
used for a variety of parameters.
Typically, we use the log transform for arithmetic means of non-negative-valued variables,
the logit, log-log and complementary log-log transform for proportions,
and the hyperbolic arctangent and arcsine parameters
for differences between proportions.

Methods and formulas

The log-log transform of transformation(loglog) is defined by the Stata formula

y=cloglog(1-x)

where x is a variable that should have values in the open interval between 0 and 1.
The log-log transform is widely used in survival analysis
to calculate confidence intervals for Kaplan-Meier survival probabilities
(see help for sts).
The transformation() values log, logit, cloglog, atanh and asin
are defined using the Stata functions of the same names.

esetran computes the transformed standard errors using the delta method.
For each transformation,
the standard error is computed by multiplying the untransformed standard error by the absolute derivative of the transformation
at the value specified by the estimate.
Before this is done, esetran promotes the estimate and standard errors to double precision if necessary,
and then converts boundary parameter values to sensible boundary values.
Boundary parameter values are non-missing values for the parameter estimates,
indistinguishable, under double precision,
from the values at the boundary of the parameter domain.
These boundary values are 0 and infinity for the log transformation,
0 and 1 for the logit transformation,
and -1 and 1 for the hyperbolic arctangent and arcsine transformations.
They are replaced by double-precisiuon boundary values,
defined using the numeric system limits specified by creturn.
These are c(smallestdouble) and c(maxdouble) for the log transformation,
c(smallestdouble) and 1-c(epsdouble) for the logit transformation,
and c(epsdouble)-1 and 1-c(epsdouble) for the hyperbolic arctangent and arcsine transformations.
These substituted values have valid non-missing values for the transformation, and for its derivative,
which is multiplied by the untransformed standard error to give the transformed standard error.
Symmetric confidence intervals for the transformed parameter can then be computed,
assuming the Normal distribution or the t-distribution,
using the parmcip module of the parmest package.

The estimates and symmetric confidence limits for the transformed parameter
can then be transformed back, using replace,
to derive asymmetric confidence intervals for the untransformed parameter.

The parmest package can be downloaded from SSC.
More information about the production and use of parmest resultssets
can be found in Newson (2010), Newson (2008), Newson (2006), Newson (2004), Newson (2003) and Newson (2002).

Examples

The following examples use the webuse command to load the lbw dataset,
with 1 observation for each of 189 pregnancies.
We fit an interactive logistic regression model for low birth weight
with respect to maternal race and smoking during pregnancy.
This produces odds and odds ratios,
which few readers will understand.
So, we use margins to compute confidence intervals
for the scenario prevalences of low birthweight in two scenarios,
a dream scenario where all mothers stop smoking and a nightmare scenario where all mothers start smoking,
in which the distribution of race is as in the real-world sample.
We also use margins with the pwcompare option
to estimate a difference in prevalences of low birthweight
between the nightmare scenario and the dream scenario.
This difference is interpreted as a causal effect of smoking
in the population as a whole.
We use esetran,
together with the parmest and parmcip modules of the SSC package parmest,
to replace the symmetric confidence intervals produced by margins
with asymmetric confidence intervals,
derived using Normalizing transformations and back-transformations.

Set-up

. webuse lbw, clear

. describe, full

. tab race smoke, miss

. logit low i.smoke#i.race, or vce(robust) asis

The following example uses margins to estimate the scenario prevalences
for the dream scenario where no mothers smoke and for the nightmare scenario where all mothers smoke,
and parmest to save the results to a temporary dataset in memory
(temporarily overwriting the original dataset),
with 1 observation per estimated scenario prevalence.
We then use esetran to convert the estimates and standard errors for the prevalences
to estimates and standard errors for the logit prevalences,
parmcip to update the z-statistics, P-values and confidence limits,
and a foreach loop to back-transform the estimates and their confidence limits
to prevalences again.
These results (with asymmetric confidence limits) are then listed,
and the original dataset restored.

. margins i.smoke

. preserve

. parmest, bmat(r(b)) vmat(r(V)) fast

. esetran estimate stderr, transform(logit)

. parmcip, replace

. foreach Y of var estimate min* max* {

. replace `Y'=invlogit(`Y')

. }

. list, abbr(32)

. restore

The following example is like the previous example,
except that it uses the log transform with esetran,
and back-transforms the confidence intervals using the exp() function.

. margins i.smoke

. preserve

. parmest, bmat(r(b)) vmat(r(V)) fast

. esetran estimate stderr, transform(log)

. parmcip, replace

. foreach Y of var estimate min* max* {

. replace `Y'=exp(`Y')

. }

. list, abbr(32)

. restore

The following example also uses margins,
this time with the pwcompare option
to create a confidence interval for the difference between the 2 scenario prevalences.
We then use parmest to save the parameter to a temporary dataset in memory,
esetran to convert the estimates and standard errors to the hyperbolic arctangent scale,
parmcip to update the other statistics,
and a foreach loop to back-transform to the original prevalence difference,
using the tanh() function.
We then list the prevalence differences with their new asymmetric confidence limits
and restore the old dataset.

. margins i.smoke, pwcompare

. preserve

. parmest, bmat(r(b_vs)) vmat(r(V_vs)) fast

. esetran estimate stderr, transform(atanh)

. parmcip, replace

. foreach Y of var estimate min* max* {

. replace `Y'=tanh(`Y')

. }

. list, abbr(32)

. restore

The following example is like the previous example,
except that it uses the arcsine transform with esetran,
and back-transforms using the sin() function.

. margins i.smoke, pwcompare

. preserve

. parmest, bmat(r(b_vs)) vmat(r(V_vs)) fast

. esetran estimate stderr, transform(asin)

. parmcip, replace

. foreach Y of var estimate min* max* {

. replace `Y'=sin(`Y')

. }

. list, abbr(32)

. restore

The following example uses margins and parmest
to create a dataset with 1 observation per smoking status
and data on probabilities of low birthweight.
We then use esetran to transform the estimates and standard errors,
using the decreasing log-log transform.
We then create the confidence limits using parmcip,
back-transform the estimates and confidence limits,
and use the SSC package creplace
to exchange values between the back-transformed confidence limits.

. margins i.smoke

. preserve

. parmest, bmat(r(b)) vmat(r(V)) fast

. esetran estimate stderr, transform(loglog)

. parmcip, replace

. foreach Y of var estimate min* max* {

. replace `Y'=1-invcloglog(`Y')

. }

. creplace min* max*

. list, abbr(32)

. restore

Author

Roger Newson, Imperial College London, UK.
Email: r.newson@imperial.ac.uk

References

Newson, R. B. 2010. Post-parmest peripherals: fvregen, invcise, and qqvalue.
Presented at the 16th United Kingdom Stata Users' Group Meeting, London, 9-10 September, 2010.

Newson, R. B. 2008. parmest and extensions.
Presented at the 14th United Kingdom Stata Users' Group Meeting, London, 8-9 September, 2008.

Newson, R. 2006. Resultssets, resultsspreadsheets, and resultsplots in Stata.
Presented at the 4th German Stata Users' Group Meeting, Mannheim, 31 March, 2006.

Newson, R. 2004. From datasets to resultssets in Stata.
Presented at the 10th United Kingdom Stata Users' Group Meeting, London, 29-30 June, 2004.

Newson, R. 2003. Confidence intervals and p-values for delivery to the end user.
The Stata Journal 3(3): 245-269.
Download from The Stata Journal website.

Newson, R. 2002. Creating plots and tables of estimation results using parmest and friends.
Presented at the 8th United Kingdom Stata Users' Group Meeting, 20-21 May, 2002.

Also see

Manual: [D] data types, [P] creturn, [R] margins

On-line: help for data_types, creturn, margins

help for parmest, parmcip, creplace if installed