-
Notifications
You must be signed in to change notification settings - Fork 8
two sets of shape hyperparameters for the Beta hyperprior in the SBM #68
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
Changes from 5 commits
c8af72d
727f8cd
bf3ec25
8182afd
a462165
dc4de41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -210,6 +210,13 @@ | |
| #' priors. Must be positive. Defaults: \code{beta_bernoulli_alpha = 1} and | ||
| #' \code{beta_bernoulli_beta = 1}. | ||
| #' | ||
| #' @param beta_bernoulli_alpha_between,beta_bernoulli_beta_between Double. | ||
| #' Second set of shape parameters for the Stochastic-Block prior. Default: \code{NULL}. | ||
| #' If the users supply values for these parameters, the model will use different | ||
| #' between-cluster and within-cluster edge inclusion probabilities. In this case | ||
| #' the beta_bernoulli_alpha and beta_bernoulli_beta will be used as the within-cluster | ||
| #' parameters. | ||
| #' | ||
| #' @param dirichlet_alpha Double. Concentration parameter of the Dirichlet | ||
| #' prior on block assignments (used with the Stochastic Block model). | ||
| #' Default: \code{1}. | ||
|
|
@@ -239,7 +246,7 @@ | |
| #' @param target_accept Numeric between 0 and 1. Target acceptance rate for | ||
| #' the sampler. Defaults are set automatically if not supplied: | ||
| #' \code{0.44} for adaptive Metropolis, \code{0.65} for HMC, | ||
| #' and \code{0.80} for NUTS. | ||
| #' and \code{0.60} for NUTS. | ||
| #' | ||
| #' @param hmc_num_leapfrogs Integer. Number of leapfrog steps for Hamiltonian | ||
| #' Monte Carlo. Must be positive. Default: \code{100}. | ||
|
|
@@ -359,6 +366,8 @@ bgm = function( | |
| inclusion_probability = 0.5, | ||
| beta_bernoulli_alpha = 1, | ||
| beta_bernoulli_beta = 1, | ||
| beta_bernoulli_alpha_between = NULL, | ||
| beta_bernoulli_beta_between = NULL, | ||
| dirichlet_alpha = 1, | ||
| lambda = 1, | ||
| na_action = c("listwise", "impute"), | ||
|
|
@@ -418,7 +427,7 @@ bgm = function( | |
| } else if(update_method == "hamiltonian-mc") { | ||
| target_accept = 0.65 | ||
| } else if(update_method == "nuts") { | ||
| target_accept = 0.80 | ||
| target_accept = 0.60 | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -444,9 +453,21 @@ bgm = function( | |
| inclusion_probability = inclusion_probability, | ||
| beta_bernoulli_alpha = beta_bernoulli_alpha, | ||
| beta_bernoulli_beta = beta_bernoulli_beta, | ||
| beta_bernoulli_alpha_between = beta_bernoulli_alpha_between, | ||
| beta_bernoulli_beta_between = beta_bernoulli_beta_between, | ||
| dirichlet_alpha = dirichlet_alpha, | ||
| lambda = lambda) | ||
|
|
||
| # check hyperparameters input | ||
| # If user left them NULL, pass -1 to C++ (means: ignore between prior) | ||
sekulovskin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (is.null(beta_bernoulli_alpha_between) && is.null(beta_bernoulli_beta_between)) { | ||
| beta_bernoulli_alpha_between <- -1.0 | ||
| beta_bernoulli_beta_between <- -1.0 | ||
| } else if (is.null(beta_bernoulli_alpha_between) || is.null(beta_bernoulli_beta_between)) { | ||
| stop("If you wish to specify different between and within cluster probabilites, | ||
| provide both beta_bernoulli_alpha_between and beta_bernoulli_beta_between, | ||
| otherwise leave both NULL.") | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I read this correctly, this will stop the analysis if the between parameters are left at their defaults. This means users cannot use bgms, except when they set other values for these defaults, irrespective if they use an SBM prior or not.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, this is in case the user specifies only one of the between parameters, but not both. Otherwise running the code below did work. But it doesn't matter now, since as you requested, both sets of hyperparameters are always provided. fit <- bgm(Wenchuan[c(1:100), c(1:5)], edge_prior = "Stochastic-Block", |
||
| # ---------------------------------------------------------------------------- | ||
| # The vector variable_type is now coded as boolean. | ||
| # Ordinal (variable_bool == TRUE) or Blume-Capel (variable_bool == FALSE) | ||
|
|
@@ -572,6 +593,8 @@ bgm = function( | |
| inclusion_probability = inclusion_probability, | ||
| beta_bernoulli_alpha = beta_bernoulli_alpha, | ||
| beta_bernoulli_beta = beta_bernoulli_beta, | ||
| beta_bernoulli_alpha_between = beta_bernoulli_alpha_between, | ||
| beta_bernoulli_beta_between = beta_bernoulli_beta_between, | ||
| dirichlet_alpha = dirichlet_alpha, lambda = lambda, | ||
| interaction_index_matrix = interaction_index_matrix, iter = iter, | ||
| warmup = warmup, counts_per_category = counts_per_category, | ||
|
|
@@ -603,6 +626,7 @@ bgm = function( | |
| na_action = na_action, na_impute = na_impute, | ||
| edge_selection = edge_selection, edge_prior = edge_prior, inclusion_probability = inclusion_probability, | ||
| beta_bernoulli_alpha = beta_bernoulli_alpha, beta_bernoulli_beta = beta_bernoulli_beta, | ||
| beta_bernoulli_alpha_between = beta_bernoulli_alpha_between, beta_bernoulli_beta_between = beta_bernoulli_beta_between, | ||
| dirichlet_alpha = dirichlet_alpha, lambda = lambda, | ||
| variable_type = variable_type, | ||
| update_method = update_method, | ||
|
|
@@ -634,6 +658,8 @@ bgm = function( | |
| edge_selection = edge_selection, edge_prior = edge_prior, inclusion_probability = inclusion_probability, | ||
| beta_bernoulli_alpha = beta_bernoulli_alpha, | ||
| beta_bernoulli_beta = beta_bernoulli_beta, | ||
| beta_bernoulli_alpha_between = beta_bernoulli_alpha_between, | ||
| beta_bernoulli_beta_between = beta_bernoulli_beta_between, | ||
| dirichlet_alpha = dirichlet_alpha, lambda = lambda, | ||
| variable_type = variable_type, | ||
| update_method = update_method, | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.