*! version 1.0 July 15, 2020 @ 11:24:48

*! version 1.1 September 9, 2018 @ 18:13:10

Title

ranwtdttt -- Maximum likelihood estimation for
parametric Waiting Time Distribution (WTD) based on observed prescription
redemptions with adjustment for covariates using one or more random index times
for each individual. Reports estimates of prevalence fraction and specified percentile of
inter-arrival density together with regression coefficients.

Syntax

ranwtdttt
varname
, id(varname:idvar) disttype(recurrence_dens) samplestart(time) sampleend(time) [options]

"id(varname:idvar)" ID variable

Recurrence distribution
disttype(string) Parametric distribution for Forward or
Backward Recurrence Density (FRD/BRD)

Time window
reverse Estimate reverse WTD

samplestart(string) Start of sampling window

sampleend(string) End of sampling window

conttime Estimate durations based on redemption times measured in continuous time (non-integer, mostly useful for simulations)

nsamp(#) Number of sampled random index dates for each ID; default is 1

Covariates
logitpcovar(fvvarlist) Covariates for logit(p)

mucovar(fvvarlist) Covariates for mu (lnorm)

lnsigmacovar(fvvarlist) Covariates for
log(sigma) (lnorm)

lnbetacovar(fvvarlist) Covariates for
log(beta) (exp | wei)

lnalphacovar(fvvarlist) Covariates for
log(alpha) (exp | wei)

allcovar(fvvarlist) Covariates for all parameters

Reporting
iadpercentile(#) Percentile to estimate in the
Inter-Arrival Distribution (IAD); default is 0.8 (80th percentile)

eform(string) Report exponentiated regression coefficients

Maximum likelihood options (all options available with ml)
niter(#) perform maximum of # iterations; default is niter(50)

Description

ranwtdttt estimates a parametric Waiting Time Distribution (WTD)
to varname (rxtime) using one or more random index times for each individual
and then computes an estimate of the specified percentile
together with an estimate of the proportion of prevalent users in the
sample. Covariates can only be included when estimating a reverse
WTD with random index times.

Here rxtime is a variable containing the time of observed
prescription redemptions, typically dates (discrete case).

ranwtdttt estimation is based on the wtdttt, but in contrast to wtdttt it uses all prescription redemption times of patients within a time window as input. One or more random index times for each individual are then uniformly sampled within the sampling window of length delta, and relative to the index time the first subsequent prescription (ordinary WTD) or the last prior prescription (reverse WTD) are considered in the WTD estimation. Consequently, the full data window must be sufficiently wide to contain all individual observation windows, i.e. it must be of length 2*delta.

Robust variance estimation is used to account for the dependence of observations originating from the same individual.

ranwtdttt alters the original dataset as it only keeps either the first prescription subsequent to (ordinary WTD) or the last prescription prior to (reverse WTD) the random
index time for each individual and index time. Furthermore the new dataset contains the variable _rxshift which is the shifted prescription redemption time after all index times have been aligned to the same time.
For multiple index dates ranwtdttt returns stacked datasets corresponding to the number of index dates.

Post-estimation commands are the same as for the wtdttt command, i.e.:

To assess the fit, the command wtdtttdiag can be used to
obtain diagnostic plots, cf. the example below.

The post-estimation command wtdtttpredprob allows
prediction of treatment probabilities on times of interest based on
observed prescription redemptions. Similarly the post-estimation command
wtdtttpreddur allows prediction of prescription durations
based on a specified percentile of the inter-arrival distribution.

For references and a general introduction to the analytic approach of the WTD, see the documentation for wtdttt.

Note: For small sample sizes and few index dates it is recommended to calculate the confidence interval for the time percentile on the log-scale and then transform it to the original scale
(see the example do-file wtdttt_ex.do for a worked example of this).

Options

Recurrence distribution

disttype specifies the forward recurrence density to use.
Possible choices 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.

Time window

reverse indicates that observations represent the last
prescription redemption observed in the interval for each patient and
a reverse WTD is estimated. If not specified (default), observations
are assumed to be first prescription redemptions and the ordinary WTD
is estimated.

samplestart is either a string such as "1Jan2014" (a date for discrete data)
or "1" (a number for continuous data) which gives the start of the sampling
window within which we sample random index times. In the discrete case (default), the string must conform to requirements
for the date function td().

sampleend is either a string such as "31Dec2014" (a date for discrete data)
or "2" (a number for continuous data) which gives the end of the sampling
window. In the discrete case (default), the string must conform to requirements
for the date function td().

conttime indicates that the data is continuous. If not
specified (default), observations are assumed to be discrete.

nsamp specifies the number of index times to be randomly sampled for each individual. The default value is 1.

Covariates

logitpcovar(fvvarlist) specifies covariates included in
the regression equation for the parameter logit(p) (log-odds of
prevalence).

mucovar(fvvarlist) specifies covariates included in the
regression equation for mu, when using a Log-Normal recurrence
distribution (lnorm).

lnsigmacovar(fvvarlist) Covariates for log(sigma) (lnorm)

lnbetacovar(fvvarlist) Covariates for log(beta) (exp | wei)

lnalphacovar(fvvarlist) Covariates for log(alpha) (exp | wei)

allcovar(fvvarlist) Covariates included in all regression
equations for the parameters.

iadpercentile The percentile of the IAD, which is to be
estimated specified as a fraction between 0 and 1 (default is 0.8).

Examples

. ranwtdttt rxdate, id(pid) disttype(lnorm) samplestart(1jan2014) sampleend(31dec2014)

. wtdtttdiag _rxshift

. ranwtdttt rxdate, id(pid) disttype(lnorm) samplestart(1jan2014) sampleend(31dec2014) nsamp(5)

. ranwtdttt rxtime, id(pid) disttype(lnorm) samplestart(1) sampleend(2) conttime reverse mucovar(i.packsize)

Further examples are provided in the example do-file
ranwtdttt_ex.do, which contains analyses based on the datafiles
ranwtddat_discdates.dta and ranwtddat_conttime.dta - simulated datasets, which are also enclosed. Be sure
to read comments in the do-file for further explanations.

Stored results

ranwtdttt stores the following scalars in r():

Scalars

r(logtimeperc) Logarithm of estimated IAD percentile

r(selogtimeperc) Standard error of estimated logarithm of IAD percentile

r(timepercentile) Estimated IAD percentile

r(setimepercentile) Standard error of estimated IAD percentile

r(prevprop) Estimated proportion of prevalent users

r(seprev) Standard error of estimated proportion of
prevalent users

r(disttype) Model type (backward or forward recurrence distribution)

r(reverse) If undefined: Ordinary WTD. If defined and
equal to "reverse": Reverse WTD.

r(delta) Length of observation window

r(samplestart) Time value at start of sampling window - corresponding to the start of the observation window for the shifted rx

r(sampleend) Time value at end of sampling window - corresponding to the end of the observation window for the shifted rx

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

Author

Katrine Bødkergaard Nielsen, Aarhus University, kani@clin.au.dk.

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