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

Document attribute "ratio" returned by counting_process() #311

Open
wants to merge 1 commit 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
19 changes: 11 additions & 8 deletions R/counting_process.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#'
#' @return
#' A data frame grouped by `stratum` and sorted within stratum by `tte`.
#' Remain rows with at least one event in the population, at least one subject
#' It only includes rows with at least one event in the population, at least one subject
#' is at risk in both treatment group and control group.
#' Other variables in this represent the following within each stratum at
#' each time at which one or more events are observed:
Expand All @@ -62,12 +62,15 @@
#' @export
#'
#' @details
#' The output produced by [counting_process()] produces a
#' counting process dataset grouped by stratum and sorted within stratum
#' by increasing times where events occur. The object is assigned the class
#' "counting_process". It also has the attributes "n_ctrl" and "n_exp",
#' which are the totals of the control and experimental treatments,
#' respectively, from the input time-to-event data.
#' The output produced by [counting_process()] produces a counting process
#' dataset grouped by stratum and sorted within stratum by increasing times
#' where events occur. The object is assigned the class "counting_process". It
#' also has the attribute "ratio", which is the ratio of the events in the
#' treatment arm compared to the control arm in the input time-to-event data. If
#' the input data was generated by [sim_pw_surv()], the ratio attribute is
#' simply obtained from the attribute of the same name from the input object.
#' Otherwise, the returned ratio is the empirical ratio of treatment to control
#' events.
#'
#' @examples
#' # Example 1
Expand Down Expand Up @@ -152,7 +155,7 @@ counting_process <- function(x, arm) {
if ("generate_by_simpwsurv" %in% names(attributes(x))) {
ratio <- attributes(x)$ratio
} else {
# if not, calcualte the emperical ratio
# if not, calculate the empirical ratio
ratio <- sum(x$treatment == arm) / sum(x$treatment != arm)
}
attr(ans, "ratio") <- ratio
Expand Down
17 changes: 10 additions & 7 deletions man/counting_process.Rd

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

Loading