*! version 1.0 January 9, 2018 @ 09:46:35

Title

wtd_perc -- Calculate percentile of inter-arrival density
based on the parametric Waiting Time Distribution (WTD).

Syntax

wtd_perc
varname
[, options]

Main
disttypel(string) Parametric distribution for Forward
Recurrence Density (FRD)

iadpercentile(#) Percentile to estimate in the
Inter-Arrival Distribution (IAD) (between 0 and 1)

Options
prevformat(string) Format for displaying proportion of
prevalent users

percformat(string) Format for displaying percentile of
IAD

start(date) Date where time window starts

end(date) Date where time window ends

delta(#) Length of time window

Description

wtd_perc estimates a parametric Waiting Time Distribution (WTD)
to varname and then computes an estimate of the specified percentile
together with an estimate of the proportion of prevalent users in the
sample.

Note: To use this command you first need to create a dataset
with the times of only the first prescription redemption of each
individual within an observation window. You can typically achieve
this with something like the following two lines of code:

. keep if rxdate >= startdate & rxdate <= enddate

. bysort pid (rxdate): keep if _n == 1

where pid is a variable containing a person identifier and
rxdate is a variable containing times (typically dates) of
observed prescription redemptions.

Options

Main

disttype specifies the forward recurrence density to use. They
are named after their corresponding interarrival density and there are
three different choices implemented: exp means Exponential,
lnorm means Log-Normal, and wei means Weibull. See Remarks
below for a description of these and their parametrization.

iadpercentile The percentile of the IAD, which is to be
estimated - it should be specified as a fraction between 0 and 1. It
must be specified.

prevformat Numerical format to be used for displaying the
estimated proportion of prevalent users in the sample. Defaults to
%4.3f, see help format.

percformat Numerical format to be used for displaying the
estimated percentile of the IAD. Defaults to
%4.3f, see help format.

start is a string such as "1Jan2014" which gives the start date
of the observation window. Strings must conform to requirements for
the date function td(). When specified, an end date must also be
given. Default time for start of time window is 0. When specified, an
end date must also be given.

end is a string such as "31dec2014" which gives the end date
of the observation window. Strings must conform to requirements for
the date function td(). When specified, a start date must also be
given.

delta specifies the length of the observation window. If
specified, no start and end date can be stated. Default value is 1.

Remarks - Methods and Formulas

The WTD is parametrized as a two-component mixture distribution with
one density component for prevalent users, g(t), and a uniform
distribution over the observation window for incident users, i.e. the
likelihood contribution for one patient is:

{it:l(t) = p * g(t) + (1 - p) / delta

where p is the proportion of prevalent users in the
sample, and delta is the width of the observation window. Only
patients with at least one prescription redemption in the observation
window are considered.

The density g(t) is known as the forward recurrence density
corresponding to the interarrival density, f(t), which governs
the distribution of time from one prescription redemption of a patient
to the subsequent one. g(t) is given by

g(t) = (1 - F(t)) / M

where F(t) is the cumulative distribution function for
f(t) and M is the mean for f(t).

The actual parametrizations used are:

Exponenential:

f(t) = exp(-(beta * t))

where lnbeta = ln(beta).

Weibull:

f(t) = exp(-(beta * t) ^alpha)

where lnalpha = ln(alpha) and lnbeta = ln(beta).

Log-Normal:

f(t) = normprob(-(ln(x) - mu)/exp(lnsigma))

where lnsigma = ln(sigma).

The ML procedure reports estimates of lnbeta
(Exponential), (lnalpha, lnbeta) (Weibull) or (mu, lnsigma)
(Log-Normal) together with an estimate of the log-odds of prevalent
users logitp. The latter is reported as the estimated proportion
of prevalent users in the sample after an
inverse-logit-transformation, i.e. exp(logitp)/(1 + exp(logitp))
accompanied by a 95% confidence interval.

Examples

. wtd_perc rx1time, disttype(lnorm) iadpercentile(0.8)

To get bootstrap confidence intervals we can do the following - notice
the use of eform in the second statement to obtain the
percentile itself and not its logarithm:

. bootstrap logtimeperc = r(logtimeperc), reps(50): ///

wtd_perc rx1time, disttype(lnorm) iadpercentile(0.8)

. bootstrap, eform

Further examples are provided in the example do-file
wtd_perc_ex.do, which contains analyses based on the datafile
wtddat.dta - a simulated dataset, which is also enclosed.

Stored results

wtd_perc stores the following scalars in r():

Scalars

r(logtimeperc) Logarithm of estimated percentile

r(timepercentile) Estimated percentile

r(prevproc) Estimated proportion of prevalent users

r(selogitprev) Standard error of estimated log-odds of
prevalent users

Apart from the above, all results obtained by the maximum likelihood
estimation are stored by ml in the usual e() macros, see
help ml.

References

Støvring H, Pottegård A, Hallas J. Determining prescription
durations based on the parametric waiting time distribution.
2016 Submitted.

Hallas J, Gaist D, Bjerrum L. The Waiting Time Distribution
as a Graphical Approach to Epidemiologic Measures of Drug Utilization.
Epidemiology. 1997;8:666-670.

Stovring H, Vach W. Estimation of prevalence and incidence
based on occurrence of health-related events. Stat Med.
2005;24(20):3139-3154.

Author

Henrik Støvring, Aarhus University, stovring@ph.au.dk