insightsengineering / rbmi

Reference based multiple imputation R package
https://insightsengineering.github.io/rbmi/
Other
17 stars 6 forks source link

Enable multiplicative delta in tipping point analysis #278

Open nociale opened 2 years ago

nociale commented 2 years ago

This might be useful to implement "multiplicative" delta strategies, e.g. delta = alpha*y

gowerc commented 2 years ago

@nociale

For reference the original proposed solution was to add the outcome value onto the delta_template but we realised this isn't viable as it is different between each imputed dataset

I was just thinking, a solution for this could be the ability to provide a function instead of a data.frame (though providing a data.frame would still be the default and recommend way to do delta adjustment). The function would take a dataframe as its input and return a delta dataframe as its output, this way we can hand over the delta_template data.frame but with the outcome value attached for each iteration across the different imputed datasets. i.e.

delta_fun <- function(df) {
    df %>%
        mutate(delta = outcome * 1.3) 
}

analysis(
    ...
    delta = delta_fun
)
nociale commented 2 years ago

@gowerc I agree this solution would work! Could you just clarify what do you mean by "we can hand over the delta_template data.frame but with the outcome value attached for each iteration across the different imputed datasets".

Procedure:

  1. delta_fun() takes an imputed dataset, adds a column "delta" containing the delta adjustment (not the new adjusted outcomes) and returns this dataset.
  2. This dataset is then internally used as a "delta" dataset to implement the user-specified delta strategy as per output of delta_fun().
  3. This is repeated for each imputed dataset. This is basically the main difference with respect to the current implementation. The delta value is different for each imputed dataset since it depends on the imputed values..

Correct or I misunderstood something?

wolbersm commented 2 years ago

@gowerc and @nociale, I am really not convinced whether such an enhancement is needed within rbmi. I am also a bit wary about mixing the additive scale (on which all our models run) with a multiplicative scale for this single enhancement.

gowerc commented 2 years ago

@wolbersm , Even if we don't directly support multiplicative scaling I do quite like the idea of allowing users to provide functions as the input which manipulate the datasets on each iteration as this allows us to attach the outcome variable for each imputed dataset which gives a lot more flexibility for non-additive scaling i.e. add +3 if outcome > 10

wolbersm commented 2 years ago

@gowerc Thanks for explaining, I agree this would be a neat addition. However, I am really not sure how often this would actually be used in practice. My sense is that people will mostly use simple delta-adjustments and I think we currently provide enough flexibility for this.