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

Translate func_MCMC()'s subfunctions to C++ #11

Open
2 of 17 tasks
wleoncio opened this issue Jun 7, 2024 · 13 comments
Open
2 of 17 tasks

Translate func_MCMC()'s subfunctions to C++ #11

wleoncio opened this issue Jun 7, 2024 · 13 comments
Assignees
Labels
enhancement New feature or request

Comments

@wleoncio
Copy link
Member

wleoncio commented Jun 7, 2024

Files to be translated

  • func_MCMC_graph()
  • updateGamma()
  • UpdateRPlee11()
  • calJpost()

Cleanup

  •  Test all valid combinations of model.type, MRF2b and MRF_G (see next section)
  •  Print final benchmarks
  •  Default all calls to C++ version
  •  Remove R code
  •  Move all TODOs to issues

Combinations of BayesSurvive() to test

Not all combos are valid, see #11 (comment).

Test number model.type MRF_G MRF_2b
1 Pooled FALSE FALSE
2 Pooled TRUE FALSE
3 CoxBVSSL FALSE FALSE
4 CoxBVSSL TRUE FALSE
5 Sub-struct FALSE FALSE
6 Sub-struct FALSE TRUE
7 Sub-struct TRUE FALSE
8 Sub-struct TRUE TRUE
  •  Test 1
  • Test 2
  • Test 3
  • Test 4
  • Test 5
  • Test 6
  • Test 7
  • Test 8
@wleoncio wleoncio added the enhancement New feature or request label Jun 7, 2024
@wleoncio wleoncio self-assigned this Jun 7, 2024
wleoncio added a commit that referenced this issue Jun 12, 2024
wleoncio added a commit that referenced this issue Jun 20, 2024
This is necessary for `func_MCMC_graph()` to be called and work on #11 to continue.
zhizuio pushed a commit that referenced this issue Jun 21, 2024
* Added `src/.gitignore`

* Added test skeleton

Literally the output of `usethis::use_testthat()`

* Added README as test script (#13)

* Restyled file

Output of `styler::style_file()`.

* Added unit tests (solves #13)

* Added gcno files to .gitignore

* Added `inst/doc` to .gitignore

Those are generated files that get removed whenever `devtools::check()` is ran.

* Finished writing tests for #13

* Sped up #13 tests 3x

* Resolved TODO, suppressed output on test (#13)

* Reinstated test with `MRF.G = FALSE` (#13)

This is necessary for `func_MCMC_graph()` to be called and work on #11 to continue.

* Added test for `MRF.G = FALSE` (closes #13)

* Relaxed unit test expectations

So checks passes on macOS
wleoncio added a commit that referenced this issue Jun 21, 2024
wleoncio added a commit that referenced this issue Jun 21, 2024
wleoncio added a commit that referenced this issue Jul 29, 2024
wleoncio added a commit that referenced this issue Jul 29, 2024
wleoncio added a commit that referenced this issue Jul 29, 2024
wleoncio added a commit that referenced this issue Aug 15, 2024
@wleoncio
Copy link
Member Author

Benchmark results for calling BayesSurvive() after translation of func_MCMC_graph():

Unit: seconds
 expr       min        lq     mean    median       uq      max neval cld
    R 48.663260 52.858755 56.45211 54.208202 58.65805 82.42916    30  a 
  C++  7.715861  8.870257 10.02130  9.466554 10.06589 24.06125    30   b

wleoncio added a commit that referenced this issue Aug 15, 2024
@zhizuio
Copy link
Collaborator

zhizuio commented Aug 15, 2024

Benchmark results for calling BayesSurvive() after translation of func_MCMC_graph():

Unit: seconds
 expr       min        lq     mean    median       uq      max neval cld
    R 48.663260 52.858755 56.45211 54.208202 58.65805 82.42916    30  a 
  C++  7.715861  8.870257 10.02130  9.466554 10.06589 24.06125    30   b

Supert!

zhizuio pushed a commit that referenced this issue Aug 15, 2024
* Added `src/.gitignore`

* Added placeholder for `func_MCMC_graph_cpp()` (#11)

* Added `cpp` flag (#11)

* Updated docs

* Added test file for `func_MCMC_graph_cpp()` (#11)

* Translated a bit more of #11

* Added FIXME (#11)

* Updated RoxygenNote version

* Properly exporting `func_MCMC_graph_cpp()` (#11)

* Fixed syntax (#11)

* Updated unit test (#11)

* Translated a bit more of #11

* Added commented R code to loop (#11)

* Translated rest of `func_MCMC_graph()' (#11)

* Added unit tests for `func_MCMC_graph()` (#11)

* Put `func_MCMC()` progressbar under `verbose` (#14)

Otherwise, the `pb` would be drawn even if the user sets `verbose = FALSE` on `BayesSurvive()` (which I assume is not the intended behaviour).

* Updated NEWS.md (#11)
@zhizuio
Copy link
Collaborator

zhizuio commented Aug 15, 2024

Hi Waldir,

I have the following error when installing the package from GitHub. One solution is to always keep the folder inst/doc/... with vignettes. Probably you have another better solution?

image

@wleoncio
Copy link
Member Author

Hi George,

I can reproduce the error and your solution. Keeping track of built files (i.e., anything under /inst/doc) is not ideal, though.

What's the use of that build folder anyway? I tried deleting it and the package still installs with vignettes, you can also try it from the fix-vignettes branch:

remotes::install_github("ocbe-uio/BayesSurvive@fix-vignettes", build_vignettes = TRUE)
browseVignettes("BayesSurvive")

@zhizuio
Copy link
Collaborator

zhizuio commented Aug 15, 2024

Hi George,

I can reproduce the error and your solution. Keeping track of built files (i.e., anything under /inst/doc) is not ideal, though.

What's the use of that build folder anyway? I tried deleting it and the package still installs with vignettes, you can also try it from the fix-vignettes branch:

remotes::install_github("ocbe-uio/BayesSurvive@fix-vignettes", build_vignettes = TRUE)
browseVignettes("BayesSurvive")

This solution works. Do you know if we can set up something, so that the usual installation still works?

wleoncio added a commit that referenced this issue Aug 15, 2024
wleoncio added a commit that referenced this issue Aug 16, 2024
wleoncio added a commit that referenced this issue Aug 16, 2024
Since this case call all remaining functions to be translated, it should suffice for testing the rest of #11. Tests will still need to be readapted once R code is removed.
wleoncio added a commit that referenced this issue Aug 19, 2024
wleoncio added a commit that referenced this issue Sep 16, 2024
wleoncio added a commit that referenced this issue Sep 16, 2024
wleoncio added a commit that referenced this issue Sep 17, 2024
wleoncio added a commit that referenced this issue Sep 17, 2024
wleoncio added a commit that referenced this issue Sep 17, 2024
wleoncio added a commit that referenced this issue Sep 17, 2024
wleoncio added a commit that referenced this issue Sep 17, 2024
wleoncio added a commit that referenced this issue Sep 17, 2024
wleoncio added a commit that referenced this issue Sep 17, 2024
wleoncio added a commit that referenced this issue Sep 17, 2024
wleoncio added a commit that referenced this issue Sep 17, 2024
wleoncio added a commit that referenced this issue Sep 17, 2024
@zhizuio
Copy link
Collaborator

zhizuio commented Sep 18, 2024

Thank you very much, Waldir, for updating and testing the package! If I remember correctly, the argument MRF_2b = TRUE is only valid when model.type ="Sub-struct". Then only the following 8 tests are needed, right?

Test number model.type MRF_G MRF_2b
1 Pooled FALSE FALSE
2 Pooled TRUE FALSE
3 CoxBVSSL FALSE FALSE
4 CoxBVSSL TRUE FALSE
5 Sub-struct FALSE FALSE
6 Sub-struct FALSE TRUE
7 Sub-struct TRUE FALSE
8 Sub-struct TRUE TRUE

It might be also helpful to add the following table in the help file or README.

Model Fix MRF_G Infer MRF_G
Pooled
CoxBVSSL
Sub-struct

@wleoncio
Copy link
Member Author

Thanks for checking, will edit accordingly! :)

@wleoncio
Copy link
Member Author

Question: when we have a situation like below (triggered when method != "Pooled" or !MRF_G), is it safe to assume that these objects are the same size across the $g = \{1, \ldots, S\}$ subgroups? For example, sobj$X[[g]] has the same dimensions for all values of g on that loop?

x <- sobj$X[[g]]
J <- hyperpar$J[[g]]
ind.r <- hyperpar$ind.r[[g]]
ind.d <- hyperpar$ind.d[[g]]
ind.r_d <- hyperpar$ind.r_d[[g]]
be.ini <- ini$beta.ini[[g]]
be.prop.sd.scale <- hyperpar$be.prop.sd.scale[[g]]
ga.ini <- ini$gamma.ini[[g]]
h <- ini$h[[g]]

@zhizuio
Copy link
Collaborator

zhizuio commented Oct 22, 2024

Question: when we have a situation like below (triggered when method != "Pooled" or !MRF_G), is it safe to assume that these objects are the same size across the g = { 1 , … , S } subgroups? For example, sobj$X[[g]] has the same dimensions for all values of g on that loop?

x <- sobj$X[[g]]
J <- hyperpar$J[[g]]
ind.r <- hyperpar$ind.r[[g]]
ind.d <- hyperpar$ind.d[[g]]
ind.r_d <- hyperpar$ind.r_d[[g]]
be.ini <- ini$beta.ini[[g]]
be.prop.sd.scale <- hyperpar$be.prop.sd.scale[[g]]
ga.ini <- ini$gamma.ini[[g]]
h <- ini$h[[g]]

Yes, the same dimension across subgroups should be required according to the model setting.

@wleoncio
Copy link
Member Author

Great news, thanks! Then I can just implement those as cubes on C++... :)

wleoncio added a commit that referenced this issue Oct 23, 2024
Allows accommodation to `S > 1`.
wleoncio added a commit that referenced this issue Oct 23, 2024
wleoncio added a commit that referenced this issue Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants