## R code for constructing likelihood based confidence intervals for stress-strength models

In my previous blog post I demonstrated how to compute bootstrap confidence intervals for stress-strength models.
The following R-code may be used for computing likelihood based confidence intervals for stress-strength models.

Definition of the unreliability in case of a stress-strength model
A component may fail when the stress (or load) exceeds the strength. Accordingly, the unreliability of the component is defined as: $U_{hat} =\int^{+\infty}_{-\infty} f_l(l)F_s(l) \ dl$

where Uhat is the unreliability of the component, fl(·) the probability density function of the load, and Fs(·) the cumulative density function of the strength.

Note that both the load and strength random variables never take negative values. Since both these random variables are non-negative, the lower limit of the above integral changes. That is, the lower limit changes from -∞ to 0, since fl(·) and Fs(·) will be 0 for negative values (i.e., for l<0). As a consequence, the above integral is given by: $U_{hat} =\int^{+\infty}_{0} f_l(l)F_s(l) \ dl$

The reliability of the component is Rhat=1-Uhat. Continue reading R code for constructing likelihood based confidence intervals for stress-strength models

## R code for constructing likelihood based confidence intervals when summing two random variables (part 2)

The following R-code may be used for computing likelihood based confidence intervals when adding two random variables.

A practical example
A device is known to fail due to material cracks. The failure time for this device is obtained by summing the onset time (X) and growth time (Y) of the cracks. Both X and Y are random variables and are assumed to follow a Weibull distribution.

What is the failure time when the probability of failure for X+Y is less than, say, 0.1%? Stated differently, when observing both the onset and growth times of the material cracks, what is the time at which a proportion of .001 of these devices will have failed? This time corresponds to the .001 quantile.

The method for computing likelihood based confidence intervals for these quantiles is similar to the one that was used in this blog post. That post discusses how to sum random variables and also demonstrates how to compute likelihood based confidence intervals for cumulative probabilities. ## R code for constructing likelihood based confidence intervals when summing two random variables

The following R-code may be used for computing likelihood based confidence intervals when adding two random variables.

A practical example
A device is known to fail due to material cracks. The failure time for this device is obtained by summing the onset time (X) and growth time (Y) of the cracks. Both X and Y are random variables and are assumed to follow a Weibull distribution.

What is the probability of failure when X+Y is less than, say, 314 seconds? This probability (denoted by Fhat) is computed using the following (convolution) integral: $F_{hat} =\int^{+\infty}_{-\infty} F_x(314-y)f_y(y) \ dy$

where Fx(·) is the Weibull cumulative density function (cdf) of X (=onset time), and fy(·) is the Weibull probability density function (pdf) of Y (=growth time).

Note that both the onset times (X) and growth times (Y) never take negative values. Since both these random variables X and Y are non-negative, the limits of the above integral will change. That is, the lower limit changes from ∞ to 0, since fy will be 0 for negative values (i.e., for y<0). Similarly, the upper limit changes from ∞ to 314 since Fx(314-y) will be 0 for negative values (i.e., for y>314). Accordingly, the above integral is given by: $F_{hat} =\int^{314}_{0} F_x(314-y)f_y(y) \ dy$