predict.dsp | R Documentation |
Predict changepoints from the output of ABCO
## S3 method for class 'dsp'
predict(object, cp_thres = 0.5, cp_prop = FALSE, ...)
object |
object of class dsp from |
cp_thres |
(default 0.5) cutoff proportion for percentage of posterior samples exceeding the threshold needed to label a changepoint |
cp_prop |
(default FALSE) logical flag determining if the posterior proportions of threshold exceedance is to be returned. |
... |
currently unused |
The changepoint model uses a thresholding mechanism with a latent indicator variable. This function calculates the proportion of samples where the increment exceeds the threshold.
If cp_prop = FALSE, a numeric vector of indices that correspond to indices of the observed data. If cp_prop = TRUE, a list containing:
- 'cp_t': a numeric vector of indices that correspond to indices of the observed data. - 'cp_prop': a numeric vector of length (T - D) with the pointwise proportion of samples where the increment exceeds the threshold.
If no proportions exceed cp_thres, then the vector will be a length 0 integer vector.
set.seed(200)
signal = c(rep(0, 50), rep(10, 50))
noise = rep(1, 100)
noise_var = rep(1, 100)
for (k in 2:100){
noise_var[k] = exp(0.9*log(noise_var[k-1]) + rnorm(1, 0, 0.5))
noise[k] = rnorm(1, 0, sqrt(noise_var[k])) }
y = signal + noise
model_spec = dsp_spec(family = "gaussian", model = "changepoint",
D = 1, useAnom = TRUE)
mcmc_output = dsp_fit(y, model_spec = model_spec, nsave = 500, nburn = 500)
predict(mcmc_output)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.