Skip to content

Commit

Permalink
add naive method
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Sabanes Bove committed Apr 8, 2024
1 parent ae213b6 commit 5e006b9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
34 changes: 34 additions & 0 deletions simulations/naive.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Method for a single data set.
naive_method <- function(df) {
df$arm <- factor(df$arm)
model <- naive(
resp = "tt_pfs",
trt = "arm",
subgr = c("x_1", "x_2", "x_3", "x_4", "x_5", "x_6", "x_7", "x_8", "x_9", "x_10"),
data = df,
resptype = "survival",
status = "ev_pfs"
)
s <- summary(model)
s
}

# Analysis of a single scenario.
naive_analysis <- function(scenario) {
assert_list(scenario)
results <- lapply(scenario, naive_method)
}

# Results across all scenarios.
naive_file <- "results/naive.rds"
naive_results <- if (file.exists(naive_file)) {
readRDS(naive_file)
} else {
res <- lapply(
scenarios,
function(x) naive_analysis(x$scenario)
)
saveRDS(res, file = naive_file)
res
}
# todo: modify results format once target is clear
1 change: 1 addition & 0 deletions simulations/run.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ source("functions.R")
# Run analyses ----

source("naivepop.R") # fast.
source("naive.R")
source("ridge.R") # takes a few minutes.
source("lasso.R") # takes a few minutes.

0 comments on commit 5e006b9

Please sign in to comment.