Genentech / psborrow2

psborrow2: Bayesian Dynamic Borrowing Simulation Study and Analysis
https://genentech.github.io/psborrow2/
Other
16 stars 2 forks source link

simulate event data #259

Closed gravesti closed 6 months ago

gravesti commented 8 months ago

Things to do:

gravesti commented 7 months ago

@mattsecrest Could you have a look? The vignette should be a pretty good walk-through of the functionality.

mattsecrest commented 6 months ago

@gravesti sorry for the delay on this! I am stuck on the vignette. I am not able to access data_age_score$X:

r$> data_age_score
Baseline Data List

Internal Treated
 patid ext trt      age    score
     1   0   1 54.16013 4.438124
     2   0   1 54.23098 5.090497
     3   0   1 58.57437 4.911435
     4   0   1 57.41674 5.630754
     5   0   1 54.74589 3.467098
     6   0   1 53.83475 4.510130
Internal Control
 patid ext trt      age    score
   101   0   0 58.19848 6.046629
   102   0   0 55.97334 5.715178
   103   0   0 57.05087 2.339077
   104   0   0 57.48266 4.515012
   105   0   0 55.51567 4.704842
   106   0   0 56.94977 4.651528
External Control
 patid ext trt      age    score
   151   1   0 61.88926 4.217798
   152   1   0 62.48363 5.249825
   153   1   0 63.69380 3.541029
   154   1   0 59.88529 4.473075
   155   1   0 59.55890 4.370421
   156   1   0 58.13547 5.578722
r$> data_age_score$age
NULL

I am actually not sure how the figure rendered...

gravesti commented 6 months ago

@mattsecrest

r$> data_age_score$age
NULL

I think you need this line

df_age_score <- as.data.frame(data_age_score)
df_age_score$age

but I see now there is an issue with that as.data.frame method, looks like only one arm is included at the moment.

gravesti commented 6 months ago

Looks as though the as.data.frame method is not registered properly, so the method list is being used :(

mattsecrest commented 6 months ago

@gravesti finally got around to a proper review and wow this is a lot of new functionality and it all works great! I haven't tested every possible combo yet, but everything is working and it looks quite general.

A few questions are on how much S4 to expose:

For enrollment, you can pass a function to sample times for your pts. Times can be negative (eg fun = \(n) rnorm(n, -100, 10)). Worth a warning?

I was at first thrown off by drift_hr = c(1, 1.2)) in setting up my_data_sim_setup bc it appeared to then handle both scenarios, whereas passing n_trt_int = c(100, 150) in create_baseline_object did not. What is the reason drift HR has this unique ability? Maybe worth some clarifying text? Is there a way to combine SimDataLists in case users want to do multiple N trt?

gravesti commented 6 months ago

@mattsecrest Thanks! Good points. I'm going to create a feature branch and merge these changes in. Then I will do smaller PRs onto that to implement the things you noted and add the tests