-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
functions estRodis_init_params_model_one and estRodis_init_params_model_two added, models renamed and some bugs fixed
- Loading branch information
1 parent
34e87aa
commit 7852409
Showing
31 changed files
with
616 additions
and
479 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
#' @title Initial values for Model 1 | ||
#' | ||
#' @description Sample from prior distributions of R, k, the number of yearly mutations and the testing probability. | ||
#' | ||
#' @param prior_r Parameters for prior distribution of R (gamma) | ||
#' @param prior_k Parameters for prior distribution of k (gamma) | ||
#' @param prior_number_yearly_mutations Parameters for prior distribution of the number of yearly mutations (normal) | ||
#' @param prior_testing Parameters for prior distribution of testing probability (scaled beta) | ||
#' | ||
#' @return A named list containing samples of the prior distributions of R, k, the number of yearly mutations and the testing probability. | ||
#' | ||
#' @export | ||
#' | ||
#' @examples | ||
#' estRodis_init_params_model_one() | ||
|
||
estRodis_init_params_model_one <- function(prior_r = c(10, 10), prior_k = c(5, 10), prior_number_yearly_mutations = c(14, 0.5), prior_testing = c(1, 3, 0.05, 1)) { | ||
|
||
distribution <- unlist(lapply(X = seq(prior_testing[3], prior_testing[4], 0.00001), | ||
FUN = function(x) estRodis_scaled_beta_distribution_pdf(prior_testing[1], prior_testing[2], prior_testing[3], prior_testing[4], x))) | ||
|
||
# initial value for R sampled from gamma distribution(prior_r[1], prior_r[2]) | ||
# initial value for k sampled from gamma distribution(prior_k[1], prior_k[2]) | ||
# initial value for number_yearly_mutations sampled from normal distribution(prior_number_yearly_mutations[1], prior_number_yearly_mutations[2]) | ||
# initial value for testing_proba sampled from scaled beta distribution(prior_testing[1], prior_testing[2]) on the interval (prior_testing[3], prior_testing[4]) | ||
result <- list(R = stats::rgamma(1, prior_r[1], prior_r[2]), | ||
k = stats::rgamma(1, prior_k[1], prior_k[2]), | ||
number_yearly_mutations = stats::rnorm(1, prior_number_yearly_mutations[1], prior_number_yearly_mutations[2]), | ||
testing_proba = sample(seq(prior_testing[3], prior_testing[4], 0.00001), 1, replace = TRUE, prob = distribution)) | ||
|
||
return(result) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
#' @title Initial values for Model 2 | ||
#' | ||
#' @description Sample from prior distributions of R, k, the number of yearly mutations and the testing probability. | ||
#' | ||
#' @param prior_r Parameters for prior distribution of R (gamma) | ||
#' @param prior_k Parameters for prior distribution of k (gamma) | ||
#' @param prior_number_yearly_mutations Parameters for prior distribution of the number of yearly mutations (normal) | ||
#' | ||
#' @return A named list containing samples of the prior distributions of R, k and the number of yearly mutations. | ||
#' | ||
#' @export | ||
#' | ||
#' @examples | ||
#' estRodis_init_params_model_two() | ||
|
||
estRodis_init_params_model_two <- function(prior_r = c(10, 10), prior_k = c(5, 10), prior_number_yearly_mutations = c(14, 0.5)) { | ||
|
||
# initial value for R sampled from gamma distribution(prior_r[1], prior_r[2]) | ||
# initial value for k sampled from gamma distribution(prior_k[1], prior_k[2]) | ||
# initial value for number_yearly_mutations sampled from normal distribution(prior_number_yearly_mutations[1], prior_number_yearly_mutations[2]) | ||
result <- list(R = stats::rgamma(1, prior_r[1], prior_r[2]), | ||
k = stats::rgamma(1, prior_k[1], prior_k[2]), | ||
number_yearly_mutations = stats::rnorm(1, prior_number_yearly_mutations[1], prior_number_yearly_mutations[2])) | ||
|
||
return(result) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.