# Estimating parameters of random exp. independent variable based on desired distribution properties of dependent variable in logistic regression model

I have a logistic regression model describing the behaviour of customers of a call centre - relation between waiting time in a queue (independent variable $W$) and probability of hanging up before answer or abandonment rate (dependent variable $A$). Waiting time $W$ is distributed exponentially: $W\sim Exp(\lambda)$.

Now, I want to find such $\lambda$ (with a confidence 95%) that it would result in $A$ for the entire population below some threshold (let's say $A <= 10%$ ).

Does it mean that we need to:

1. Find how $A$ would be distributed (i. e. what happens with exponentially distributed random variable when it is "fed" into logit function?)

2. Find $min(\lambda)$ that makes $\int_0^1 {PDF(A)*A\, dA} = 10\%$?

Does it make sense at all?

And what about confidence interval then? I understand that applying the logistic regression model to a single waiting time value I'm getting a confidence interval for probability of abandonment for this specific data point. But if I apply the model to a sample of $N$ values, I would need to be $\sqrt[N] {0.95}$ confident in each value to achieve 95% confidence for the entire sample? And if it's not a finite sample of $N$ values, but random variable $W$, then how can confidence interval be calculated?

So many questions...

This problem is very similar to estimating the $LD_{50}$, i.e. the dose of a drug at which 50% dies. In that case the $W$ would be the dose of a drug rather than time, and you want to find out at what dose 50% of the rats die. So you model the chance of hanging up (in your case) or dying (in case of estimating the $LD_{50}$) using this equation:

$\ln\left(\frac{p}{1-p}\right)=\beta_0 + \beta_1 W$

We can fill in the desired percentage (.5 for the $LD_{50}$ or .10 in your case) and solve for $W$:

$W=\frac{\ln\left(\frac{.1}{1-.1}\right)-\beta_0}{\beta1}$

So you are dealing with a ratio of coefficients, this makes me reluctant to use tricks like the delta method for computing confidence intervals. Instead I would use the bootstrap

Here is an example of how I would do that in Stata:

. // start with an empty slate
. clear all

.
. // open example data
. sysuse nlsw88, clear
(NLSW, 1988 extract)

.
. // estimate model

Iteration 0:   log likelihood = -1044.9376
Iteration 1:   log likelihood = -1037.0358
Iteration 2:   log likelihood = -1037.0127
Iteration 3:   log likelihood = -1037.0127

Logistic regression                             Number of obs     =      1,876
LR chi2(1)        =      15.85
Prob > chi2       =     0.0001
Log likelihood = -1037.0127                     Pseudo R2         =     0.0076

------------------------------------------------------------------------------
union |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
grade |   .0841686   .0212523     3.96   0.000     .0425148    .1258224
_cons |  -2.244098   .2906487    -7.72   0.000    -2.813759   -1.674437
------------------------------------------------------------------------------

.
. // grade at which 25% are union members
13.609413

. // create a program that computes the statistic
. program define toboot, rclass
1.         syntax [if] [in]
2.         marksample touse
3.         logit union grade if touse'
4.         return scalar ld25 = (ln(.25/.75)-_b[_cons])/_b[grade]
5. end

. // bootstrap that program
. // and store the coefficients in the temporary file results'
. tempfile results
. bootstrap ld25=r(ld25), bca reps(10000) saving(results', replace) nodots : toboot
Bootstrap results                               Number of obs     =      1,876
Replications      =     10,000

command:  toboot
ld25:  r(ld25)

------------------------------------------------------------------------------
|   Observed   Bootstrap                         Normal-based
|      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
ld25 |   13.60941   1.342487    10.14   0.000     10.97819    16.24064
------------------------------------------------------------------------------

// This is a ratio of coefficients so I don't trust the normal approximation
// so I use the bca confidence intervals instead
. estat bootstrap , bca

Bootstrap results                               Number of obs     =      1,876
Replications      =      10000

command:  toboot
ld25:  r(ld25)

------------------------------------------------------------------------------
|    Observed               Bootstrap
|       Coef.       Bias    Std. Err.  [95% Conf. Interval]
-------------+----------------------------------------------------------------
ld25 |   13.609413   .0540051   1.3424874    12.15759   15.17913 (BCa)
------------------------------------------------------------------------------
(BCa)  bias-corrected and accelerated confidence interval

. // out of curiosity look at the estimated sampling distribution
. use results'
(bootstrap: toboot)

. // this computes an overall 95% confidence band for a quantile plot.
qenvnormal ld25, gen(lb ub) overal reps(20000)

. local mean = r(mean)

. local sd = r(sd)

. // this displays that quantile plot
. qplot ld25 lb ub , ms(oh none ..) c(. l l) lc(gs10 ..)  mcolor(%15 ..) ///
>         legend(off) ytitle("grade at which 25% is union member") ///
>         trscale(mean' + sd' *invnormal(@)) xtitle(Normal quantiles)


As we can see there are some pretty extreme outliers in the sampling distribution, which is what you would expect for a ratio of coefficients.