Dear all,
When I dump the data to the file, it says that the variable N does not exist:
stan_data = dict({
'N': df_.shape[0],
'onset_day': np.array(df_.發病日期.values, dtype='int'),
'report_day': np.array(df_.確診日期.values, dtype='int'),
'truncation_day': truncation_day,
'M': 150,
'xmax': 13.0,
'xmin': -2.0
})
stan_data_file = os.path.join(standirname, 'Data.R')
cmdstan.write_stan_json(stan_data_file, stan_data)
The error:
RuntimeError: Error during sampling: Exception: variable does not exist; processing stage=data initialization; variable name=N; base type=int
I assume I need to declare the type directly (I remember I had a similar issue in the past). I also tried to write int(df_.shape[0]) following Difficulty passing data to PyStan: variable name=N; dims declared=(); dims found=(1) - #5 by ahartikainen, but result is the same
Interestingly, when I do the same with pystan (v.2.19.1.1), everything works
import pystan as stan
stan.misc.stan_rdump(stan_data, stan_data_file)
Thank you in advance and my apologies if I am wrong somewhere.
Best,
Andrei