Test on device-events using Wald's Sequential Probability Ratio Test (SPRT). Supports both Poisson (default) and normal distribution functions.
sprt(df, ...)# S3 method for mds_ts
sprt(df, ts_event = c(Count = "nA"), analysis_of = NA, ...)
# S3 method for default
sprt(
df,
analysis_of = NA,
eval_period = NULL,
obs_period = 1,
h0 = NULL,
h1 = NULL,
relative_risk = NULL,
distribution = "poisson",
alpha = 0.05,
beta = 0.2,
h1_type = "greater",
...
)
Required input data frame of class mds_ts
or, for generic
usage, any data frame with the following columns:
Unique times of class Date
Either the event count or rate of class numeric
Further arguments passed onto sprt
methods
Required if df
is of class mds_ts
. Named string
indicating the variable corresponding to the event count (cell A in the 2x2
contingency table). In most cases, the default is the appropriate setting.
See details for alternative options.
Default: c("Count"="nA")
corresponding to the event count column in
mds_ts
objects. Name is generated from mds_ts
metadata.
Optional string indicating the English description of what
was analyzed. If specified, this will override the name of the
ts_event
string parameter.
Default: NA
indicates no English description for plain df
data frames, or ts_event
English description for df
data frames
of class mds_ts
.
Example: "Count of bone cement leakages"
Optional positive integer indicating the number of unique
times counting in reverse chronological order to evaluate. This will be used
to establish the default null hypothesis h0
.
Default: NULL
considers all times in df
.
Required positive integer indicating the number of unique times
in reverse chronological order to observe and test against the null
hypothesis h0
. This cannot be greater than eval_period
. Used
with eval_period
to establish the default null hypothesis h0
.
Default: 1
indicates only the latest time in df
constitutes the
observation period.
Example: 3
indicates the last three times in df
constitute the
observation period.
Optional numeric value representing the null hypothesis. See details for more.
Default: NULL
estimates the null hypothesis from the evaluation period
eval_period
less the number of observation periods obs_period
.
Optional numeric value representing the test/alternative
hypothesis. Either h1
or relative_risk
must be specified. If
both are specified, relative_risk
takes priority. See details for more.
Default: NULL
assumes that relative_risk
is being used to infer
the alternative hypothesis.
Optional numeric value representing the relative risk used to
infer the test/alternative hypothesis as follows: h1=relative_risk * h0
.
Either h1
or relative_risk
must be specified. If both are
specified, relative_risk
takes priority. See details for more.
Default: NULL
assumes that h1
is defining the alternative
hypothesis.
Example: 1.2
tests if event occurrence is 1.2 times what is specified
by the null hypothesis h0
.
Required distribution to estimate. Must be either
"poisson"
or "normal"
.
Default: "poisson"
Required Type I error probability between 0 and 1.
Default: 0.05
Required Type II error probability between 0 and 1.
Default: 0.20
Required type of alternative hypothesis. Must be any of three
values: "greater"
, "less"
, or "not equal"
. For a
two-sided test, set to "not equal"
.
Default: "greater"
A named list of class mdsstat_test
object, as follows:
Name of the test run
English description of what was analyzed
Named boolean of whether the test was run. The name contains the run status.
A standardized list of test run results: statistic
for the test statistic, lcl
and ucl
for the set
confidence bounds, p
for the p-value, signal
status, and
signal_threshold
.
The test parameters
The data on which the test was run
mds_ts
: SPRT on mds_ts data
default
: SPRT on general data
Runs Wald's SPRT where the null hypothesis h0
and alternative
hypothesis h1
represent event occurrence in a single time period.
Event occurrence in Wald's context is the number of events in a time period.
However, at the user's discretion, this function allows event occurrence to
be any continuous number (such as event rate).
In typical medical device surveillance, h1
is greater than h0
or relative_risk
is greater than 1, and h1_type="greater"
. This is
because we wish to detect elevated occurrences of an undesirable event.
For parameter ts_event
, in the uncommon case where the
device-event count (Cell A) variable is not "nA"
, the name of the
variable may be specified here. A named character
vector may be used where the name is the English description of what was
analyzed. Note that if the parameter analysis_of
is specified, it will
override this name. Example: ts_event=c("Count of Bone Cement
Leakages"="event_count")
Wald, Abraham (June 1945). "Sequential Tests of Statistical Hypotheses". Annals of Mathematical Statistics. 16 (2): 117-186.
Martin Kulldorff, Robert L. Davis, Margarette Kolczak, Edwin Lewis, Tracy Lieu & Richard Platt (2011) A Maximized Sequential Probability Ratio Test for Drug and Vaccine Safety Surveillance, Sequential Analysis, 30:1, 58-78.
Stephane Mikael Bottine (2015). SPRT: Wald's Sequential Probability Ratio Test. R package version 1.0. https://CRAN.R-project.org/package=SPRT
# NOT RUN {
# At minimum, the df parameter and either the h1 or relative_risk parameter
# must be specified.
# Basic Example
data <- data.frame(time=c(1:25), event=as.integer(stats::rnorm(25, 100, 25)))
a1 <- sprt(data, h1=110)
# Example using an mds_ts object
a2 <- sprt(mds_ts[[3]], relative_risk=1.2)
# }
Run the code above in your browser using DataLab