Description Usage Arguments Details Value Methods (by class) References Examples
Test on deviceevents using the meanshift changepoint method originally described in Xu, et al 2015.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19  cp_mean(df, ...)
## S3 method for class 'mds_ts'
cp_mean(df, ts_event = c(Count = "nA"), analysis_of = NA, ...)
## Default S3 method:
cp_mean(
df,
analysis_of = NA,
eval_period = NULL,
alpha = 0.05,
cp_max = 100,
min_seglen = 6,
epochs = NULL,
bootstrap_iter = 1000,
replace = T,
zero_rate = 1/3,
...
)

df 
Required input data frame of class

... 
Further arguments passed onto 
ts_event 
Required if Default: Example: 
analysis_of 
Optional string indicating the English description of what
was analyzed. If specified, this will override the name of the
Default: Example: 
eval_period 
Optional positive integer indicating the number of unique times counting in reverse chronological order to assess. This will be used to establish the process mean and moving range. Default: 
alpha 
Alpha or TypeI error rate for detection of a changepoint, in the range (0, 1). Default: 
cp_max 
Maximum number of changepoints detectable. This supersedes the
theoretical max set by Default: 
min_seglen 
Minimum required length of consecutive measurements without a changepoint in order to test for an additional changepoint within. Default: 
epochs 
Maximum number of epochs allowed in the iterative search for
changepoints, where Default: 
bootstrap_iter 
Number of bootstrap iterations for constructing the null distribution of means. Lowest recommended is 1000. Increasing iterations also increases pvalue precision. Default: 
replace 
When sampling for the bootstrap, perform sampling with or
without replacement. Unless your Default: 
zero_rate 
Required maximum proportion of Default: 
Function cp_mean()
is an implementation of the meanshift changepoint
method originally proposed by Xu, et al (2015) based on testing the
meancentered absolute cumulative sum against a bootstrap null
distribution. This algorithm defines a signal as any changepoint found within
the last/most recent n=min_seglen
measurements of df
.
The parameters in this implementation can be interpreted as
follows. Changepoints are detected at an alpha
level based on
n=bootstrap_iter
bootstrap iterations (with or without replacement
using replace
) of the input time series
df
. A minimum of n=min_seglen
consecutive measurements without
a changepoint are required to test for an additional changepoint. Both
epochs
and cp_max
constrain the maximum possible number of
changepoints detectable as follows: within each epoch, each segment of
consecutive measurements at least n=min_seglen
measurements long are
tested for a changepoint, until no additional changepoints are found.
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 95
confidence bounds, p
for the pvalue, signal
status, and
signal_threshold
.
The test parameters
The data on which the test was run
mds_ts
: Meanshift changepoint on mds_ts data
default
: Meanshift changepoint on general data
Xu, Zhiheng, et al. "Signal detection using change point analysis in postmarket surveillance." Pharmacoepidemiology and Drug Safety 24.6 (2015): 663668.
1 2 3 4 5 6 7 8 9  # Basic Example
data < data.frame(time=c(1:25), event=as.integer(stats::rnorm(25, 100, 25)))
a1 < cp_mean(data)
# Example using an mds_ts object
a2 < cp_mean(mds_ts[[3]])
# Example using a derived rate as the "event"
data < mds_ts[[3]]
data$rate < ifelse(is.na(data$nA), 0, data$nA) / data$exposure
a3 < cp_mean(data, c(Rate="rate"))

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.