sim.detect.stat: Simulation using Statistic-based Stopping Rule

Description Usage Arguments Value Examples

View source: R/stat.R

Description

Simulation experiment of change-point detection with known post-change distributions using the statistic-based stopping rule.

Usage

1
2
sim.detect.stat(GEN0, GEN1, detect.stat, nulower = NULL,
  nuupper = NULL, ...)

Arguments

GEN0, GEN1

Functions that take no argument and return an observation from the pre-change (GEN0) and post-change (GEN1) models.

detect.stat

A function that implements the statistic-based stopping rule: detect.stat for continuous data or detect.bin.stat for binary data.

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.

...

Additional arguments to be passed to detect.stat.

Value

A named numeric vector with components

  1. is.FA A numeric of 1 or 0 indicating whether a false alarm has been raised.

  2. DD A positive numeric: The delay to detection.

  3. CT A positive numeric: The computation 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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
##Change from N(0,1) to N(1,1) occurs between 10 and 25.

GEN0=function() rnorm(1)
GEN1=function() 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
sim.detect.stat(GEN0=GEN0,GEN1=GEN1,detect.stat=detect.stat,nulower=10,nuupper=25,
alpha=0.1,GLP0=GLP0,LLP0=LLP0,GLP1=GLP1,LLP1=LLP1)

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

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


###################################

##Change from 3 iid Bernoulli(0.2) to 3 iid Bernoulli(0.8) occurs before 20.

GEN0=function() rbinom(3,1,0.2)
GEN1=function() 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
sim.detect.stat(GEN0=GEN0,GEN1=GEN1,detect.stat=detect.bin.stat,nuupper=20,
alpha=0.1,ULP0=ULP0,ULP1=ULP1)

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

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

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