poisson_rare: Poisson for Rare Events

Description Usage Arguments Details Value Methods (by class) Examples

Description

Test on rare events using an exact test on the Poisson distribution rate parameter (stats::poisson.test()).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
poisson_rare(df, ...)

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

## Default S3 method:
poisson_rare(
  df,
  analysis_of = NA,
  eval_period = NULL,
  zero_rate = 2/3,
  p_rate = 0.2,
  p_crit = 0.05,
  ...
)

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 poisson_rare methods

ts_event

Required if df is of class mds_ts. Named string indicating the variable corresponding to the event count or rate. Rate must be calculated in a separate column in df as it is not calculated by default. The name of the string is an English description of what was analyzed.

Default: c("Count"="nA") corresponding to the event count column in mds_ts objects. Name is generated from mds_ts metadata.

Example: c("Rate of Bone Filler Events in Canada"="rate")

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: "Rate of bone cement leakage"

eval_period

Optional positive integer indicating the number of unique times counting in reverse chronological order to assess.

Default: NULL considers all times in df.

zero_rate

Required minimum proportion of events in df (constrained by eval_period) containing zeroes for this algorithm to run.

Default: 2/3 requires a minimum of 2/3 zeros in events in df.

p_rate

Hypothesized Poisson rate parameter null value at which the Poisson test is performed (null vs. greater). See details for more.

Default: 0.2

p_crit

Critical p-value for the Poisson test..

Default: 0.05

Details

p_rate default of 0.2 is a suggested null value for the Poisson rate parameter. However this value is highly advised to be set based on known priors and/or your specific application.

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

Examples

1
2
3
4
5
6
7
8
9
# Basic Example
data <- data.frame(time=c(1:8), event=c(rep(0, 6), stats::rpois(2, 4)))
a1 <- poisson_rare(data)
# Example using an mds_ts object
a2 <- poisson_rare(mds_ts[[1]])
# Example using a derived rate as the "event"
data <- mds_ts[[1]]
data$rate <- ifelse(is.na(data$nA), 0, data$nA) / data$exposure
a3 <- poisson_rare(data, c("Rate"="rate"))

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