I never observed this in previous versions so it may not be something specific to cmdstan 2.18. In my stan model I have: parameters {
matrix[5, 240] beta_first;
and
transformed parameters {
vector[N] alpha = calculate_alpha(beta_first);
After fitting the model with cmdstan2.18 I run in R:
fit <- read_stan_csv(csvfile)
la <- extract(fit, permuted = TRUE)
I get
dim(la$beta_first) = c(1000, 240, 5) where 1000 is # of iterations.
i.e., beta_first is transposed.
Then in R code I expose calculate_alpha and run
alpha <- calculate_alpha(t(beta_first[1, , ])) which gives the completely different results from la$alpha[1].
I am completely confused and will appreciate any insight. The stan model is attached. NNsigma.2.18.stan (1.5 KB)
I have no problem with transpose. Since alpha is calculated both in stan and R using calculate_alpha function I am pretty sure that calculation in R is not correct. I don’t know what is wrong. In stan model I call it using:
where dim(stan.x) is 12600x240, la$bias_first is 1000x5, la$bias_output is 1000, la$beta_first is 1000x240x5, la$beta_output is 1000x5. Unfortunately alpha.stan[1] is not la$alpha[1, 1]. This one confuses me.
The labels are an rstan thing so I’m not sure. My preference would be to hide this from the user entirely and mask the “transpose” but it’s likely a backwards-compatibility thing for rstan2 at this point.