MatlabStan icon indicating copy to clipboard operation
MatlabStan copied to clipboard

Error in checking Stan version & eight schools example

Open dajagl opened this issue 3 years ago • 3 comments

I am using MATLAB version 9.9.0.1718557 (R2020b) Update 6 on macOS Mojave Version 10.14.6.

Going through the eight schools example in Getting Started. This is my output.

Having a problem getting stan version.
This is likely a problem with Java running out of file descriptors
Trying again.
Trying again.
Trying again.
Trying again.
Trying again.
Trying again.
Giving up.
Error using cellfun
Non-scalar in Uniform output, at index 1, output 1.
Set 'UniformOutput' to false.

Error in StanModel/stan_version (line 850)
            ver = cellfun(@str2num,regexp(str{3},'\.','split'));

Error in StanModel (line 196)
               ver = self.stan_version();

Error in stan (line 108)
   model = StanModel();

Error in testStan (line 5)
fit = stan('file', 'eight_schools.stan', 'data', schools_dat, 'iter', 1000, 'chains', 4);

Solution: Change line 850 in StanModel.m: ver = cellfun(@str2num,regexp(str{3},'\.','split')); to ver = cellfun(@str2num,regexp(str{2}(2:end),'\.','split'));

Also, eight_schools.stan does not match what is in the example and will give an error: eta is undefined.

dajagl avatar Apr 07 '22 18:04 dajagl

Thank you! I had the same issue running MATLAB version 9.12.0.1956245 (R2022a) Update 2 on Ubuntu 20.04.4. Your fix on line 850 of StanModel.m worked!

AndyPohlNZ avatar Jun 08 '22 16:06 AndyPohlNZ

Hey, I have the same issue running Matlab version (R2020a) on 64 bit windows 10. I did the line change in StanModel.m. I can pass the error described above. But now, I have a new error after modification of StanModel.m.

Any thoughts? Thank you!!

Having a problem getting stan version.
This is likely a problem with Java running out of file descriptors
Trying again.
Trying again.
Trying again.
Trying again.
Trying again.
Trying again.
Giving up.
Error using mstan.check_ver (line 13)
Versions should be MAJOR.MINOR.PATCH

Error in mstan.stan_params (line 14)
   if mstan.check_ver(ver,'2.1.0') % Stan 2.1+

Error in StanModel (line 197)
               [self.defaults,self.validators] = mstan.stan_params(ver);

Error in stan (line 108)
   model = StanModel();

Error in matlabstan_test (line 27)
fit = stan('model_code',schools_code,'data',schools_dat);

cyf203 avatar Jun 06 '23 19:06 cyf203

I've solved the problem by hard code the ver = '2.22.0'.

cyf203 avatar Jun 07 '23 12:06 cyf203