impute_duration {drugprepr} | R Documentation |
Replace missing or implausible prescription durations
Description
Instead of replacing missing stop dates, we impute the durations and then infer the stop dates from there.
Usage
impute_duration(
data,
method,
where = is.na,
group = c("patid", "start_date"),
...
)
Arguments
data |
A data frame containing columns |
method |
Method for imputing the values. See details. |
where |
Logical vector, or function applied to |
group |
Level of structure for imputation. Defaults to whole study population. |
... |
Extra arguments, currently ignored |
Details
We can fix clashing start dates by setting group
to start_date
and patid
, i.e. average over groups with more than one member;
any metric should return the original values if the group size is one.
Value
A data frame of the same structure as data
, with values imputed
Examples
example_duration <- transform(example_therapy, duration = qty / ndd)
impute_duration(example_duration, method = 'mean', group = 'patid')
[Package drugprepr version 0.0.4 Index]