
Restrict Imputed --DTC date to Minimum/Maximum Dates
Source: R/derive_vars_dt.R
restrict_imputed_dtc_dt.RdRestrict Imputed --DTC date to Minimum/Maximum Dates
Usage
restrict_imputed_dtc_dt(
dtc,
imputed_dtc,
min_dates,
min_dates_strict,
max_dates,
max_dates_strict
)Arguments
- dtc
-
The
--DTCdate to imputeA character date is expected in a format like
yyyy-mm-ddoryyyy-mm-ddThh:mm:ss. Trailing components can be omitted and-is a valid "missing" value for any component.- Permitted values
a character date variable
- Default value
none
- imputed_dtc
-
The imputed
--DTCdate- Default value
none
- min_dates
-
Minimum dates
A list of dates is expected. It is ensured that the imputed date is not before any of the specified dates, e.g., that the imputed adverse event start date is not before the first treatment date. Only dates which are in the range of possible dates of the
dtcvalue are considered. The possible dates are defined by the missing parts of thedtcdate (see example below). This ensures that the non-missing parts of thedtcdate are not changed. A date or date-time object is expected. For exampleimpute_dtc_dt( "2020-11", min_dates = list( ymd("2020-12-06"), ymd("2020-11-11") ), highest_imputation = "M" )returns
"2020-11-11"because the possible dates for"2020-11"range from"2020-11-01"to"2020-11-30". Therefore"2020-12-06"is ignored. Returning"2020-12-06"would have changed the month although it is not missing (in thedtcdate).- Permitted values
a list of dates, e.g.
list(ymd_hms("2021-07-01T04:03:01"), ymd_hms("2022-05-12T13:57:23"))- Default value
NULL
- min_dates_strict
-
Minimum dates (strict)
The argument works like the
min_datesargument but it affects the behavior of themin_datesandmax_datesarguments. The range which is used to determine which of themin_datesandmax_datesare considered is restricted by the dates specified formin_dates_strict.For example
impute_dtc_dt( "2020-11", min_dates_strict = list( ymd("2020-11-24") ), max_dates = list( ymd("2020-11-22") ), highest_imputation = "M", date_imputation = "last", time_imputation = "last" )returns
"2020-11-30". The possible dates for"2020-11"range from"2020-11-01"to"2020-11-30". Themin_dates_strictargument restricts this range to"2020-11-24"to"2020-11-30". Therefore"2020-11-22"(from themax_datesargument) is ignored as it is not within the restricted range.- Permitted values
a list of dates, e.g.
list(ymd_hms("2021-07-01T04:03:01"), ymd_hms("2022-05-12T13:57:23"))- Default value
NULL
- max_dates
-
Maximum dates
A list of dates is expected. It is ensured that the imputed date is not after any of the specified dates, e.g., that the imputed date is not after the data cut off date. Only dates which are in the range of possible dates are considered. A date or date-time object is expected.
- Permitted values
a list of dates, e.g.
list(ymd_hms("2021-07-01T04:03:01"), ymd_hms("2022-05-12T13:57:23"))- Default value
NULL
- max_dates_strict
-
Maximum dates (strict)
The argument works like the
max_datesargument but it affects the behavior of themin_datesandmax_datesarguments. The range which is used to determine which of themin_datesandmax_datesare considered is restricted by the dates specified formax_dates_strict.- Permitted values
a list of dates, e.g.
list(ymd_hms("2021-07-01T04:03:01"), ymd_hms("2022-05-12T13:57:23"))- Default value
NULL
Value
The last of the minimum dates (
min_dates) which are in the range of the partial--DTCdate (dtc)The first of the maximum dates (
max_dates) which are in the range of the partial--DTCdate (dtc)imputed_dtcif the partial--DTCdate (dtc) is not in range of any of the minimum or maximum dates.
See also
impute_dtc_dtm(), impute_dtc_dt()
Utilities used for date imputation:
dt_level(),
dtm_level(),
get_imputation_target_date(),
get_imputation_target_time(),
get_partialdatetime(),
restrict_imputed_dtc_dtm()