hasChangepoint: Investigate the possibility of a changepoint

Description Usage Arguments Value Examples

View source: R/changepoint.R

Description

Checks whether it's probable that there is a changepoint in the unidimensional time series x. Currently only one changepoint is supported. The model works by investigating the hypothesis that there is a point in the time series at which the generating probability distribution shifts. These distributions are assumed to be gaussian with a mu1 and mu2. If mu1 and mu2 overlap completely there is no changepoint. The distribution of the location of the changepoint is in the "tau" parameter and is returned in the results as median.

Usage

1
2
hasChangepoint(x, chains = 2, iter = 1000, allpars = FALSE,
  cores = max(parallel::detectCores() - 1, 1), ...)

Arguments

x

the numeric vector representing the timeseries to investigate

chains

number of MCMC chains to run defualts to 2

iter

number of samples to pull from MCMC defaults to 1000

allpars

return all parameter samples from the changepoint model which defaults to FALSE and thus returns only the relevant ones for the decision

cores

the number of cores to use which defaults to max(parallel::detectCores()-1, 1)

...

other arguments passed to the sampling method in rstan

Value

a list of names results containing a tibble with overlap probabilities for mu and sigma as well as the samples for the relevant parameters of the model.

Examples

1
2
3
4
5
## Not run: 
a <- hasChangepoint(c(rnorm(50, 100, 100), rnorm(50, 150, 100)))
print(a$results)

## End(Not run)

DoktorMike/bayesian-model-zoo documentation built on May 23, 2019, 11:32 p.m.