open-AIMS / bayesnec

Bayesian No-Effect-Concentration estimation in R

Home Page:https://open-AIMS.github.io/bayesnec

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

validate_priors code logic

beckyfisher opened this issue · comments

JSS editorial comment:
The code if (!model %in% names(priors)) {message("Named prior list does not contain ","priors for model ", model, ".\n","Using bayesnec default priors.")}priors <- priors[[model]]if (is.null(priors)) {stop("No valid prior specified.")} suggests that the message is misleading as in case model is not in the names subsetting with model will lead to priors being equal to NULL.

This first if statement checks if there is an element in the priors list with the appropriate model name.
if (!model %in% names(priors)) {
message("Named prior list does not contain ",
"priors for model ", model, ".\n",
"Using bayesnec default priors.")
}
If the model name does not appear a message will be returned indicating bayesnec will use the default priors.
The next block extracts the model priors, and tests that this is not null. As the editor points, out – if this returns null because priors does not contain an element named model, the earlier warning message should apply. It seems more appropriate for the code to check at this point if supplied priors are adequately specified, not that they are null.
priors <- priors[[model]]
if (is.null(priors)) {
stop("No valid prior specified.")
}