detect.bin.stat: Statistic-based Stopping Rule for Binary Data

Description Usage Arguments Value Examples

View source: R/stat.R

Description

Change-point detection for binary data with known post-change distributions using the statistic-based stopping rule.

Usage

1
2
3
detect.bin.stat(GEN, alpha, nulower = NULL, nuupper = NULL,
  score = "hyvarinen", ULP0, ULP1, par0 = NULL, par1 = NULL,
  lenx = NULL, tbin = 1)

Arguments

GEN

A function of time that returns an observation.

alpha

A numeric parameter in (0,1) that controls the probability of false alarm.

nulower, nuupper

Optional nonnegative numerics: The earliest and latest time of change-point based on prior belief. The default is nulower=0 and nuupper=18 which corresponds to the geometric prior distribution with p=0.1.

score

An optional character specifying the type of score to be used: The default "hyvarinen" or the conventional "logarithmic". Can be abbreviated. Case insensitive.

ULP0, ULP1

Functions of an observation: The log unnormalized probability function for the pre-change (ULP0) and post-change (ULP1) models.

par0, par1

Optional numeric parameters for the pre-change (par0) and post-change (par1) models. If score="hyvarinen", the positive tuning parameter with a default of 1. If score="logarithmic", the negative log normalizing constant. If omitted, will be computed by summing over the sample space.

lenx

A positive numeric: The length of the variable of an obervation. Optional if score="hyvarinen" or if score="logarithmic" and par0,par1 are specified.

tbin

Optional numeric specifying the binary type: The default tbin=1 representing {1,0} or the alternative tbin=2 representing {1,-1}.

Value

A positive numeric: The stopping time.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
##Change from 3 iid Bernoulli(0.2) to 3 iid Bernoulli(0.8) at t=10.
##Prior knowledge suggests change occurs before 20.

GEN=function(t) { if(10>=t) rbinom(3,1,0.2) else rbinom(3,1,0.8)}
ULP0=function(x) sum(x)*(log(0.2)-log(1-0.2))
ULP1=function(x) sum(x)*(log(0.8)-log(1-0.8))
par0=-3*log(1-0.2)
par1=-3*log(1-0.8)

#using hyvarinen score
detect.bin.stat(GEN=GEN,alpha=0.1,nuupper=20,ULP0=ULP0,ULP1=ULP1)

#using log score. normalizing constant is unknown
detect.bin.stat(GEN=GEN,alpha=0.1,nuupper=20,score="log",ULP0=ULP0,ULP1=ULP1,lenx=3)

#using log score. normalizing constant is known
detect.bin.stat(GEN=GEN,alpha=0.1,nuupper=20,score="log",ULP0=ULP0,ULP1=ULP1,
par0=par0,par1=par1)

daining0905/chgdetn documentation built on May 25, 2019, 4:01 a.m.