detect.stat: Statistic-based Stopping Rule for Continuous Data

Description Usage Arguments Value Examples

View source: R/stat.R

Description

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

Usage

1
2
3
4
5
detect.stat(GEN, alpha, nulower = NULL, nuupper = NULL,
  score = "hyvarinen", ULP0 = NULL, GLP0 = NULL, LLP0 = NULL,
  ULP1 = NULL, GLP1 = NULL, LLP1 = NULL, par0 = NULL,
  par1 = NULL, lenx = NULL, lower0 = NULL, upper0 = NULL,
  lower1 = NULL, upper1 = NULL)

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, GLP0, LLP0, ULP1, GLP1, LLP1

Functions of an observation: The log unnormalized probability function, its gradient and its laplacian for the pre-change (ULP0,GLP0,LLP0) and post-change (ULP1,GLP1,LLP1) models. If score="hyvarinen", either {GLP0,LLP0,GLP1,LLP1} or {ULP0,ULP1} is required. The former is recommended. In the latter case, {GLP0,LLP0,GLP1,LLP1} will be computed via grad and laplacian. If score="logarithmic", only {ULP0,ULP1} is required.

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 via integrate (if lenx=1) or hcubature (if lenx>1).

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.

lower0, upper0, lower1, upper1

Optional numeric vectors of length lenx: The lower and upper limits of an observation from the pre-change (lower0,upper0) and post-change (lower1,upper1) models. The defaults are infinite.

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
19
20
21
22
23
##Change from N(0,1) to N(1,1) at t=15.
##Prior knowledge suggests change occurs between 10 and 25.

GEN=function(t) { if(15>=t) rnorm(1) else rnorm(1)+1 }
ULP0=function(x) -x^2/2
ULP1=function(x) -(x-1)^2/2
GLP0=function(x) -x
GLP1=function(x) -(x-1)
LLP0=function(x) -1
LLP1=function(x) -1
par0=log(2*pi)/2;par1=par0

#using hyvarinen score
detect.stat(GEN=GEN,alpha=0.1,nulower=10,nuupper=25,
GLP0=GLP0,LLP0=LLP0,GLP1=GLP1,LLP1=LLP1)

#using log score. normalizing constant is unknown
detect.stat(GEN=GEN,alpha=0.1,nulower=10,nuupper=25,
score="log",ULP0=ULP0,ULP1=ULP1,lenx=1)

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

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