# Data for examples:
date_of_production <- c("2014-07-28", "2014-02-17", "2014-07-14",
"2014-06-26", "2014-03-10", "2014-05-14",
"2014-05-06", "2014-03-07", "2014-03-09",
"2014-04-13", "2014-05-20", "2014-07-07",
"2014-01-27", "2014-01-30", "2014-03-17",
"2014-02-09", "2014-04-14", "2014-04-20",
"2014-03-13", "2014-02-23", "2014-04-03",
"2014-01-08", "2014-01-08")
date_of_registration <- c(NA, "2014-03-29", "2014-12-06", "2014-09-09",
NA, NA, "2014-06-16", NA, "2014-05-23",
"2014-05-09", "2014-05-31", NA, "2014-04-13",
NA, NA, "2014-03-12", NA, "2014-06-02",
NA, "2014-03-21", "2014-06-19", NA, NA)
date_of_repair <- c(NA, "2014-09-15", "2015-07-04", "2015-04-10", NA,
NA, "2015-04-24", NA, "2015-04-25", "2015-04-24",
"2015-06-12", NA, "2015-05-04", NA, NA,
"2015-05-22", NA, "2015-09-17", NA, "2015-08-15",
"2015-11-26", NA, NA)
date_of_report <- c(NA, "2014-10-09", "2015-08-28", "2015-04-15", NA,
NA, "2015-05-16", NA, "2015-05-28", "2015-05-15",
"2015-07-11", NA, "2015-08-14", NA, NA,
"2015-06-05", NA, "2015-10-17", NA, "2015-08-21",
"2015-12-02", NA, NA)
time_in_service <- rep(1000, length(date_of_production))
status <- c(0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0)
# Example 1 - MCS for delay in registration:
mcs_regist <- mcs_delay(
date_1 = date_of_production,
date_2 = date_of_registration,
time = time_in_service,
status = status,
distribution = "lognormal"
)
# Example 2 - MCS for delay in report:
mcs_report <- mcs_delay(
date_1 = date_of_repair,
date_2 = date_of_report,
time = time_in_service,
status = status,
distribution = "exponential"
)
# Example 3 - Reproducibility of random numbers:
set.seed(1234)
mcs_report_reproduce <- mcs_delay(
date_1 = date_of_repair,
date_2 = date_of_report,
time = time_in_service,
status = status,
distribution = "exponential"
)
# Example 4 - MCS for delays in registration and report with same distribution:
mcs_delays <- mcs_delay(
date_1 = list(date_of_production, date_of_repair),
date_2 = list(date_of_registration, date_of_report),
time = time_in_service,
status = status,
distribution = "lognormal"
)
# Example 5 - MCS for delays in registration and report with different distributions:
## Assuming lognormal registration and exponential reporting delays.
mcs_delays_2 <- mcs_delay(
date_1 = list(date_of_production, date_of_repair),
date_2 = list(date_of_registration, date_of_report),
time = time_in_service,
status = status,
distribution = c("lognormal", "exponential")
)
Run the code above in your browser using DataLab