No rush! Its mid-term season where I am, so I am in and out of things as well. I think we’re really close!
I cleaned and re built and received the correct build message. When I tried to run the make examples/bernoulli/bernoulli
I still received permission errors. When I used sudo make
I had no problems. It worked! In order to be able to run it from my julia script, I changed the permissions on my /opt
directory using chmod 755 /opt
. Now when I run the julia script I get a new error:
ERROR: LoadError:
Error when compiling SampleModel bernoulli:
/home/linuxbrew/.linuxbrew/bin/ld: stan/lib/stan_math/lib/tbb/libtbb.so.2: undefined reference to `__cxa_init_primary_exception@CXXABI_1.3.11'
/home/linuxbrew/.linuxbrew/bin/ld: stan/lib/stan_math/lib/tbb/libtbb.so.2: undefined reference to `std::__exception_ptr::exception_ptr::exception_ptr(void*)@CXXABI_1.3.11'
collect2: error: ld returned 1 exit status
make: *** [/home/charper/test/tmp/bernoulli] Error 1
Stacktrace:
[1] SampleModel(name::String, model::String, tmpdir::String)
@ StanSample ~/.julia/packages/StanSample/rqV3P/src/stanmodel/SampleModel.jl:110
[2] top-level scope
@ ~/test/stan_test.jl:28
[3] include(fname::String)
@ Base.MainInclude ./client.jl:451
[4] top-level scope
@ REPL[1]:1
in expression starting at /home/charper/test/stan_test.jl:28
Here is the local julia file I am trying to run in case it helps:
CMDSTAN="/opt/cmdstan-2.28.2/"
using StanSample, MCMCChains
using StatsPlots
ProjDir=@__DIR__
bernoullimodel = "
data {
int<lower=1> N;
int<lower=0,upper=1> y[N];
}
parameters {
real<lower=0,upper=1> theta;
}
model {
theta ~ beta(1,1);
y ~ bernoulli(theta);
}
";
observed_data = Dict("N" => 10, "y" => [0, 1, 0, 1, 0, 0, 0, 0, 0, 1])
# Default for tmpdir is to create a new tmpdir location
# To prevent recompilation of a Stan progam, choose a fixed location,
tmpdir=joinpath(@__DIR__,"tmp")
sm = SampleModel("bernoulli", bernoullimodel,tmpdir);
rc = stan_sample(sm, data=observed_data);
if success(rc)
chns = read_samples(sm, :mcmcchains)
# Describe the results
chns |> display
# Optionally, read samples as a a DataFrame
df=read_samples(sm, :dataframe)
first(df, 5)
println()
df = read_summary(sm)
df[df.parameters .== :theta, [:mean, :ess]]
end