sprt: Sequential Probability Ratio Test

Description Usage Arguments Details Value Methods (by class) References Examples

Description

Test on device-events using Wald's Sequential Probability Ratio Test (SPRT). Supports both Poisson (default) and normal distribution functions.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
sprt(df, ...)

## S3 method for class 'mds_ts'
sprt(df, ts_event = c(Count = "nA"), analysis_of = NA, ...)

## Default S3 method:
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",
  ...
)

Arguments

df

Required input data frame of class mds_ts or, for generic usage, any data frame with the following columns:

time

Unique times of class Date

event

Either the event count or rate of class numeric

...

Further arguments passed onto sprt methods

ts_event

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.

analysis_of

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"

eval_period

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.

obs_period

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.

h0

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.

h1

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.

relative_risk

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.

distribution

Required distribution to estimate. Must be either "poisson" or "normal".

Default: "poisson"

alpha

Required Type I error probability between 0 and 1.

Default: 0.05

beta

Required Type II error probability between 0 and 1.

Default: 0.20

h1_type

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"

Details

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")

Value

A named list of class mdsstat_test object, as follows:

test_name

Name of the test run

analysis_of

English description of what was analyzed

status

Named boolean of whether the test was run. The name contains the run status.

result

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.

params

The test parameters

data

The data on which the test was run

Methods (by class)

References

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

Examples

1
2
3
4
5
6
7
# 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)

mdsstat documentation built on March 13, 2020, 2:58 a.m.