sim.detect.bayes: Simulation using Bayesian Stopping Rule

Description Usage Arguments Value Examples

View source: R/bayes.R

Description

Simulation experiment of change-point detection with unknown post-change distributions using the Bayesian stopping rule.

Usage

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

Arguments

GEN0

A function that take no argument and return an observation from the pre-change model.

GEN1

A function that takes a value of the unknown parameter in the post-change model and return an observation.

th0

Numeric: True value of the unknown parameter in the post-change model.

detect.bayes

A function that implements the Bayesian stopping rule. Currently only detect.bayes for continuous data is supported.

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.

  4. LER A numeric in (0,1): The low ESS rate, i.e., the proportion of iterations that ESS drops below c*n.

  5. AAR A numeric in (0,1): The average acceptance rate of the Metropolis-Hastings sampling in the move step. NaN if ESS never drops below c*n.

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
##Change from N(0,1) to 2*N(0,1)+1 occurs between 10 and 25.
##The mean and standard deviation of the post-change normal distribution are unknown.

GEN0=function() rnorm(1)
GEN1=function(th) th[2]*rnorm(1)+th[1]
ULP1=function(x,th) -(x-th[1])^2/2/th[2]^2
GLP1=function(x,th) -(x-th[1])/th[2]^2
LLP1=function(x,th) -1/th[2]^2
ULP0=function(x) ULP1(x,c(0,1))
GLP0=function(x) GLP1(x,c(0,1))
LLP0=function(x) LLP1(x,c(0,1))
par0=log(2*pi)/2
par1=function(th) log(2*pi)/2+log(th[2])

#using hyvarinen score
sim.detect.bayes(GEN0=GEN0,GEN1=GEN1,th0=c(1,2),detect.bayes=detect.bayes,
nulower=10,nuupper=25,alpha=0.1,thlower=c(-Inf,0),
GLP0=GLP0,LLP0=LLP0,GLP1=GLP1,LLP1=LLP1)

#using log score, normalizing constant unknown
#sim.detect.bayes(GEN0=GEN0,GEN1=GEN1,th0=c(1,2),detect.bayes=detect.bayes,
#nulower=10,nuupper=25,alpha=0.1,thlower=c(-Inf,0),
#score="log",ULP0=ULP0,ULP1=ULP1,lenx=1)

#using log score, normalizing constant known
sim.detect.bayes(GEN0=GEN0,GEN1=GEN1,th0=c(1,2),detect.bayes=detect.bayes,
nulower=10,nuupper=25,alpha=0.1,thlower=c(-Inf,0),
score="log",ULP0=ULP0,ULP1=ULP1,par0=par0,par1=par1)

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