Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
seabbs committed Nov 28, 2024
1 parent c425116 commit 8711ddc
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
8 changes: 5 additions & 3 deletions R/epidist.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
#' reexported as part of `epidist`.
#' @param prior One or more `brmsprior` objects created by [brms::set_prior()]
#' or related functions. These priors are passed to [epidist_prior()] in the
#' `prior` argument.
#' @param merge_priors If `TRUE` then merge new priors with existing ones, if
#' `FALSE` only use new priors. Defaults to `TRUE`. This may be useful if
#' `prior` argument. Some models have default priors that are automatically
#' added (see [epidist_model_prior()]). These can be merged with user-provided
#' priors using the `merge_priors` argument.
#' @param merge_priors If `TRUE` then merge user priors with default priors, if
#' `FALSE` only use user priors. Defaults to `TRUE`. This may be useful if
#' the built in approaches for merging priors are not flexible enough for a
#' particular use case.
#' @param fn The internal function to be called. By default this is
Expand Down
9 changes: 8 additions & 1 deletion R/family.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,14 @@ epidist_family_param.default <- function(family, ...) {
)
lpdf_match <- regexpr(lpdf_pattern, dummy_mdl)
reparam <- if (lpdf_match > 0) {
match_str <- regmatches(dummy_mdl, lpdf_match)[[1]]
matches <- unlist(regmatches(dummy_mdl, lpdf_match))
mu_matches <- matches[grepl("mu", matches, fixed = TRUE)]
if (length(mu_matches) > 1) {
cli_abort("Multiple Stan parameterisations found with 'mu' parameter.")
} else if (length(mu_matches) == 0) {
cli_abort("No Stan parameterisation found with 'mu' parameter.")
}
match_str <- mu_matches[1]
param <- sub(
paste0(
"target \\+= ", family_name, "_(lpdf|lpmf)\\(Y \\| " # nolint
Expand Down
2 changes: 1 addition & 1 deletion R/gen.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ epidist_gen_log_lik <- function(family) {
swindow <- prep$data$vreal3[i]

# make the prep object censored
# 1 here is equivalent to right censored in brms
# -1 here is equivalent to right censored in brms
prep$data$cens <- -1

# Calculate density for each draw using primarycensored::dpcens()
Expand Down
3 changes: 1 addition & 2 deletions R/latent_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ epidist_family_model.epidist_latent_model <- function(
#' @export
epidist_formula_model.epidist_latent_model <- function(
data, formula, ...) {
# Update main formula
formula <- stats::update(
formula, delay | vreal(relative_obs_time, pwindow, swindow) ~ .
)
Expand Down Expand Up @@ -193,7 +192,7 @@ epidist_stancode.epidist_latent_model <- function(
stanvar(
block = "data",
scode = "array[wN] int woverlap;",
x = as.integer(filter(data, woverlap > 0)$.row_id),
x = filter(data, woverlap > 0)$.row_id,
name = "woverlap"
)

Expand Down
8 changes: 5 additions & 3 deletions man/epidist.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/epidist_prior.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8711ddc

Please sign in to comment.