I am trying to translate my model from rstan to pystan. However, I observe a significantly slower sampling time and a weird error something like this
If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,
but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
Exception: student_t_lpdf: Scale parameter is 0, but must be > 0! (in ‘unknown file name’ at line 195)If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,
but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.
From R I run:
library("rjson")
library("rstan")
stan_data <- fromJSON(file = "debug_stan_data.json")
stan_data$PR_MAT <- matrix(0, nrow=stan_data$NUM_OF_OBS, ncol=0)
stan_data$RR_MAT <- matrix(0, nrow=stan_data$NUM_OF_OBS, ncol=0)
stan_data$PR_BETA_PRIOR <- numeric(0)
stan_data$PR_SIGMA_PRIOR<- numeric(0)
stan_data$RR_BETA_PRIOR <- numeric(0)
stan_data$RR_SIGMA_PRIOR <- numeric(0)
mod <- stan_model(file='lgt.stan', verbose = TRUE)
fit <- sampling(mod, chains=4, cores=8, iter=1125, warmup=1000, data=stan_data)
From Python I run:
import json
import pystan
with open('debug_stan_data.txt') as f:
stan_data = json.load(f)
sm = pystan.StanModel(file='lgt.stan')
stan_data['PR_MAT'] = np.zeros((stan_data['NUM_OF_OBS'], 0))
stan_data['RR_MAT'] = np.zeros((stan_data['NUM_OF_OBS'], 0))
stan_data['PR_BETA_PRIOR'] = []
stan_data['RR_BETA_PRIOR'] = []
stan_data['PR_SIGMA_PRIOR'] = []
stan_data['RR_SIGMA_PRIOR'] = []
fit = sm.sampling(data=stan_data, iter=1125, warmup=1000, chains=4)
- Operating System Mac
- Python Version 3.6
- PyStan Version 2.19.1lgt.stan (6.1 KB) debug_stan_data.txt (32.3 KB)
- RStan Version 2.19.3