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

Issue #374: Add test of input mu ~ 1 as formula #396

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
15 changes: 15 additions & 0 deletions tests/testthat/test-formula.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ test_that("epidist_formula with custom formulas produces a brmsformula with corr
)
})

test_that("epidist_formula with input as a formula (not using brms::bf) produces a brmsformula", { # nolint: line_length_linter.
form <- epidist_formula(
prep_obs, family = family_lognormal, formula = mu ~ 1
)
expect_s3_class(form, "brmsformula")
expect_equal(
as_string_formula(form$formula),
"delay | vreal(relative_obs_time, pwindow, swindow) ~ 1"
)
expect_equal(
as_string_formula(form$pforms$sigma),
"sigma ~ 1"
)
})

test_that("epidist_formula with custom formulas errors for incorrect custom formulas", { # nolint: line_length_linter.
expect_error(
epidist_formula(
Expand Down
10 changes: 5 additions & 5 deletions vignettes/faq.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fit <- epidist(
## I would like to work with the samples output

The output of a call to `epidist` is compatible with typical Stan workflows.
We recommend use of the `posterior` package for working with samples from MCMC or other sampling algorithms.
We recommend use of the [`posterior`](https://mc-stan.org/posterior/) package for working with samples from MCMC or other sampling algorithms.
For example, the function `posterior::as_draws_df()` may be used to obtain a dataframe of MCMC draws for specified parameters.

```{r message = FALSE}
Expand All @@ -69,7 +69,7 @@ head(draws)
## How can I assess if sampling has converged?

The output of a call to `epidist` is compatible with typical Stan workflows.
We recommend use of the `bayesplot` package for sampling diagnostic plots.
We recommend use of the [`bayesplot`](http://mc-stan.org/bayesplot/) package for sampling diagnostic plots.
For example, the function `bayesplot::mcmc_trace()` can be used to produce traceplots for specified parameters.

```{r message = FALSE}
Expand All @@ -85,7 +85,7 @@ epidist_diagnostics(fit)

## I'd like to run a simulation study

We recommend use of the `purrr` package for running many `epidist` models, for example as a part of a simulation study.
We recommend use of the [`purrr`](https://purrr.tidyverse.org/) package for running many `epidist` models, for example as a part of a simulation study.
We particularly highlight two functions which might be useful:

1. `purrr::map()` (and other similar functions) for iterating over a list of inputs.
Expand All @@ -96,7 +96,7 @@ For an example use of these functions, have a look at the [`epidist-paper`](http

## How did you choose the default priors for `epidist`?

`brms` provides default priors for all parameters.
[`brms`](http://paulbuerkner.com/brms/) provides default priors for all parameters.
However, some of those priors do not make sense in the context of our application.
Instead, we used [prior predictive checking](https://mc-stan.org/docs/stan-users-guide/posterior-predictive-checks.html) to set `epidist`-specific default priors which produce epidemiological delay distribution mean and standard deviation parameters in a reasonable range.

Expand Down Expand Up @@ -170,7 +170,7 @@ powerscale_plot_dens(fit, variable = c("Intercept", "Intercept_sigma")) +

# What do the parameters in my model output correspond to?

The `epidist` package uses `brms` to fit models.
The `epidist` package uses [`brms`](http://paulbuerkner.com/brms/) to fit models.
This means that the model output will include `brms`-style names for parameters.
Here, we provide a table giving the correspondence between the distributional parameter names used in `brms` and those used in standard R functions for some common likelihood families.

Expand Down
Loading