-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move to marginal model name and lint
- Loading branch information
Showing
5 changed files
with
61 additions
and
52 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters