import greenwood as gw
x = gw.event_time(
time=[7, 5, 3, 2, None],
status=["e", "r", "l", "i", None],
time_max=[None, None, None, 4, None],
)
x<event_time[5]>
7 5+ 3- [2, 4] <NA>
Create a vector of event times.
Usage
event_time() creates a vector of event times that may be exact, or right-, left-, or interval-censored. It validates its input and raises an error describing the first problem found.
time: AnyNon-negative event times (numbers or booleans, with None or nan for missing values). For interval-censored values, this is the lower end of the interval. Accepts a list, a NumPy array, or a DataFrame series. A single number is treated as a vector of length 1.
status: AnyStatus codes, the same length as time: "e" (exact event), "r" (right-censored), "l" (left-censored), or "i" (interval-censored). It can be missing (None) only where time is missing. Codes are case-sensitive, and categorical input is rejected.
time_max: Any = Nonetime. Must be missing for values that are not interval-censored, and greater than time otherwise. The default None sets all values to missing.
EventTime TypeErrorIf time or time_max isn’t numeric, or status isn’t a character vector.
ValueErrorErrors carry two extra attributes: check, a stable identifier for the rule that failed (such as "status_invalid_value"), and locations, a 0-based integer array of the offending positions (empty when the rule isn’t about particular positions). Only the first failing rule is reported, but with every location that breaks it.
import greenwood as gw
x = gw.event_time(
time=[7, 5, 3, 2, None],
status=["e", "r", "l", "i", None],
time_max=[None, None, None, 4, None],
)
x<event_time[5]>
7 5+ 3- [2, 4] <NA>
To start from a data frame, name the columns in a formula (or with Outcome.event_time()) and pass data= to fit(), which works on every DataFrame backend: