Description Usage Arguments Value Examples
Change-point detection for continuous data with unknown post-change distributions using the Bayesian stopping rule.
1 2 3 4 5 6 | detect.bayes(GEN, alpha, nulower = NULL, nuupper = NULL,
score = "hyvarinen", c = 0.5, n = 1000, lenth, thlower = NULL,
thupper = NULL, GENTH = NULL, ULPTH = NULL, 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)
|
GEN |
A function of time that returns an observation. |
alpha |
A numeric parameter in |
nulower, nuupper |
Optional nonnegative numerics: The earliest and latest
time of change-point based on prior belief. The default is |
score |
An optional character specifying the type of score to be used:
The default |
c, n |
Optional parameters of the Sequentital Monte Carlo algorithm: ESS
threshold |
lenth |
A positive numeric: The length of the variable of the unknown parameter in the post-change model. |
thlower, thupper |
Optional numeric vectors of length |
GENTH |
An optional function that takes a sample size and returns a
random sample from the prior distribution of the unknown parameter in the
post-change model. Default is standard normal on the unconstrained
space. Required if |
ULPTH |
An optional function: The log unnormalized probability function
of the prior distribution of the unknown parameter in the post-change
model. Default is standard normal on the unconstrained space. Required
if |
ULP0, GLP0, LLP0 |
Functions of an observation: The log unnormalized
probability function, its gradient and its laplacian for the pre-change
model. If |
ULP1, GLP1, LLP1 |
Functions of an observation and a numeric parameter:
The log unnormalized probability function, its gradient and its laplacian
for the post-change model. If |
par0, par1 |
Optional numeric parameters for the pre-change
( |
lenx |
A positive numeric: The length of the variable of an obervation.
Optional if |
lower0, upper0, lower1, upper1 |
Optional numeric vectors of length
|
A named numeric vector with components
t
A positive numeric: The stopping time.
LER
A numeric in (0,1)
: The low ESS rate, i.e., the proportion of iterations that ESS drops below c*n
.
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
.
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 | ##Change from N(0,1) to 2*N(0,1)+1 at t=15.
##Prior knowledge suggests change occurs between 10 and 25.
##The mean and standard deviation of the post-change normal distribution are unknown.
GEN=function(t){ if(15>=t) rnorm(1) else 2*rnorm(1)+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
detect.bayes(GEN=GEN,alpha=0.1,nulower=10,nuupper=25,lenth=2,
thlower=c(-Inf,0),GLP0=GLP0,LLP0=LLP0,GLP1=GLP1,LLP1=LLP1)
#using log score, normalizing constant unknown
detect.bayes(GEN=GEN,alpha=0.1,nulower=10,nuupper=25,lenth=2,
thlower=c(-Inf,0),score="log",ULP0=ULP0,ULP1=ULP1,lenx=1)
#using log score, normalizing constant known
detect.bayes(GEN=GEN,alpha=0.1,nulower=10,nuupper=25,lenth=2,
thlower=c(-Inf,0),score="log",ULP0=ULP0,ULP1=ULP1,par0=par0,par1=par1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.