Closed gloriamacia closed 6 months ago
Hi, I think we have a more general way of doing that with heemod (That way, you can use data from WHO, or use your own life tables) : did you have the chance to visit: https://cran.r-project.org/web/packages/heemod/vignettes/g_heterogeneity.html#weighted-results? Best
Thanks a lot for the kind reply - Looking at the vignette but struggling to see the 1:1 connection. (I do agree we would have from the clinical trial individual patient-level data that would at least have the columns age and gender). Seems to me the weight column in the vignette is added by the user with some sort of logic behind of how much each strata should be weighted. Open to use it but I just need first to understand how this would help in our case.
Our current approach (models are built in Excel, trying to migrate to R) is to take the mean age of the trial (calculated indeed using patient-level data which could look like tab_indiv
), retrieve from who the gender-specific mr, and then use the percentage of each gender (calculated using patient-level data) and do a weighted average to get the cohort mr.
You could do something like this:
# in define_parameters you consider the baseline values, for instance you could use the average mortality for your whole dataset:
params <- define_parameters(
age = 41 # average age for instance
sex = NULL, #not sure if that works, you could try "BTSX"
mr = get_who_mr(age, sex),
## ... all other parameters
)
# ... states /strategies
res_mod <- run_model(params, ...) # gets the baseline results
tab_indiv_w <- tibble(
age = 40, sex = 1, weight = .53, # Average age of male patients is 40
age = 42, sex = 0, weight = .47 # Average age of female patients is 42
)
update(res_mod, newdata = tab_indiv_w) # gets the results based on the values specified by tab_indiv_w
Is that more useful?
Ah, got you. Thanks a lot. I still personally prefer to do it before, instead of updating later the model but I agree that this is a valid way of implementing it.
Hi there,
I suggest adding a new function to the package. I am very open to function name suggestions, example:
get_who_mr_cohort_memo
Rationale: A model cohort is rarely only female or male. What seems to me it is currently necessary is to call the function twice (one for each gender) and then apply the percentages e.g. 53% male, to get the combined MR. The suggested operation would be a weighted average.
The idea would be to add a new function which takes the same arguments as
get_who_mr_memo
in addition to the percentage so that the user avoids this extra step.1) I could take care of it and open a pull request (if the team agrees this could add value) 2) I could even give it a go to see if any improvements can be made to the code of the original
get_who_mr_memo