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

burnin validation #19

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# BayesSurvive (development version)

# BayesSurvive 0.0.4

* Add units tests
* Rename the output of MPM coefficients in function `coef.BayesSurvive()`
* Added `cpp` argument to `BayesSurvive()` to allow for faster computation using `Rcpp`
* Added validation to some `BayesSurvive()` arguments

# BayesSurvive 0.0.3

Expand Down
3 changes: 3 additions & 0 deletions R/BayesSurvive.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ BayesSurvive <- function(survObj,
output_graph_para = FALSE,
verbose = TRUE,
cpp = FALSE) {
# Validation
stopifnot(burnin < nIter)

# same number of covariates p in all subgroups
p <- ifelse(is.list(survObj[[1]]), NCOL(survObj[[1]]$X), NCOL(survObj$X))
Beta.ini <- numeric(p)
Expand Down
25 changes: 25 additions & 0 deletions tests/testthat/test-validation.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Load the example dataset
dataset <- list(
"X" = simData[[1]]$X,
"t" = simData[[1]]$time,
"di" = simData[[1]]$status
)
# Run a Bayesian Cox model

## Initial value: null model without covariates
initial <- list("gamma.ini" = rep(0, ncol(dataset$X)))

# Prior parameters
hyperparPooled = list(
"c0" = 2, # prior of baseline hazard
"tau" = 0.0375, # sd (spike) for coefficient prior
"cb" = 20, # sd (slab) for coefficient prior
"pi.ga" = 0.02, # prior variable selection probability for standard Cox models
"a" = -4, # hyperparameter in MRF prior
"b" = 0.1, # hyperparameter in MRF prior
"G" = simData$G # hyperparameter in MRF prior
)

test_that("burnin must be less than nIter", {
expect_error(BayesSurvive(dataset, Iter = 30, burnin = 30))
})
Loading