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

Hotfix/issue 80 sdm likelihood evaluation explodes for extremely high kappa #91

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
6 changes: 5 additions & 1 deletion R/bmm_model_sdmSimple.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,13 @@ configure_model.sdmSimple <- function(model, data, formula) {
# fix mu to 0 (when I change mu to be the center, not c)
brms::prior_("constant(0)", class = "Intercept", dpar = "mu")

# set initial values to be sampled between [-1,1] to avoid extreme SDs that
# can cause the sampler to fail // TODO: test extensively if this works in
# all cases
init = 1

# return the list
out <- nlist(formula, data, family, prior, stanvars)
out <- nlist(formula, data, family, prior, stanvars, init)
return(out)
}

Expand Down
3 changes: 1 addition & 2 deletions R/fit_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,11 @@ fit_model <- function(formula, data, model, parallel = FALSE, chains = 4, prior

# estimate the model
dots <- list(...)
fit_args <- c(config_args, opts, dots)
fit_args <- combine_args(nlist(config_args, opts, dots))
fit <- call_brm(fit_args)

# model postprocessing
fit <- postprocess_brm(model, fit)

return(fit)
}

20 changes: 20 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,23 @@ call_brm <- function(fit_args) {
}
return(fit)
}


# function to ensure that if the user wants to overwrite an argument (such as
# init), they can
combine_args <- function(args) {
config_args <- args$config_args
opts <- args$opts
dots <- args$dots
if (is.null(dots)) {
return(c(config_args, opts))
}
for (i in names(dots)) {
if (not_in(i, c('family'))) {
config_args[[i]] <- dots[[i]]
} else {
stop('You cannot provide a family argument to fit_model. Please use the model argument instead.')
}
}
c(config_args, opts)
}
4,889 changes: 4,889 additions & 0 deletions dev_utils/stan_data_structure.html

Large diffs are not rendered by default.

Loading