Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New commit for additional statistics #663

Merged
merged 32 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
02e6855
New commit for additional statistics
Prerana17 Aug 16, 2023
94c076f
Merge 02e685556ccd1e12becd15155c4188def6d45f24 into 23982ded06130d207…
Prerana17 Aug 16, 2023
f4280f9
[skip actions] Restyle files
github-actions[bot] Aug 16, 2023
96ea829
Update: additional statstics added to other designs bug correction su…
Prerana17 Aug 17, 2023
ebfd762
bug corrected
ClaraBeckBayer Aug 17, 2023
2741f9a
Update: Additional_stats
Prerana17 Aug 18, 2023
cfccb61
update: additional_stats
Prerana17 Aug 18, 2023
6dc58eb
updaze: error_corrections (additional_stats)
Prerana17 Aug 18, 2023
e24202b
update: additional_statistics
Prerana17 Aug 21, 2023
7a94c59
Dynamic: Additional_statistical_summary
Prerana17 Aug 30, 2023
27d41e3
Additional statistical summary function update
Prerana17 Aug 31, 2023
c329a82
additional statistical summary changes
Prerana17 Aug 31, 2023
4940312
Update: Additional Statistical Summary
Prerana17 Sep 1, 2023
2ff5275
small change: additional stat summary
Prerana17 Sep 1, 2023
969b530
Merge branch 'main' into 656_additional_stat
0liver0815 Sep 1, 2023
bea2537
Suggested changes: additional_statistics and validation
Prerana17 Sep 14, 2023
1ec6575
Merge bea25375ae19e5b5694853af2cda9c8cec7fe27b into 1762da78c4b3aeaa6…
Prerana17 Sep 14, 2023
1e424d9
[skip actions] Restyle files
github-actions[bot] Sep 14, 2023
24a3591
Merge branch 'main' into 656_additional_stat
0liver0815 Sep 18, 2023
8e06ac3
Simulation refectoring
Prerana17 Sep 28, 2023
ec070be
Simulation small update
Prerana17 Oct 6, 2023
fac045c
Merge branch 'main' into 656_additional_stat
Prerana17 Oct 9, 2023
a6a2ca9
Merge fac045c5a79e581d0e4d4062fb8765f661bafa24 into d6d5434713e696c23…
Prerana17 Oct 9, 2023
53955f8
[skip actions] Restyle files
github-actions[bot] Oct 9, 2023
ecfcff5
small update
Prerana17 Oct 9, 2023
b9e7ca5
Merge branch '656_additional_stat' of https://github.com/Roche/crmPac…
Prerana17 Oct 9, 2023
7b113d2
incorrectly named file:delete
Prerana17 Oct 9, 2023
232c94a
removing documentation errors
Prerana17 Oct 9, 2023
97e309a
update yaml file
Prerana17 Oct 10, 2023
7192f55
Merge branch 'main' into 656_additional_stat
Prerana17 Oct 10, 2023
4717780
Merge branch 'main' into 656_additional_stat
Prerana17 Oct 10, 2023
9cdeabe
Merge branch 'main' into 656_additional_stat
danielinteractive Oct 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ Collate:
'Samples-validity.R'
'Samples-class.R'
'mcmc.R'
'Simulations-validity.R'
'Simulations-class.R'
'helpers_rules.R'
'Model-methods.R'
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ usable instances of all concrete subclasses of `Increments`, `Model`, `NextBest`
* Include rolling CRM design, which was previously only available in a separate
GitHub branch.
* Additional authors and change of maintainer.
* Included 'additional_stats' to add reporting of additional parameters to method simulate to summarize MTD.
* 'report_label' can be added to stopping rules for individual or combined stopping rule reporting.

# Version 1.0.0

Expand Down
78 changes: 72 additions & 6 deletions R/Design-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ NULL
##' @param nCores how many cores should be used for parallel computing?
##' Defaults to the number of cores on the machine, maximum 5.
##' @param \dots not used
##' @param derive a named list of functions which derives statistics, based on the
##' vector of posterior MTD samples. Each list element must therefore accept
##' one and only one argument, which is a numeric vector, and return a number.
##'
##' @return an object of class \code{\linkS4class{Simulations}}
##'
Expand All @@ -57,7 +60,7 @@ setMethod("simulate",
truth, args = NULL, firstSeparate = FALSE,
mcmcOptions = McmcOptions(),
parallel = FALSE, nCores =
min(parallel::detectCores(), 5L),
min(parallel::detectCores(), 5), derive = list(),
Prerana17 marked this conversation as resolved.
Show resolved Hide resolved
...) {
## checks and extracts
assert_function(truth)
Expand Down Expand Up @@ -259,6 +262,18 @@ setMethod("simulate",
data = thisData
)

# Get the MTD estimate from the samples.

target_dose_samples <- dose(
mean(object@nextBest@target),
model = object@model,
samples = thisSamples
)

# Create a function for additional statistical summary.

additional_stats <- lapply(derive, function(f) f(target_dose_samples))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
additional_stats <- lapply(derive, function(f) f(target_dose_samples))
additional_stats <- lapply(derive, f, target_dose_samples)

should work too I guess?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's throwing error. So I kept same.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep makes sense actually


## return the results
thisResult <-
list(
Prerana17 marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -273,7 +288,8 @@ setMethod("simulate",
stopit,
"message"
),
report_results = stopit_results
report_results = stopit_results,
additional_stats = additional_stats
)
return(thisResult)
}
Expand Down Expand Up @@ -313,13 +329,17 @@ setMethod("simulate",
stopResults <- lapply(resultList, "[[", "report_results")
stop_matrix <- as.matrix(do.call(rbind, stopResults))

# Result list of additional statistical summary.
additional_stats <- lapply(resultList, "[[", "additional_stats")

## return the results in the Simulations class object
ret <- Simulations(
data = dataList,
doses = recommendedDoses,
fit = fitList,
stop_report = stop_matrix,
stop_reasons = stopReasons,
additional_stats = additional_stats,
seed = RNGstate
)

Expand Down Expand Up @@ -528,6 +548,9 @@ setMethod("simulate",
##' @param nCores how many cores should be used for parallel computing?
##' Defaults to the number of cores on the machine, maximum 5.
##' @param \dots not used
##' @param derive a named list of functions which derives statistics, based on the
##' vector of posterior MTD samples. Each list element must therefore accept
##' one and only one argument, which is a numeric vector, and return a number.
##'
##' @return an object of class \code{\linkS4class{DualSimulations}}
##'
Expand All @@ -546,7 +569,7 @@ setMethod("simulate",
mcmcOptions = McmcOptions(),
parallel = FALSE,
nCores =
min(parallel::detectCores(), 5L),
min(parallel::detectCores(), 5), derive = list(),
...) {
## checks and extracts
assert_function(trueTox)
Expand Down Expand Up @@ -837,6 +860,19 @@ setMethod("simulate",
data = thisData
)

# Get the MTD estimate from the samples.

target_dose_samples <- dose(
mean(object@nextBest@target),
model = object@model,
samples = thisSamples
)

# Create a function for additional statistical summary.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here


additional_stats <- lapply(derive, function(f) f(target_dose_samples))


## return the results
thisResult <-
list(
Expand All @@ -861,7 +897,8 @@ setMethod("simulate",
attr(
stopit,
"message"
)
),
additional_stats = additional_stats
)

return(thisResult)
Expand Down Expand Up @@ -912,6 +949,9 @@ setMethod("simulate",
## for dual simulations as it would fail in summary otherwise (for dual simulations reporting is not implemented)
stop_report <- matrix(TRUE, nrow = nsim)

## For dual simulations summary of additional statistics.
additional_stats <- lapply(resultList, "[[", "additional_stats")

## return the results in the DualSimulations class object
ret <- DualSimulations(
data = dataList,
Expand All @@ -922,6 +962,7 @@ setMethod("simulate",
fit_biomarker = fitBiomarkerList,
stop_report = stop_report,
stop_reasons = stopReasons,
additional_stats = additional_stats,
seed = RNGstate
)

Expand Down Expand Up @@ -3968,6 +4009,9 @@ setMethod("simulate",
##' @param nCores how many cores should be used for parallel computing?
##' Defaults to the number of cores on the machine (maximum 5)
##' @param \dots not used
##' @param derive a named list of functions which derives statistics, based on the
##' vector of posterior MTD samples. Each list element must therefore accept
##' one and only one argument, which is a numeric vector, and return a number.
##'
##' @return an object of class \code{\linkS4class{Simulations}}
##'
Expand All @@ -3987,7 +4031,8 @@ setMethod("simulate",
deescalate = TRUE,
mcmcOptions = McmcOptions(),
DA = TRUE,
parallel = FALSE, nCores = min(parallel::detectCores(), 5L),
parallel = FALSE, nCores = min(parallel::detectCores(), 5),
derive = list(),
...) {
## checks and extracts
assert_function(truthTox)
Expand Down Expand Up @@ -4456,6 +4501,19 @@ setMethod("simulate",
data = thisData
)

# Get the MTD estimate from the samples.

target_dose_samples <- dose(
mean(object@nextBest@target),
model = object@model,
samples = thisSamples
)

# Create a function for additional statistical summary.

additional_stats <- lapply(derive, function(f) f(target_dose_samples))


## return the results
thisResult <-
list(
Expand All @@ -4470,7 +4528,8 @@ setMethod("simulate",
attr(
stopit,
"message"
)
),
additional_stats = additional_stats
)
return(thisResult)
}
Expand Down Expand Up @@ -4514,17 +4573,22 @@ setMethod("simulate",
stopReasons <- lapply(resultList, "[[", "stop")

stop_report <- matrix(TRUE, nrow = nsim)

additional_stats <- lapply(resultList, "[[", "additional_stats")

## return the results in the Simulations class object
ret <- DASimulations(
data = dataList,
doses = recommendedDoses,
fit = fitList,
trialduration = trialduration,
stop_report = stop_report,
additional_stats = additional_stats,
stop_reasons = stopReasons,
seed = RNGstate
)


return(ret)
}
)
Expand Down Expand Up @@ -4686,13 +4750,15 @@ setMethod(
stop_reasons <- lapply(this_list, "[[", "stop")
report_results <- lapply(this_list, "[[", "results")
stop_report <- as.matrix(do.call(rbind, report_results))
additional_stats <- lapply(this_list, "[[", "additional_stats")

Simulations(
data = data_list,
doses = recommended_doses,
fit = fit_list,
stop_reasons = stop_reasons,
stop_report = stop_report,
additional_stats = additional_stats,
seed = rng_state
)
})
Expand Down
Loading