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

New commit for additional statistics #663

merged 32 commits into from
Oct 11, 2023

Conversation

Prerana17
Copy link
Collaborator

@Prerana17 Prerana17 commented Aug 16, 2023

closes ##656

@danielinteractive danielinteractive self-assigned this Aug 16, 2023
Copy link
Collaborator

@danielinteractive danielinteractive left a comment

Choose a reason for hiding this comment

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

Thanks @Prerana17 and @0liver0815 please see comments below

R/Design-methods.R Outdated Show resolved Hide resolved
R/Design-methods.R Show resolved Hide resolved
)

# Create list with median MTD and CV.
additional_stats <- list(
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is nice I think, however I wonder if we can make this more flexible for the user - e.g. how about accepting a list of functions as part of the simulate() call and then the user can define median, cv functions etc. to apply to 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.

Great proposal. I really like that idea. This will add much flexibility e.g. if someone want to see the mean instead of the median etc.. We just have to evaluate, if it is straight forward to implement.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@danielinteractive @0liver0815 Sure, as the next step, I will try to implement the functions where user can define median, cv, mean etc. functions.

@danielinteractive
Copy link
Collaborator

@Prerana17 @ClaraBeckBayer @0liver0815 I am assuming this is the PR moving forward now and not #661 ? or is that not the case? ... please clarify

@0liver0815
Copy link
Collaborator

After talking to @Prerana17, the other PR is closed and the changes that @ClaraBeckBayer added, that were not part of this PR will be added here, so that this PR is up to date. @danielinteractive I think a review makes only sense for you, if the all checks completed without error.

@danielinteractive
Copy link
Collaborator

Thanks @0liver0815 and @Prerana17 for the clarification :) all good. I did initial review here, please have a look since that could change structure a bit.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 17, 2023

Unit Tests Summary

       1 files       36 suites   2m 33s ⏱️
1 174 tests 1 045 ✔️ 129 💤 0
6 191 runs  6 027 ✔️ 164 💤 0

Results for commit 9cdeabe.

♻️ This comment has been updated with latest results.

R/Design-methods.R Outdated Show resolved Hide resolved
Comment on lines 429 to 433
if (is.null(derive)) {
additional_stats <- list()
} else {
additional_stats <- lapply(derive, function(f) f(target_dose_samples))
}
Copy link
Collaborator

@0liver0815 0liver0815 Aug 30, 2023

Choose a reason for hiding this comment

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

If default is an empty list, I think you can get rid of the if statement

Suggested change
if (is.null(derive)) {
additional_stats <- list()
} else {
additional_stats <- lapply(derive, function(f) f(target_dose_samples))
}
additional_stats <- lapply(derive, function(f) f(target_dose_samples))

Comment on lines 1034 to 1038
if (is.null(derive)) {
additional_stats <- list()
} else {
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.

I think it is the same here. lapply works with an empty list.

Suggested change
if (is.null(derive)) {
additional_stats <- list()
} else {
additional_stats <- lapply(derive, function(f) f(target_dose_samples))
}
additional_stats <- lapply(derive, function(f) f(target_dose_samples))

Comment on lines 4688 to 4693
# Create a function for additional statistical summary.
if (is.null(derive)) {
additional_stats <- list()
} else {
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.

Same here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you need to add derive = list()to the function as done in line 212 above.

R/Simulations-class.R Outdated Show resolved Hide resolved
Copy link
Collaborator

@danielinteractive danielinteractive left a comment

Choose a reason for hiding this comment

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

thanks @Prerana17 , nice work! please see comments below, can you also add a NEWS entry?

R/Design-methods.R Outdated Show resolved Hide resolved
R/Design-methods.R Outdated Show resolved Hide resolved
median_mtd = median(target_dose_samples),
cv_mtd = mad(target_dose_samples) / median(target_dose_samples)
)
# 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

examples/Simulations-method-summary.R Outdated Show resolved Hide resolved
R/Design-methods.R Outdated Show resolved Hide resolved
@@ -209,7 +212,7 @@ setMethod("simulate",
truth, args = NULL, firstSeparate = FALSE,
mcmcOptions = McmcOptions(),
parallel = FALSE, nCores =
min(parallel::detectCores(), 5),
min(parallel::detectCores(), 5), derive = list(),
...) {
nsim <- safeInteger(nsim)
Copy link
Collaborator

Choose a reason for hiding this comment

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

please assert derive properties here (list, named, unique names, elements are functions) using checkmate package functions


# 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

o$check(
identical(length(object@additional_stats), nSims),
"additional_stats must have same length as the number of simulations"
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

also check that it has names?


cat(
"Results of Additional Statistical Calculation : \n",
paste(names(summary_stat_op), ":", round(summary_stat_op), "\n")
Copy link
Collaborator

Choose a reason for hiding this comment

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

ok as a first version, just wondering if we should follow up in another PR to make this printing more flexible

@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2023

badge

Code Coverage Summary

Filename                    Stmts    Miss  Cover    Missing
------------------------  -------  ------  -------  ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
R/checkmate.R                  49       0  100.00%
R/crmPack-package.R             4       0  100.00%
R/Data-class.R                 91       4  95.60%   466-467, 473-478
R/Data-methods.R              203       0  100.00%
R/Data-validity.R             144       1  99.31%   21
R/Design-class.R               75       0  100.00%
R/Design-methods.R           2763    2328  15.74%   111, 136-139, 147-158, 162-181, 193-197, 203-216, 392-969, 1034-1375, 1426, 1616, 1787-4592, 4711
R/Design-validity.R            20       0  100.00%
R/fromQuantiles.R             178      69  61.24%   237-378
R/helpers_covr.R               23       0  100.00%
R/helpers_data.R               84       1  98.81%   139
R/helpers_design.R             75      36  52.00%   22, 77-129
R/helpers_jags.R               77       0  100.00%
R/helpers_model.R              78       4  94.87%   38, 89-90, 139
R/helpers_rules.R             447       0  100.00%
R/helpers.R                   244      80  67.21%   107-127, 140, 153-167, 203-323, 353-402
R/logger.R                     11       0  100.00%
R/mcmc.R                      287      18  93.73%   90-95, 374-375, 385, 387-388, 391-394, 577-578, 667, 673, 731
R/McmcOptions-class.R          18       0  100.00%
R/McmcOptions-methods.R         8       1  87.50%   43
R/McmcOptions-validity.R       42       0  100.00%
R/Model-class.R               962     155  83.89%   135-137, 205-207, 211-213, 272-274, 346-348, 352-354, 433-435, 502-504, 566-570, 573-576, 679-682, 686-687, 802-806, 926-928, 932-940, 1085-1087, 1092-1095, 1099-1102, 1218-1222, 1224-1227, 1231-1234, 1237, 1398-1408, 1413-1419, 1574-1577, 1583-1590, 1747, 1756, 1765, 1774, 1783-1788, 1924, 1933, 1942, 1950-1952, 2693-2722, 2726-2732, 2739-2743, 2748, 2855-2868, 2894, 2990-2992, 2996, 3089-3091, 3095, 3164-3176, 3194
R/Model-methods.R             376      34  90.96%   78, 155, 208, 675-720, 1039-1048
R/Model-validity.R            435       8  98.16%   430-433, 442-445
R/ModelParams-class.R          13       0  100.00%
R/ModelParams-validity.R       21       0  100.00%
R/Rules-class.R               416       2  99.52%   3102, 3169
R/Rules-methods.R            1429     164  88.52%   741, 744, 887, 890, 893, 1008, 1011, 1014, 1134-1137, 1171, 1274-1277, 1312, 2475-2483, 2507-2514, 3017-3260
R/Rules-validity.R            418       0  100.00%
R/Samples-class.R               1       0  100.00%
R/Samples-methods.R          1104      45  95.92%   406-416, 644, 1358-1393, 1616, 1629, 1794, 2124-2129
R/Samples-validity.R           10       0  100.00%
R/Simulations-class.R          51      32  37.25%   408-727
R/Simulations-methods.R      1604    1460  8.98%    65-350, 406, 416-435, 448-453, 500-509, 675-2944
R/Simulations-validity.R       75      75  0.00%    20-168
R/utils.R                       6       0  100.00%
TOTAL                       11842    4517  61.86%

Diff against main

Filename                    Stmts    Miss  Cover
------------------------  -------  ------  --------
R/Design-methods.R            +29     +18  +0.24%
R/Simulations-class.R          +1       0  +1.25%
R/Simulations-methods.R        +7      +6  +0.02%
R/Simulations-validity.R      +75     +75  +100.00%
TOTAL                        +112     +99  -0.48%

Results for commit: 9cdeabe

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@Prerana17 Prerana17 merged commit 14d4d52 into main Oct 11, 2023
20 checks passed
@Prerana17 Prerana17 deleted the 656_additional_stat branch October 11, 2023 08:35
Puzzled-Face added a commit that referenced this pull request Oct 16, 2023
* Refactor setSeed and getResultList (#676)

Co-authored-by: Daniel Sabanes Bove <danielinteractive@users.noreply.github.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

* 675: Add `DesignGrouped` (#677)

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

* Fixes first cohort logic for grouped design simulation (#684)

* Remove references to is.bool and is.scalar (#686)

* Remove references to is.bool and is.scalar

* [skip actions] Restyle files

* Responding to review comments

* Removing lintr moan

* Updating documentation

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

* Remove plot.gtable and print.gtable (#697)

* Remove plot.gtable and print.gtable

* Fix _pkgdown.yaml

* 690 remove safeinteger and iswholenumber 1 (#693)

* Remove safeInteger and is.wholenumber

* Fixing false test failures

* [skip actions] Restyle files

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

* Remove noOverlap (#695)

* remove %~% (#689)

* remove %~%

* Fixing NAMESPACE

* 699 remove multiplot (#700)

* Remove multiplot

* Correct typo

* Correcting typo in argument to assert_integerish

* New commit for additional statistics (#663)

* New commit for additional statistics

* [skip actions] Restyle files

* Update: additional statstics added to other designs bug correction suggetions by Clara

* bug corrected

* Update: Additional_stats

* update: additional_stats

* updaze: error_corrections (additional_stats)

* update: additional_statistics

* Dynamic: Additional_statistical_summary

* Additional statistical summary function update

* additional statistical summary changes

* Update: Additional Statistical Summary

* small change: additional stat summary

* Suggested changes: additional_statistics and validation

* [skip actions] Restyle files

* Simulation refectoring

* Simulation small update

* [skip actions] Restyle files

* small update

* incorrectly named file:delete

* removing documentation errors

* update yaml file

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Clara <clara.beck@bayer.com>
Co-authored-by: Oliver Boix <95433070+0liver0815@users.noreply.github.com>
Co-authored-by: Daniel Sabanes Bove <danielinteractive@users.noreply.github.com>

* Refactor myBarplot (#703)

* Refactor myBarplot

* [skip actions] Restyle files

* Responding to lintr complaints

* Rsponding to review comments

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: Oliver Boix <95433070+0liver0815@users.noreply.github.com>
Co-authored-by: Daniel Sabanes Bove <danielinteractive@users.noreply.github.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Prerana Chandratre <82475780+Prerana17@users.noreply.github.com>
Co-authored-by: Clara <clara.beck@bayer.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add additional statistics to the analysis of simulation output
4 participants