Skip to content

Commit

Permalink
Move to marginal model name and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
athowes committed Nov 18, 2024
1 parent c194e1d commit afdbf08
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 52 deletions.
50 changes: 0 additions & 50 deletions R/cohort_model.R

This file was deleted.

55 changes: 55 additions & 0 deletions R/marginal_model.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#' Prepare marginal model to pass through to `brms`
#'
#' @param data A `data.frame` containing line list data
#' @family marginal_model
#' @export
as_epidist_marginal_model <- function(data) {
UseMethod("as_epidist_marginal_model")
}

#' The marginal model method for `epidist_linelist_data` objects
#'
#' @param data An `epidist_linelist_data` object
#' @method as_epidist_marginal_model epidist_linelist_data
#' @family marginal_model
#' @autoglobal
#' @export
as_epidist_marginal_model.epidist_linelist_data <- function(data) {
assert_epidist(data)

data <- data |>
mutate(delay = .data$stime_lwr - .data$ptime_lwr)

data <- new_epidist_marginal_model(data)
assert_epidist(data)
return(data)
}

#' Class constructor for `epidist_marginal_model` objects
#'
#' @param data A data.frame to convert
#' @returns An object of class `epidist_marginal_model`
#' @family marginal_model
#' @export
new_epidist_marginal_model <- function(data) {
class(data) <- c("epidist_marginal_model", class(data))
return(data)
}

#' @method assert_epidist epidist_marginal_model
#' @family marginal_model
#' @export
assert_epidist.epidist_marginal_model <- function(data, ...) {
assert_data_frame(data)
assert_names(names(data), must.include = "delay")
assert_numeric(data$delay, lower = 0)
}

#' Check if data has the `epidist_marginal_model` class
#'
#' @param data A `data.frame` containing line list data
#' @family marginal_model
#' @export
is_epidist_marginal_model <- function(data) {
inherits(data, "epidist_marginal_model")
}
4 changes: 4 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ reference:
desc: Functions for fitting delay distribution models using `brms`
contents:
- has_concept("fit")
- title: Marginal model
desc: Specific methods for the marginal model
contents:
- has_concept("marginal_model")
- title: Latent model
desc: Specific methods for the latent model
contents:
Expand Down
2 changes: 1 addition & 1 deletion vignettes/approx-inference.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ library(purrr)
library(tidyr)
library(tibble)
library(tidybayes)
library(cmdstanr)
library(cmdstanr) # nolint
```

To access the approximate inference methods used in this vignette we will need to use the `cmdstanr` backend for `brms` (we generally recommend using this backend for fitting models). To do this, we first need to install CmdStan (see the README for more details). We can check we have everything we need as follows:
Expand Down
2 changes: 1 addition & 1 deletion vignettes/ebola.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ library(tidybayes)
library(modelr)
library(patchwork)
library(lubridate)
library(cmdstanr)
library(cmdstanr) # nolint
```

For users new to `epidist`, before reading this article we recommend beginning with the "[Getting started with `epidist`](http://epidist.epinowcast.org/articles/epidist.html)" vignette.
Expand Down

0 comments on commit afdbf08

Please sign in to comment.