mcs_delay_data {weibulltools}R Documentation

MCS Delay Data

Description

Create consistent mcs_delay_data based on an existing data.frame (preferred) or on multiple equal length vectors.

Usage

mcs_delay_data(
  data = NULL,
  date_1,
  date_2,
  time,
  status = NULL,
  id = NULL,
  .keep_all = FALSE
)

Arguments

data

Either NULL or a data.frame. If data is NULL, date_1, date_2, time, status and id must be vectors containing the data. Otherwise date_1, date_2, time, status and id can be either column names or column positions.

date_1

A date of class character or Date in the format "yyyy-mm-dd", representing the earlier of the two dates belonging to a particular delay. Use NA for missing elements.

If more than one delay is to be considered, use a list for the vector-based approach and a vector of column names or positions for the data-based approach. The first element is the earlier date of the first delay, the second element is the earlier date of the second delay, and so forth (see 'Examples').

date_2

A date of class character or Date in the format "yyyy-mm-dd". date_2 is the counterpart of date_1 and is used the same as date_1, just with the later date(s) of the particular delay(s). Use NA for missing elements.

time

Operating times. Use NA for missing elements.

status

Optional argument. If used, it must contain binary data (0 or 1) indicating whether a unit is a right censored observation (= 0) or a failure (= 1).

If status is provided, class wt_reliability_data is assigned to the output of mcs_delay, which enables the direct application of estimate_cdf on operating times.

id

Identification of every unit.

.keep_all

If TRUE keep remaining variables in data.

Value

A tibble with class wt_mcs_delay_data that is formed for the downstream Monte Carlo method mcs_delay. It contains the following columns (if .keep_all = FALSE):

If .keep_all = TRUE, the remaining columns of data are also preserved.

The attributes mcs_start_dates and mcs_end_dates hold the name(s) of the column(s) that preserve the input of date_1 and date_2.

See Also

dist_delay for the determination of a parametric delay distribution and mcs_delay for the Monte Carlo method with respect to delays.

Examples

# Example 1 -  Based on an existing data.frame/tibble and column names:
mcs_tbl <- mcs_delay_data(
  data = field_data,
  date_1 = production_date,
  date_2 = registration_date,
  time = dis,
  status = status
)

# Example 2 - Based on an existing data.frame/tibble and column positions:
mcs_tbl_2 <- mcs_delay_data(
  data = field_data,
  date_1 = 7,
  date_2 = 8,
  time = 2,
  id = 1
)

# Example 3 - Keep all variables of the tibble/data.frame entered to argument data:
mcs_tbl_3 <- mcs_delay_data(
  data = field_data,
  date_1 = production_date,
  date_2 = registration_date,
  time = dis,
  status = status,
  id = vin,
  .keep_all = TRUE
)

# Example 4 - For multiple delays (data-based):
mcs_tbl_4 <- mcs_delay_data(
  data = field_data,
  date_1 = c(production_date, repair_date),
  date_2 = c(registration_date, report_date),
  time = dis,
  status = status
)

# Example 5 - Based on vectors:
mcs_tbl_5 <- mcs_delay_data(
  date_1 = field_data$production_date,
  date_2 = field_data$registration_date,
  time = field_data$dis,
  status = field_data$status,
  id = field_data$vin
)

# Example 6 - For multiple delays (vector-based):
mcs_tbl_6 <- mcs_delay_data(
  date_1 = list(field_data$production_date, field_data$repair_date),
  date_2 = list(field_data$registration_date, field_data$report_date),
  time = field_data$dis,
  status = field_data$status,
  id = field_data$vin
)

# Example 7 - For multiple delays (vector-based with named dates):
mcs_tbl_7 <- mcs_delay_data(
  date_1 = list(d11 = field_data$production_date, d12 = field_data$repair_date),
  date_2 = list(d21 = field_data$registration_date, d22 = field_data$report_date),
  time = field_data$dis,
  status = field_data$status,
  id = field_data$vin
)


[Package weibulltools version 2.1.0 Index]