Getting the Same Output with RStan and C++

What I’m trying to do is get the same values with RStan as I get with running the Stan C++ code directly.

With

stan::services:sample::hmc_nuts_diag_e_adapt()

you can specify:
chain_id
init_radius
num_warmup
num_samples
num_thin
save_warmup
refresh
stepsize
stepsize_jitter
max_depth
delta
gamma
kappa
t0
init_buffer
term_buffer
window

Using Fit a model with Stan — stan • rstan

I’m tryng to specify all these through RStan, but one main thing stands in my way, I’m very new to R.

Here’s the parameter section:

//Where N = 2 in this case

parameters {
vector[N] param;
}

Can someone familar with RStan fill in the blanks to what I have?

control = list(adapt_engaged = TRUE, adapt_gamma = 0.04, adapt_delta = 0.9, adapt_kappa = 0.85, adapt_t0 = 4, adapt_init_buffer = 85, adapt_term_buffer = 40, adapt_window = 20)
fit = stan(file = ‘model.stan’, data=my_data, iter=2000, chains = 1, warmup = 250, thin = 1, seed = 1234, init = list(list(‘param[1]’ = 1.0, ‘param[2]’ = 1.0), algorithm = “NUTS”, control = control)

I’m looking to add:
stepsize
stepsize_jitter
metric (diag_e)
max_treedepth
chain_id (how is this specified if I have more than one chain?)
save_warmup

I’m pretty sure “init” is incorrect here as changing values has no effect.

I think you want init = list(list(param = c(1,1))) but I don’t know that the amount of effort you are going to have to go through to make the results identical is worth it.

Thanks @bgoodri That’s what I needed. The values are consistent now.