A step of the bayrjmcmc_native implementation. No other function in the package calls it. See the file header for the source the module follows. the source it follows.
Usage
changepoint_rjmcmc(
y = numeric(0),
L = 1,
n_iter = 40000,
burn_in = 4000,
lam = 3,
k_max = 30,
alpha = 1,
beta = 200,
seed = 0,
cap = 0.9,
use_likelihood = TRUE,
k_init = 0,
thin = 1,
keep_chain = FALSE
)Arguments
- y
Coerced to numeric by the body, with
as.numeric. Defaults tonumeric(0).- L
Numeric; passed to
log. Defaults to1.- n_iter
A count; the body uses it as
seq_len(...). Defaults to40000L.- burn_in
Numeric; combined arithmetically in the body. Defaults to
4000L.- lam
Passed to
.log_k_prior_ratio. Defaults to3.- k_max
Numeric; combined arithmetically in the body. Defaults to
30L.- alpha
Numeric; combined arithmetically in the body. Defaults to
1.- beta
Numeric; passed to
log. Defaults to200.- seed
Passed to
.unif_stream. Defaults to0L.- cap
Passed to
changepoint_move_probabilities. Defaults to0.9.- use_likelihood
A flag; the body branches on it. Defaults to
TRUE.- k_init
A count; the body uses it as
seq_len(...). Defaults to0L.- thin
Numeric; combined arithmetically in the body. Defaults to
1L.- keep_chain
A flag; the body branches on it. Defaults to
FALSE.
Value
A list with k_posterior, k_counts, k_mean, s,
h, accept, tried, c, b, d, eta,
pi, mean_s1_given_k1, var_s1_given_k1, mean_height,
chain, n_kept, use_likelihood, method, note.
Examples
u <- .unif_stream(1L)
unique(c(u(), u(), u(), u()))
#> [1] 0.5665616 0.7457818 0.9710028 0.4443592
set.seed(2); y <- sort(c(runif(30, 0, .4), runif(60, .4, 1)))
r <- changepoint_rjmcmc(y = y, L = 1, n_iter = 4000L, burn_in = 1000L, seed = 1L)
r$k_mean
#> [1] 0.067
r$k_posterior[1]
#> [1] 0.933
r2 <- changepoint_rjmcmc(y = y, L = 1, n_iter = 4000L, burn_in = 1000L, seed = 1L)
r$k_posterior
#> [1] 0.933 0.067 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000
#> [13] 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000
#> [25] 0.000 0.000 0.000 0.000 0.000 0.000 0.000
