Matrix CNC Reliability

rm(list = ls()) # remove all environment
options(warnPartialMatchAttr = T)
library(WeibullR)
library(readxl)
library(ggplot2)
library(magrittr)
source('~/CNC Matrix/itais_functions.R')

Blmr <- read_excel("Breton.xlsx", col_types = c("skip", "skip", "skip", "date", "text", "text", 
     "text", "text", "text", "text", "text", 
     "text", "text", "text", "numeric", "numeric", 
     "numeric", "numeric", "numeric", "numeric", 
     "numeric", "numeric"))
date <- "2012/01/01"
Blmr$Event<-as.numeric(as.Date(Blmr$END.DATE)-as.Date(date))

q <- wblr(Blmr$Event, pch = 0)
q1 <- wblr.conf(wblr.fit(q, dist = "weibull2p"))
plot.wblr(q1, in.legend.blives = F)

q2 <- wblr.conf(wblr.fit(q, dist = "lognormal"))
plot.wblr(q2, in.legend.blives = F)

q3 <- wblr.fit(q, dist = "weibull3p")
plot.wblr(q3)

q4 <- wblr.fit(q, dist = "lognormal3p")
plot.wblr(q4)

b<-Blmr[Blmr$EQUIP.CODE %in% c("CY10194","CY10194-2"),]
competeRisk(x = b, title = "Matrix CNC", pch = 1, date = date)
##    bigIx start stop  intercept        slope     adjR2
## 1      2     1   95 -0.4589068 0.0006070961 0.9744379
## 2      2    96  190 -0.8767926 0.0008159014 0.9345281
## 3      3     1   63 -0.5966098 0.0007428648 0.9811105
## 4      3    64  126 -0.2746622 0.0004794919 0.9881893
## 5      3   127  189 -1.7580328 0.0012342302 0.9598429
## 6      4     1   48 -0.5313212 0.0006718223 0.9859958
## 7      4    49   96 -0.2235679 0.0004408928 0.9879048
## 8      4    97  144 -0.4143181 0.0005615067 0.9727379
## 9      4   145  192 -2.4738595 0.0015682491 0.9648944
## 10     5     1   38 -0.4865422 0.0006218673 0.9895080
## 11     5    39   76 -0.4369792 0.0006087816 0.9416567
## 12     5    77  114 -0.3518984 0.0005252148 0.9751463
## 13     5   115  152 -0.7493475 0.0007340210 0.9346676
## 14     5   153  190 -3.0621233 0.0018401064 0.9778319
## [1] 190
## 3P weibull: 
## 3P log-normal: Bad log-normal 3p solution 
## Weibull 2-paprameters and 3-parameters likelyhood

## Log-normal 2-paprameters and 3-parameters likelyhood

## 3P weibull: 3p optimization did not converge 
## 3P log-normal: 
## Weibull 2-paprameters and 3-parameters likelyhood

## Log-normal 2-paprameters and 3-parameters likelyhood

## 3P weibull: 
## 3P log-normal: 
## Weibull 2-paprameters and 3-parameters likelyhood

## Log-normal 2-paprameters and 3-parameters likelyhood

## [[1]]
##         Eta        Beta        Rsqr      AbPval 
## 1079.394614    9.787809    0.955575   11.149141 
## 
## [[2]]
##          Eta         Beta         Rsqr       AbPval 
## 1689.8855598   10.0566301    0.9385645    5.1288939 
## 
## [[3]]
##          Eta         Beta         Rsqr       AbPval 
## 2128.5279176   34.6796078    0.9312035    3.8430357 
## 
## [[4]]
## [1] 0
f2(b ,"Matrix CNC",MTTF = (q1$fit[[1]]$eta * gamma(1 / q1$fit[[1]]$beta + 1)))
## Matrix CNC  Availability:
## Weibull MTTF 1367.00513070555 
## Events MTBF: 60.1481481481481 
## Events MTTR: 4.5231981981982 
## Events MLDT: 46.8108108108108 
## Technical: 0.93 
## Operational: 0.54
qe <- wblr(Blmr$Event[Blmr$EQUIP.CODE=="CY10192"], pch = 0)
q1 <- wblr.conf(wblr.fit(qe, dist = "weibull2p"))
plot.wblr(q1, in.legend.blives = F)

q2 <- wblr.conf(wblr.fit(qe, dist = "lognormal"))
plot.wblr(q2, in.legend.blives = F)

q3 <- wblr.fit(qe, dist = "weibull3p")
plot.wblr(q3)

q4 <- wblr.fit(qe, dist = "lognormal3p")
plot.wblr(q4)

b<-Blmr[Blmr$EQUIP.CODE %in% c("CY10194"),]
competeRisk(x = b, title = "Eagle CNC", pch = 2, date = date)
##    bigIx start stop  intercept        slope     adjR2
## 1      2     1   85 -0.5663888 0.0007299519 0.9776601
## 2      2    86  170 -0.6035634 0.0007070621 0.9814741
## 3      3     1   57 -0.6499882 0.0008122536 0.9777884
## 4      3    58  114 -0.2839845 0.0005208304 0.9865778
## 5      3   115  171 -0.8837958 0.0008423793 0.9703400
## 6      4     1   42 -0.5625952 0.0007161513 0.9884198
## 7      4    43   84 -0.3539343 0.0005711615 0.9625116
## 8      4    85  126 -0.3973266 0.0005873243 0.9760065
## 9      4   127  168 -0.9846827 0.0008899640 0.9697023
## 10     4   169  210 -1.5489949 0.0011567845       NaN
## 11     5     1   34 -0.5356348 0.0006857463 0.9866836
## 12     5    35   68 -0.7006031 0.0008604840 0.9349616
## 13     5    69  102 -0.2246284 0.0004780613 0.9767320
## 14     5   103  136 -0.3607409 0.0005705126 0.9561409
## 15     5   137  170 -1.0940403 0.0009419335 0.9425322
## [1] 170
## 3P weibull: 
## 3P log-normal: 
## Weibull 2-paprameters and 3-parameters likelyhood

## Log-normal 2-paprameters and 3-parameters likelyhood

## 3P weibull: 
## 3P log-normal: Bad log-normal 3p solution 
## Weibull 2-paprameters and 3-parameters likelyhood

## Log-normal 2-paprameters and 3-parameters likelyhood

## [[1]]
##          Eta         Beta         Rsqr       AbPval 
## 1191.4140912    7.2823776    0.9363845    2.8917027 
## 
## [[2]]
##          Eta         Beta         Rsqr       AbPval 
## 1995.3882920   11.9281006    0.9223948    1.3523012
f2(b,"Eagle CNC",MTTF = (q1$fit[[1]]$eta * gamma(1 / q1$fit[[1]]$beta + 1)))
## Eagle CNC  Availability:
## Weibull MTTF 1198.67851199963 
## Events MTBF: 67.1715976331361 
## Events MTTR: 4.42067901234568 
## Events MLDT: 43.2592592592593 
## Technical: 0.938 
## Operational: 0.585
a<-q$data$dpoints
ae<-qe$data$dpoints

ggplot(data = a,mapping = aes(time,ppp)) + geom_point(color="black") + geom_smooth(color="red")
## `geom_smooth()` using method = 'loess'

ggplot(data = a,mapping = aes(time,ppp)) + stat_density2d()

a<-Blmr$DownTime[is.numeric(Blmr$DownTime) & !is.na(Blmr$DownTime) & Blmr$DownTime!=0 & Blmr$LDT==0]
plot(a)

hist(a)

summary(a)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.9167  1.5000  2.0000  2.4038  3.0000  9.5000
a1<-wblr(a,dist="weibull3p")
plot.wblr(wblr.fit(a1),main="Repair Distribution")

a2<-a1$data$dpoints
ggplot(a2,aes(time,ppp))+ geom_point(color="black") + geom_smooth(color="red")
## `geom_smooth()` using method = 'loess'

a3<-a2$time
write.dcf(a3, file = "repair time")