Hi,
I am a new user of pymc
. I am a regular user of rstan
but I came across the advantages of pymc4
over stan
as it can generate from discrete parameters while using NUTS.
To understand the usages, I found the following page-
I tried to replicate the examples in the recently installed Anaconda 3 with the jupyter notebook interface. Unfortunately, it is taking 3 hours to run 8000 samples using pymc3 whereas it is supposed to run in 23 seconds as shown on the webpage. Same thing happened using pymc4.
Specs for my laptop are: Windows 11, 8 cores, ram 16 GB
The code I tried (copying from the weblink given above):
def build_model(pm):
with pm.Model(coords=coords) as hierarchical_model:
# Intercepts, non-centered
mu_a = pm.Normal("mu_a", mu=0.0, sigma=10)
sigma_a = pm.HalfNormal("sigma_a", 1.0)
a = pm.Normal("a", dims="county") * sigma_a + mu_a
# Slopes, non-centered
mu_b = pm.Normal("mu_b", mu=0.0, sigma=2.)
sigma_b = pm.HalfNormal("sigma_b", 1.0)
b = pm.Normal("b", dims="county") * sigma_b + mu_b
eps = pm.HalfNormal("eps", 1.5)
radon_est = a[county_idx] + b[county_idx] * data.floor.values
radon_like = pm.Normal(
"radon_like", mu=radon_est, sigma=eps, observed=data.log_radon,
dims="obs_id"
)
return hierarchical_model
I tried the followings:
model_pymc3 = build_model(pm3)
%%time
with model_pymc3:
idata_pymc3 = pm3.sample(target_accept=0.9, return_inferencedata=True)
and
model_pymc4 = build_model(pm)
%%time
with model_pymc4:
idata_pymc4 = pm.sample(target_accept=0.9)
Additionally, I also faced some installation issues.
For installing pymc4
, I used conda create -c conda-forge -n pymc_env "pymc>=4"
. This resumes the installation and the following file was created:
4.txt (9.7 KB)
The file looks interactive but I don’t know any way to interact with this and the installation was stuck forever.
I installed pymc4
by using the command pip install "pymc>=4"
and that seemed to work fine as it didn’t pop up any error message.
For installing pymc3
I used pip install pymc3
as mentioned in the installation guide. It gave me the following error but it did not show any problem while importing the package.
If you kindly tell me if the packages are wrongly installed or guide me to solve the slow sampling issue, it will be very helpful.