Statistical Methods for Reliability Data

Chapter 7 - Parametric Likelihood Fitting Concepts: Exponential Distribution

W. Q. Meeker and L. A. Escobar

16 June 2020

CHAPTER OVERVIEW

This chapter explains…

7.1 - INTRODUCTION

Maximum Likelihood Estimation

Properties of MLE’s

\[ \sqrt{n}\left(\hat{\theta}_{_{MLE}}-\theta\right)\xrightarrow{L}N\left(0,\mathscr{I}^{-1}_{\theta}\right) \]

\[ \mathscr{I}_{\theta}=-E\left[\frac{\partial^2\mathscr{L}(\underline{\theta}|\underline{x})}{\partial\underline{\theta}(\partial\underline{\theta})^T}\right]=-E\left[\frac{\partial^2\mathscr{L}(\underline{\theta}|\underline{x})}{\partial\theta_i\partial\theta_j}\right] \]

7.1 - INTRODUCTION Example

Example 7.1 - Time Between \(\alpha\)-Particle Emissions

SMRD::smrd_app('figure7_1')

7.2 - PARAMETRIC LIKELIHOOD

Total likelihood is equal to the joint probability of the data

\[ \mathscr{L}(\underline{\theta}|\underline{x})=\sum_{i=1}^{n}\mathscr{L}_{i}(\underline{\theta}|x_i)=f(\underline{x}|\underline{\theta})=\prod_{i=1}^{n}f(x_{i}|\underline{\theta}),\;\;\text{if}\;x_{i}\; iid \]

teachingApps::teachingApp('maximum_likelihood')

7.2.2 - Likelihood Function and Its Maximum

Every Observation Contributes to the Likelihood Function

teachingApps::teachingApp('maximum_likelihood_simulation')

Contributions to the Likelihood Function For Reliability Data

\[ \mathscr{L}_{i}(\underline{\theta}|t_{i})=\begin{cases} S(t_{i}) &\mbox{for a right censored observation}\\\\F(t_{i}) &\mbox{for a left censored observation}\\\\F(t_{i})-F(t_{i-1}) &\mbox{for an interval censored observation}\\\\\lim\limits_{\Delta_i\rightarrow 0} \frac{(F(t_{i})-\Delta_{i})-F(t_{i})}{\Delta_{i}} &\mbox{for an "exact" observations}\end{cases} \]

\[ \begin{aligned} \mathscr{L}(\underline{\theta}|\underline{x})&=C\prod_{i=1}^{n} \mathscr{L}_{i}(\underline{\theta}|x_i)\\ &=C\prod_{i=1}^{m+1}[F(t_{i})]^{l_{i}}[F(t_{i})-F(t_{i-1})]^{d_{i}}[1-F(t_{i})]^{r_{i}} \end{aligned} \]

7.2.3 - Comparison of \(\alpha\)-Particle Data Analyses

Example 7.3 - Likelihood for the \(\alpha\) Particle Data

Background

Data Set

data <- matrix(c(3,7,4,1,3,2,0,0,
                 41,44,24,32,29,21,9,0,
                 292,494,332,236,261,308,73,4,
                 1609,2424,1770,1306,1213,1528,354,16),
               nrow  = 4, 
               byrow = TRUE)

rownames(data) <- c("n = 20","n = 200","n = 2000","n = 10220")
          [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
n = 20       3    7    4    1    3    2    0    0
n = 200     41   44   24   32   29   21    9    0
n = 2000   292  494  332  236  261  308   73    4
n = 10220 1609 2424 1770 1306 1213 1528  354   16

Additional Information

\[ \begin{aligned} \mathscr{L}(\underline{\theta}|\underline{x})&=C\prod_{j=1}^{8}[F(t_{j}|\theta)-F(t_{j-1}|\theta)]^{d_{j}}\\ &=C\prod_{j=1}^{8}\left[1-\exp\left(-\frac{t_{j}}{\theta}\right)-1-\exp\left(-\frac{t_{j-1}}{\theta}\right)\right]^{d_{j}}\\ &=C\prod_{j=1}^{8}\left[\exp\left(-\frac{t_{j-1}}{\theta}\right)-\exp\left(-\frac{t_{j}}{\theta}\right)\right]^{d_{j}} \end{aligned} \]

Like7.3 <- function(theta,d) {

F <- log(exp(   -0/theta)-exp( -100/theta))*d[1]+
     log(exp( -100/theta)-exp( -300/theta))*d[2]+
     log(exp( -300/theta)-exp( -500/theta))*d[3]+
     log(exp( -500/theta)-exp( -700/theta))*d[4]+
     log(exp( -700/theta)-exp(-1000/theta))*d[5]+
     log(exp(-1000/theta)-exp(-2000/theta))*d[6]+
     log(exp(-2000/theta)-exp(-4000/theta))*d[7]+
     log(exp(-4000/theta)-exp( -Inf/theta))*d[8] 

return(-F)  ### Remember: we're minimizing the negative of our function  
}
P.1 <- nlminb(start = 400, obj = Like7.3, d = data[1,], lower = 100, upper = 800)$par 
P.2 <- nlminb(start = 400, obj = Like7.3, d = data[2,], lower = 100, upper = 800)$par
P.3 <- nlminb(start = 400, obj = Like7.3, d = data[3,], lower = 100, upper = 800)$par
P.4 <- nlminb(start = 400, obj = Like7.3, d = data[4,], lower = 100, upper = 800)$par

MLE <- data.frame(P.1,P.2,P.3,P.4)

colnames(MLE) <- c("n = 20","n = 200","n = 2000","n = 10220")
rownames(MLE) <- c("MLE")
      n = 20  n = 200 n = 2000 n = 10220
MLE 440.1711 572.2742 612.7727  596.3443

Figure 7.3 - Exponential MLE Probability Plots

N.samples <- 200

berkson <- switch(as.character(N.samples), 
                  "20"    = {SMRD::berkson20},
                  "200"   = {SMRD::berkson200},
                  "2000"  = {SMRD::berkson2000},
                  "10220" = {SMRD::berkson10220},
                  stop('This number is no good'))

berkson.ld <- frame.to.ld(berkson,
                          response.column = c(1,2),
                          censor.column = 3,
                          case.weight.column = 4)

mleprobplot(berkson.ld, distribution = "Exponential")

7.3 - Confidence Intervals for \(\theta\)

7.3.1 - Likelihood Confidence Interval for \(\theta\)

The Relative Likelihood Function \(R(\theta)\)

\[ R(\theta)=\frac{\mathscr{L}(\theta|\underline{x})}{\mathscr{L}(\hat{\theta}_{_{MLE}}|\underline{x})} \in (0,1) \]

Likelihood-Based Confidence Intervals

\[-2\log[R(\theta)]\le \chi^2_{(1-\alpha;df)}\]

\[R(\theta)\ge\exp\left[-\chi^2_{(1-\alpha;df)}/2\right]\]

\[ \frac{\mathscr{L}(\theta|\underline{x})}{\mathscr{L}(\hat{\theta}_{_{MLE}}|\underline{x})}=\exp\left[\frac{\log(\mathscr{L}(\theta|\underline{x}))}{\log(\mathscr{L}(\hat{\theta}_{_{MLE}}|\underline{x})})\right]\ne\frac{\log(\mathscr{L}(\theta|\underline{x}))}{\log(\mathscr{L}(\hat{\theta}_{_{MLE}}|\underline{x}))} \]

Example: Finding Relative-Likelihood Based CI’s

Background

Finding Likelihood Based CI’s Analytically

\[ \begin{aligned} \mathscr{L}(\theta|\underline{x})&=C\prod^{20}_{i=1}\frac{1}{\theta}\exp\left[-\frac{t}{\theta}\right]\\ &=C\prod_{j=1}^{8}\left[\exp\left(-\frac{t_{j-1}}{\theta}\right)-\exp\left(-\frac{t_{j}}{\theta}\right)\right]^{d_{j}}\\ &=C\sum_{j=1}^{8}d_{j}\times \log\left[\exp\left(-\frac{t_{j-1}}{\theta}\right)-\exp\left(-\frac{t_{j}}{\theta}\right)\right] \end{aligned} \]

\[ \begin{aligned} R(\theta)=\frac{\mathscr{L}(\hat{\theta}|\underline{x})}{\mathscr{L}(\hat{\theta}_{_{MLE}}|\underline{x})}&\ge \exp\left[-\chi^{2}_{(1-.05;1)}/2\right]\\ &\ge 0.147 \end{aligned} \]

exp(-qchisq(.95,1)/2)
[1] 0.1465001

Finding The Relative-Likelihood Based CI Numerically

par(family  = 'serif')

library(SMRD)

berkson200.ld <- 
frame.to.ld(berkson200,
            response.column = c(1,2),
            censor.column = 3,
            case.weight.column = 4,
            time.units = '1/5000 Seconds')

simple.contour(berkson200.ld, 
               distribution = 'exponential', 
               xlim = c(450,800))

Figure 7.2 - Relative Likelihood Functions

library(ggplot2)

Like<-function(theta,d) {

F<-log(exp(   -0/theta)-exp( -100/theta))*d[1]+
   log(exp( -100/theta)-exp( -300/theta))*d[2]+
   log(exp( -300/theta)-exp( -500/theta))*d[3]+
   log(exp( -500/theta)-exp( -700/theta))*d[4]+
   log(exp( -700/theta)-exp(-1000/theta))*d[5]+
   log(exp(-1000/theta)-exp(-2000/theta))*d[6]+
   log(exp(-2000/theta)-exp(-4000/theta))*d[7]+
   log(exp(-4000/theta)-exp( -Inf/theta))*d[8] 

return(-F)      

}

data<-matrix(c(3,7,4,1,3,2,0,0,
               41,44,24,32,29,21,9,0,
               292,494,332,236,261,308,73,4,
               1609,2424,1770,1306,1213,1528,354,16),
             nrow = 4, 
             byrow = TRUE)

mles <- matrix(NA, ncol = 1, nrow = nrow(data))

mles[,1] <- sapply(X = 1:4, 
                   FUN = function(x) {
                       
                    nlminb(start = 400,
                           Like,
                           d = data[x,],
                           lower = 100,
                           upper = 800,
                           control = list(trace=FALSE))$par
         
                  })

x<-seq(200,800,.1)

n.1 <- exp(-Like(x,data[1,]) + Like(mles[1,],data[1,]))
n.2 <- exp(-Like(x,data[2,]) + Like(mles[2,],data[2,]))
n.3 <- exp(-Like(x,data[3,]) + Like(mles[3,],data[3,]))
n.4 <- exp(-Like(x,data[4,]) + Like(mles[4,],data[4,]))

Data <- data.frame(X = x,
                   Y = c(n.1, n.2, n.3, n.4),
                   N = rep(c(20,200,2000,10220), each = length(x)),
                   row.names = NULL)

ggplot(Data) +
  geom_line(aes(x = X, y = Y, colour = as.factor(N)), size = 1.5) +
  theme_bw(base_size = 16) +
  ylab(expression('R('*theta*')')) +
  xlab(expression(theta)) +
  guides(col = guide_legend(title = "# Samples"))

7.3.2 - Confidence Interval - Significance Test Relationship

Significance Tests (aka hypothesis tests)

Confidence Intervals

  • We observe data
  • Attempt to fit many distributions
  • Find the “most likely” parameters
  • Identify the critial values
  • Values inside critical values bound our uncertainty on the parameter value
Significance Test

  • We observe data
  • Assume one distribution is correct
  • Test a single parameter value
  • Identify the critical values
  • Values outside critical values indicate the data is inconsitent with our hypothesis

\[ R(\theta|\underline{x})\ge\exp\left[-\chi^2_{(1-\alpha;1)}/2\right] \]

Example 7.7 LRT for the \(\alpha\)-Particle Data Set

Background

\[ \begin{aligned} H_{0}: \theta &= 650\\ H_{1}: \theta &\ne 650 \end{aligned} \]

Analysis

\[ \begin{aligned} -2\log\left[R(\theta_{0}|\underline{x})\right]&>\chi^2_{(.95,1)}\\ -2\log\left[\frac{\mathscr{L}(\theta_0|\underline{x})}{\mathscr{L}(\hat{\theta}_{_{MLE}}|\underline{x})}\right]&>3.84 \end{aligned} \]

\[\frac{\mathscr{L}(650|\underline{x})}{\mathscr{L}(572.3|\underline{x})}=2.94\]

Additional Information

7.3.3 - Normal Approximation CI for \(\theta\)

The Fisher Information Matrix

\[ \left[\underline{\theta},\overline{\theta}\right]=\hat{\theta}\pm z_{(1-\alpha/2)} \hat{se}_{\hat{\theta}} \]

\[ \mathscr{I}_{\theta}=-E\left[\frac{\partial^2\mathscr{L}(\underline{\theta}|\underline{x})}{\partial\theta_i\partial\theta_j}\right]=E\left[\mathcal{I}_{\hat{\theta}}\right] \]

Observed Information Matrix

\[ \mathcal{I}_{\theta}=-\frac{\partial^2\mathscr{L}(\underline{\theta}|\underline{x})}{\partial\theta_i\partial\theta_j} \]

\[ \mathcal{L}(\theta|\underline{t})=\sum_{j=1}^8 d_j \log\left[\exp\left(-\frac{t_{j-1}}{\theta}\right)-\exp\left(-\frac{t_j}{\theta}\right)\right] \]

\[ \begin{aligned} \frac{d\mathcal{L}(\theta)}{d\theta}&=\sum_{j=1}^8 d_j\frac{\frac{t_{j-1}}{\theta^2}\exp\left(-\frac{t_{j-1}}{\theta}\right)-\frac{t_{j}}{\theta^2}\exp\left(-\frac{t_{j}}{\theta}\right)}{\exp\left(-\frac{t_{j-1}}{\theta}\right)-\exp\left(-\frac{t_{j}}{\theta}\right)}\\\\\\\\ \frac{d^2\mathcal{L}(\theta)}{d\theta^2}&=\sum_{j=1}^8 d_j\left[\frac{\frac{t_{j-1}}{\theta^2}\exp\left(-\frac{t_{j-1}}{\theta}\right)-\frac{t_{j}}{\theta^2}\exp\left(-\frac{t_{j}}{\theta}\right)}{\exp\left(-\frac{t_{j-1}}{\theta}\right)-\exp\left(-\frac{t_{j}}{\theta}\right)}\right]^2+ \frac{\frac{-2t_{j-1}}{\theta^3}\exp\left(-\frac{t_{j-1}}{\theta}\right)+\frac{t_{j}^4}{\theta^4}\exp\left(-\frac{t_{j}}{\theta}\right)}{\exp\left(-\frac{t_{j-1}}{\theta}\right)-\exp\left(-\frac{t_{j}}{\theta}\right)} \end{aligned} \]

\[ \mathcal{I}_{\hat{\theta}_{_{MLE}}} = 0.000574 \]

\[ \Sigma_{\hat{\theta}_{_{MLE}}}=\left[\mathcal{I}_{\hat{\theta}_{_{MLE}}}\right]^{-1} \]

\[ \Sigma_{\hat{\theta}_{_{MLE}}}=\frac{1}{0.000574}=1742.2 \]

Computing \(\mathcal{I}_{\hat{\theta}_{MLE}}\) Numerically

Using R to Compute \(\mathcal{I}_{\hat{\theta}_{MLE}}\)

Like7.3<-function(theta,d) {

F<-log(exp(   -0/theta)-exp( -100/theta))*d[1]+
   log(exp( -100/theta)-exp( -300/theta))*d[2]+
   log(exp( -300/theta)-exp( -500/theta))*d[3]+
   log(exp( -500/theta)-exp( -700/theta))*d[4]+
   log(exp( -700/theta)-exp(-1000/theta))*d[5]+
   log(exp(-1000/theta)-exp(-2000/theta))*d[6]+
   log(exp(-2000/theta)-exp(-4000/theta))*d[7]+
   log(exp(-4000/theta)-exp( -Inf/theta))*d[8] 

return(-F)      }
data[2,]
[1] 41 44 24 32 29 21  9  0
nlminb(start = 400, 
       obj = Like7.3, 
       d = data[2,], 
       lower = 100, 
       upper = 800)$par
[1] 572.27
optim(par = 400, 
      fn = Like7.3, 
      d = data[2,], 
      lower = 100, 
      upper = 800, 
      method = "L-BFGS-B")$par
[1] 572.27
optim(par = 400, 
      fn = Like7.3, 
      d = data[2,], 
      lower = 100, 
      upper = 800,
      method = "L-BFGS-B", 
      hessian = TRUE)$hessian
           [,1]
[1,] 0.00057452

Using SMRD to Compute \(\mathcal{I}_{\hat{\theta}_{MLE}}\)

berkson200.ld <- frame.to.ld(berkson200, 
                             response.column = c(1,2), 
                             censor.column = 3, 
                             case.weight.column = 4)

berkson200.mlest <- mlest(berkson200.ld, distribution = "Exponential")

berkson200.mlest$mle.table
                        MLE  Std.Err. 95% Lower 95% Upper
mu                   6.3496  0.072901    6.2067    6.4925
sigma                1.0000  0.000000    1.0000    1.0000
Exponential (mean) 572.2742 41.719536  496.0786  660.1732
berkson200.mlest$vcv.matrix
             mu sigma
mu    0.0053146     0
sigma 0.0000000     0

\[ \widehat{se}\left[\hat{\theta}_{_{MLE}}\right]=\sqrt{\widehat{Var}\left[\hat{\theta}_{_{MLE}}\right]}=\sqrt{1742.2}=41.72 \]

Returning to Eq 7.6

\[ \frac{\hat{\theta}-\theta}{\hat{se}_{\hat{\theta}}}\sim NOR(0,1) \]

\[ \left[\underline{\theta}, \overline{\theta}\right]=572.3\pm 1.960\times 41.72=\left[ 490,653 \right] \]

\[ \frac{\log(\hat{\theta})-\log(\theta)}{\hat{se}_{\log(\hat{\theta})}}\sim NOR(0,1) \]

\[ \left[\underline{\log(\theta)},\overline{\log(\theta)}\right]=\log(\hat{\theta}) \pm z_{(1-\alpha/2)}\hat{se}_{\log(\hat{\theta})} \]

\[ \left[\underline{\theta},\overline{\theta}\right]=\left[\hat{\theta}/w,\hat{\theta}\times w\right] \]

\[ \begin{aligned} \widehat{Var}\left[\log(\hat{\theta})\right]&=\sum_{i=1}^n\left[\frac{\partial(\log(\hat{\theta}))}{\partial\hat{\theta}}\right]^2 \widehat{Var}\left[\hat{\theta}\right] =\frac{\widehat{Var}\left[\hat{\theta}\right]}{\hat{\theta}^2}\\\\ \text{therefore}\;\;\hat{se}_{\log(\hat{\theta})}&=\sqrt{\frac{\widehat{Var}\left[\hat{\theta}\right]}{\hat{\theta}^2}}=\frac{\hat{se}_{\hat{\theta}}}{\hat{\theta}} \end{aligned} \]

berkson200.mlest$mle.table
                        MLE  Std.Err. 95% Lower 95% Upper
mu                   6.3496  0.072901    6.2067    6.4925
sigma                1.0000  0.000000    1.0000    1.0000
Exponential (mean) 572.2742 41.719536  496.0786  660.1732
berkson200.mlest$vcv.matrix
             mu sigma
mu    0.0053146     0
sigma 0.0000000     0

Table 7.3 - Comparison of \(\alpha\)-Particle ML Results

a<-c("596.3","6.084","",rep("[584,608]",3),"168","1.7","",rep("[164,171]",3))
b<-c("612.8","14.13","",rep("[586,641]",2),"[585,640]","163","3.8","",rep("[156,171]",3))
c<-c("572.3","41.72","","[498,662]","[496,660]","[490,653]","175","13","","[151,201]","[152,202]","[149,200]")
d<-c("440.2","101.0","","[289,713]","[281,690]","[242,638]","227","52","","[140,346]","[145,356]","[125,329]")
Tab.7.2<-data.frame(a,b,c,d)
rownames(Tab.7.2)<-c("ML estimate $\\hat{\\theta}$",
                     "Standard error $\\hat{se}_{\\hat{\\theta}}$",
                     "Approximate $95\\%$ CI for $\\theta$",
                     "Based on the likelihood",
                     "Based on $Z_{\\log(\\hat{\\theta})}\\sim NOR(0,1)$",
                     "Based on $Z_{\\hat{\\theta}}\\sim NOR(0,1)$",
                     "ML estimate $\\hat{\\lambda}\\times10^{5}$",
                     "Standard error $\\hat{se}_{\\hat{\\lambda}\\times10^{5}}$",
                     "Approximate $95\\%$ CI for $\\lambda \\times 10^{5}$",
                     "Based on the likelihood ",
                     "Based on $Z_{\\log(\\hat{\\lambda})}\\sim NOR(0,1)$",
                     "Based on $Z_{\\hat{\\lambda}} \\sim NOR(0,1)$")

knitr::kable(Tab.7.2, 
             format = 'markdown', 
             col.names = c("n = 10220","n = 2000","n = 200","n = 20"),
             row.names = T)
n = 10220 n = 2000 n = 200 n = 20
ML estimate \(\hat{\theta}\) 596.3 612.8 572.3 440.2
Standard error \(\hat{se}_{\hat{\theta}}\) 6.084 14.13 41.72 101.0
Approximate \(95\%\) CI for \(\theta\)
Based on the likelihood [584,608] [586,641] [498,662] [289,713]
Based on \(Z_{\log(\hat{\theta})}\sim NOR(0,1)\) [584,608] [586,641] [496,660] [281,690]
Based on \(Z_{\hat{\theta}}\sim NOR(0,1)\) [584,608] [585,640] [490,653] [242,638]
ML estimate \(\hat{\lambda}\times10^{5}\) 168 163 175 227
Standard error \(\hat{se}_{\hat{\lambda}\times10^{5}}\) 1.7 3.8 13 52
Approximate \(95\%\) CI for \(\lambda \times 10^{5}\)
Based on the likelihood [164,171] [156,171] [151,201] [140,346]
Based on \(Z_{\log(\hat{\lambda})}\sim NOR(0,1)\) [164,171] [156,171] [152,202] [145,356]
Based on \(Z_{\hat{\lambda}} \sim NOR(0,1)\) [164,171] [156,171] [149,200] [125,329]

7.4.1 - Confidence Intervals for the Arrival Rate

\[ \overline{\theta}=\underline{\lambda} \quad \& \quad \underline{\theta}=\overline{\lambda} \]

\[ \lambda \in \left(\underline{\lambda},\overline{\lambda}\right)\;\;\iff \theta \in \left(\underline{\theta},\overline{\theta}\right) \]

7.4.2 - Confidence intervals for \(F(t;\theta)\)

\[ \left[\underline{F(t|\theta)},\overline{F(t|\theta)}\right]=\left[F(t|\overline{\theta}),F(t\underline{\theta}\right] \]

\[ F(t) \in \left(\underline{F(t)},\overline{F(t)}\right)\;\;\iff \theta \in \left(\underline{\theta},\overline{\theta}\right) \]

Table 7.3 - Comparison of \(\alpha\)-Particle ML Results

\[ \begin{array}{lcccc} \hline & n=10220 & n=2000 & n=200 & n=20 \\ \hline \text{ML estimate } \hat{\lambda}\times10^{5} & 168 & 163 & 175 & 227 \\ \text{Standard error } \hat{se}_{\hat{\lambda}\times10^{5}} & 1.7 & 3.8 & 13 & 52 \\ \hline \text{Approximate } 95\% \text{ CI for } \lambda\times10^{5}\ & & & & \\ \hline \text{Based on the likelihood } & [164,171] & [156,171] & [151,201] & [140,346] \\ \text{Based on } Z_{\log(\hat{\lambda})}\sim NOR(0,1) & [164,171] & [156,171] & [152,202] & [145,356] \\ \text{Based on } Z_{\hat{\lambda}}\sim NOR(0,1) & [164,171] & [156,171] & [149,200] & [125,329] \\ \hline \end{array} \]

7.5 - Comparison of Confidence Interval Prodcedures

7.6 - Likelihood for Exact Failure Times

7.6.3 - \(\hat{\theta}_{_{MLE}}\) based on density approximation

\[ \lim\limits_{\Delta_i\rightarrow 0^+}\left[F(t_i|\theta)-F(t_i-\Delta_i|\theta\right]\approx f(t_i|\theta)\Delta_i \]

\[ \hat{\theta}=\frac{TTT}{r} \]

Calculating Total Time on Test

TTT_1 = lzbearing$megacycles[1] * nrow(lzbearing) 

TTT_1
[1] 411.24
TTT_2 = TTT_1 + diff(lzbearing$megacycles[1:2]) * (nrow(lzbearing) - 1)

TTT_2
[1] 654.12
TTT <- double(nrow(lzbearing))

for(i in 1:nrow(lzbearing)) {
  
  `if`(i == 1,
       TTT[i] <- lzbearing[i,1] * length(lzbearing[23:i,1]),
       TTT[i] <- diff(lzbearing[(i-1):i,1]) * length(lzbearing[23:i,1]))
  
}

plot(x = 1:23,
     y = cumsum(TTT),
     pch = 16, 
     col = 2,
     cex = 1.2,
     las = 1,
     ylab = 'TTT',
     xlab = '# Failures')

TTTplot <- function(time,cens=NULL,show_results = F)  {
  
    n <- length(time)
    oo <- order(time)
    if(is.null(cens)) cens = rep(1,n)
    sorttime <- time[oo]
    sortcens <- cens[oo]
    ttt <- numeric(n)
    ttt[1] <- n*sorttime[1]
    for(i in 2:n)
      {
        ttt[i] <- ttt[i-1]+(n-i+1)*(sorttime[i]-sorttime[i-1])
      }
    ttt <- data.frame(time = sorttime,
                      cens = sortcens,
                      rank = 1:n,
                      "cum total time" = ttt)
    
    colnames(ttt) <- c("time","cens","rank","Cum.Total.Time")#,"i/n","TTT")

    TTT <- ttt[ttt$cens==1,]
    
    nfail <- dim(TTT)[1]
    
    TTT <- cbind(TTT[,-3],
                 TTT$Cum.Total.Time / TTT$Cum.Total.Time[nfail],
                 (1:nfail) / nfail)
    
    colnames(TTT) <- c("time","cens","Cum.Total.Time","TTT","i/n")
    
    W <- sum(TTT$"Cum.Total.Time"[1:(nfail-1)]) / TTT$"Cum.Total.Time"[nfail]
    
    Z <- (W - (nfail - 1) / 2) / sqrt((nfail-1) / 12)
    
    if(show_results) {
      
       print(TTT)
       
       cat("Barlow-Proschan's test\n")
       cat(paste("W=",round(W,4)," k=",nfail,"\n",sep=""))
       cat(paste("Z=",
                 round(Z,4)," p.value=",round(pnorm(-abs(Z)),4),"\n",sep=""))
       
    }

    plot(TTT$"i/n",
         TTT$TTT,
         xlab = "i/n",
         ylab = "TTT",
         xlim = c(0,1),
         ylim = c(0,1),
         pch = 19, 
         main = "TTT plot",
         sub = paste("N. failure = ",
                     nfail," N. censored = ", 
                     n-nfail,sep=""))
    
    lines(c(0,1),
          c(0,1),
          lty = 2)
    
    invisible(list(TTT = TTT, W = W, Z = Z))
    
}

TTTplot(time = lzbearing$megacycles)

7.6.4 - CI for \(\hat{\theta}_{_{MLE}}\) with complete data or Type II censoring

Background Assumptions

\[ \big[\underset{\sim}{\theta},\quad\overset{\sim}{\theta}\big] = \Bigg[\frac{2(TTT)}{\chi^2_{(1-\alpha/2),2r}},\quad\frac{2(TTT)}{\chi^2_{(\alpha/2),2r}}\Bigg] \]

\[ \frac{2(TTT)}{\theta}\sim\chi^2_{2r} \]

Example 7.13

t7.13 <- c(1.08,12.2,17.8,19.1,26,27.9,28.2,32.2,35.9,43.5,44,45.2,45.7,46.3,47.8,rep(47.8,10))
c7.13 <- c(rep(1,15),rep(0,10))

df7.13 <- data.frame(times = t7.13,
                     cens  = c7.13)

knitr::kable(df7.13)
times cens
1.08 1
12.20 1
17.80 1
19.10 1
26.00 1
27.90 1
28.20 1
32.20 1
35.90 1
43.50 1
44.00 1
45.20 1
45.70 1
46.30 1
47.80 1
47.80 0
47.80 0
47.80 0
47.80 0
47.80 0
47.80 0
47.80 0
47.80 0
47.80 0
47.80 0

\[ \begin{eqnarray} \big[\underset{\sim}{\theta},\quad\overset{\sim}{\theta}\big] &=& \Bigg[\frac{2(TTT)}{\chi^2_{(1-\alpha/2),2r}}&,&\quad\frac{2(TTT)}{\chi^2_{(\alpha/2),2r}}&\Bigg]&\\\\ &=&\Bigg[\frac{2(950.88)}{\chi^2_{(0.975),30}}&,&\quad\frac{2(950.88)}{\chi^2_{(0.025),30}}&\Bigg]&\\\\ &=&\Bigg[\frac{1901.76}{46.98}&,&\quad\frac{1901.76}{16.79}&\Bigg]&\\\\ &=&\Bigg[40.48&,&113.26&\Bigg]& \end{eqnarray} \]

res <- TTTplot(time = df7.13$times,
               cens = df7.13$cens)

knitr::kable(res$TTT)
time cens Cum.Total.Time TTT i/n
1.08 1 27.00 0.02839 0.06667
12.20 1 293.88 0.30906 0.13333
17.80 1 422.68 0.44451 0.20000
19.10 1 451.28 0.47459 0.26667
26.00 1 596.18 0.62698 0.33333
27.90 1 634.18 0.66694 0.40000
28.20 1 639.88 0.67293 0.46667
32.20 1 711.88 0.74865 0.53333
35.90 1 774.78 0.81480 0.60000
43.50 1 896.38 0.94268 0.66667
44.00 1 903.88 0.95057 0.73333
45.20 1 920.68 0.96824 0.80000
45.70 1 927.18 0.97508 0.86667
46.30 1 934.38 0.98265 0.93333
47.80 1 950.88 1.00000 1.00000
TTT <- max(res$TTT$Cum.Total.Time)

TTT

[1] 950.88

7.7 - Data analysis with no failures

Data from  berkson200 
  lower upper     Status Case.weights
1   100   100 L-Censored           41
2   100   300   Interval           44
3   300   500   Interval           24
4   500   700   Interval           32
5   700  1000   Interval           29
6  1000  2000   Interval           21
7  2000  4000   Interval            9
8  4000  4000 R-Censored            0

comptime

Snubber.ld <- frame.to.ld(snubber, 
                          response.column = "cycles", 
                          censor.column = "event", 
                          time.units = "Toaster Cycles",
                          case.weight.column = "count", 
                          x.columns = "design")

groupm.mleprobplot(Snubber.ld, 
                   distribution ="Lognormal", 
                   group.var = 1, 
                   relationships = "linear")