Questions tagged [pymc]

PyMc is a Python module for providing Bayesian statistical models, algorithms and estimations. Two versions are currently widely used: 2 and 3, that are significantly different. Version 2 is not supported anymore, but version 3 is not fully compatible with previous codes and translating a V2-code to V3 is not always straightforward. If you have a PyMc question specific to V3, consider using the [pymc3] tag in addition to the [pymc] tag.

Filter by
Sorted by
Tagged with
0 votes
0 answers
17 views

How to use ADVI of PYMC3 for Bayesian model calibration

I hope to use PYMC3's ADVI for a simple Bayesian model calibration I assume that there is a physical model based on numerical simulation as follows def func_1(x): return (x[:,1] * np.power(x[:,0], ...
0 votes
0 answers
14 views

What is pymc.MutableData?

The docs don't really explain what pymc.MutableData is. From this example it seems like a way of putting data into a model, but it isn't clear to me how that is different than using observed=data in ...
  • 1,014
0 votes
1 answer
21 views

In PyMC how can one represent normal variables the standard deviations whereof have independent logarithmic priors?

Suppose there are three independent normal variables and their means are 0 and their standard deviations have independent logarithmic priors. Suppose we have one observation for each, 1.0, 1e6 and 1e-...
0 votes
0 answers
24 views

How to use the posterior predictive distribution for checking a model from PyMC

I am trying to understand how to use a posterior predictive check (PPC) after building a bayesian model using the PyMC library. I've never done this before and I don't quite understand how I should ...
  • 874
0 votes
0 answers
17 views

@pm.Deterministic in pymc package of python has TypeError: Deterministic() missing 1 required positional argument: 'var'

I am learning the pymc package from the book "Bayesian Methods for Hackers: Probabilistic Programming and Bayesian Inference". While executing some codes shown in the picture, I got errors. ...
1 vote
0 answers
25 views

How to restrict joint combinations of parameter values in PyMC

I am building a PyMC model in which I have a multidimensional Normal distributed parameter, as follows: motor_betas = pm.Normal("motor_beta", mu=0, sigma=1/2, size=9) These betas are later ...
  • 117
2 votes
1 answer
101 views

In PyMC, the "thin" argument seems no more in use. What can be put instead?

Trying to understand PyMC through examples, I made a small model referring to a set of birds weight (data observed: y20), supposedly coming from a normal population N(mu, sigma). import pymc as pm ...
  • 874
1 vote
1 answer
31 views

Wrong exponential sampling in PyMC

I'am obviously doing something wrong here... Please have a look at the following program. It runs well but gives me a lambda parameter for an exponential distribution which is far away from the ...
  • 874
0 votes
0 answers
13 views

How are built the abscissa-axis in Python arviz plots from PyMC?

I am working on Python package PyMC, using the examples shown in this introductory page Introductory Overview of PyMC, available HERE. After running az.plot_trace(idata), the usual plots are shown (in ...
  • 874
0 votes
0 answers
17 views

Model in PyMc too large?

I have this model alpha = np.empty(18, dtype=object) beta = np.empty(18, dtype=object) y_obs = np.empty((18, 18), dtype=object) epsilon = np.empty((18, 18), dtype=object) mu = np.empty((18, 18), dtype=...
2 votes
0 answers
49 views

Implementing ERGMs with PyMC

I am trying to implement ERGMs with PyMC. I've found this, this, this and this, but these resources are a bit dated. I have an NxN matrix for each network statistic (density, triangles, istar2, ...
0 votes
1 answer
72 views

How to run PyMC in 'base' environment?

When I run Python in the base environment and then call import pymc I run into the following error: ModuleNotFoundError: No module named 'pymc.Container_values' How can I solve this problem? ...
  • 1
0 votes
0 answers
19 views

How can I used posterior distributions as tensors in other calculations

I have a PYMC model that I've trained, with ADVI, against some observations. I'm happy with the fit of the model against that data. I'd like to use the posterior distributions from some of my ...
0 votes
0 answers
9 views

Looking for extreme minimum grumbel in pYMC

I have been reading up on the Gumbel function in pymc. According to the docs, this looks like the extreme maximum implementation of the function but I am interested in the extreme minimum version. How ...
0 votes
0 answers
55 views

pymc how do i add dims to gaussian mixture model

I am struggling with the below issue. Suppose I have a gaussian mixture (3 components) but I want to do have individual weights per group (two groups in the below - so i would expect w to be of shape ...
0 votes
0 answers
51 views

How to properly represent the bayesian linear regression in a plot? (PyMC)

I am currently trying to learn Bayesian Statistics and how to implement it with pymc for a project at work. So far I'm just playing around with this linear regression tutorial. Here's the code snippet ...
  • 337
1 vote
0 answers
23 views

How to pass a coordinate to inference data

I've been skimming through Arviz documentation and came across 8 school inference data. import arviz as az idata = az.load_arviz_data("centered_eight") Inference data object also includes ...
0 votes
1 answer
43 views

How to generate samples from distribution function of data points by PyMC3

I have a density distribution function from data, which means that I cannot express its analytical form. If I want to generate 1000 samples by this distribution function, what should I do. It seems ...
0 votes
0 answers
44 views

How to specify a Multiclass GP in pymc

I'm trying to form a multiclass classification model with GP's in pymc. My idea is I specify K independent GP's, stack and normalize their outputs to a probability distribution, which will then be ...
  • 85
0 votes
0 answers
12 views

PYMC a/b testing diff experiment

I have the following code: coords = {'name': ['A', 'B', 'C']} with pm.Model(coords=coords) as context_model: mu = pm.Normal('mu', mu=0, sigma=10, dims=['name']) sigma = pm.HalfNormal('sigma', ...
0 votes
0 answers
39 views

Vector output Gaussian Process in PYMC, Python

I'm not 100% sure if this belongs here or in cross-validated, but here we go. I've began experimenting with Gaussian Processes in pymc, and they seem really appealing due to their versatility. I want ...
  • 85
0 votes
0 answers
31 views

Shape error using pymc for estimates per group

I have the data, there is 4 categories of shop sales shop 0 117 1 1 0 2 2 0 3 3 134 0 4 0 3 I try to estimate distribution for sales using Pymc3 with ...
1 vote
0 answers
75 views

Pymc how to fix shape issues

I have data like this (there 5 different shops: 0 ,1,2,3,4) sales shop 0 117 0 1 0 0 2 0 0 3 134 1 4 0 2 I need to determine distribution for ...
0 votes
0 answers
35 views

Fit a (frequentist) maximum likelihood model in Bambi

Let's say I have a simple binomial regression model: import pandas as pd import bambi as bmb df = pd.DataFrame(data={'group': ['A', 'B'], 'y': [3, 4], 'n': 10}) model = bmb.Model("p(y, n) ~ ...
0 votes
0 answers
14 views

an error importing gaussian regressor from pmlearn

I am trying to use pymc for model fitting and prediction. I got an error upon importing gaussian regressor from pmlearn import pmlearn from pmlearn.gaussian_process import GaussianProcessRegressor ...
0 votes
0 answers
42 views

Estimation of the parameters of networks from data using PyMC

Let a dataset D = {G1, G2, ..., Gi, ..., Gn} with each Gi being a DAG, Gi=(Vi, Ei), with node set Vi and edge set Ei. Each node in Vi takes a value in set {red, blue, green}. The graphs Gi are ...
  • 19
1 vote
1 answer
121 views

Vectorizing theano/aesara variable operations

I am trying to compute the function below with theano/aesara in an preferably vectorized manner: ![image|620x182](upload://9Px5wAGjZdkBXVBg4fqmuSPorPr.png) The solution i have is not vectorized and ...
  • 11
0 votes
1 answer
137 views

How can I get test_value in PyMC(PyMC4)?

I am a newbie in Bayesian and Probabilistic inference, and sorry for this basic question. Recently I am following some examples in Bayesian Methods. And, the examples require me to use "tag....
0 votes
0 answers
50 views

Weibull Survival Analysis

I have just started to study Bayesian Inference and pymc3. I have gone through the tutorials. In the example here (Parameterization 1), the prior is defined as follows: alpha_sd = 10.0 mu = pm....
  • 99
0 votes
0 answers
124 views

PYMC v4: prior of a function of variables

I'm trying to train a regression spline withh a strictly negative first derivative. This is the same as saying that the cumulative sum of the spline coefficients (a vector) must be negative, or zero. ...
  • 3,390
1 vote
0 answers
123 views

aesara/tensor: AttributeError: 'float' object has no attribute 'type'

I'm bulding a model using pymc and aesara. The model worked fine until I introduce the new parameter 'cut_off'. It throws me this error: AttributeError: 'float' object has no attribute 'type'. I've ...
2 votes
0 answers
299 views

Can I install pymc version 4 without using conda?

The official instructions only talk about conda: https://www.pymc.io/projects/docs/en/latest/installation.html I'm trying to put pymc into a docker image and I don't want to use conda in the docker ...
  • 3,390
1 vote
2 answers
555 views

Cannot import PyMc3

I have installed PyMc3 but the import pymc3 as pm fails. Here is the error message: WARNING (theano.configdefaults): g++ not available, if using conda: `conda install m2w64-toolchain` C:\Users\...
  • 331
0 votes
0 answers
183 views

must be real number, not TensorVariable

my code: h = pm.Normal("h", mu=0.0, sigma=0.1) a = pm.Normal("a", mu=mu_a, sigma=tau_a, dims="h") d = pm.Normal("d", mu=mu_d, sigma=tau_d, dims="a") ...
  • 1
1 vote
1 answer
255 views

How to initialize sample values in PyMC3?

I have a model with 4 priors and a custom likelihood. Everything works fine when running the sampling method with its default values and 1 chain. However, I need to change the initial values used by ...
  • 11
2 votes
1 answer
285 views

How to use PyMC (v4.0.1) with statsmodels to estimate state space models?

I am trying to use PyMC (v4.0.1) with statsmodels to estimate state-space models. I am following this example that uses PyMC3: https://www.statsmodels.org/v0.12.0/examples/notebooks/generated/...
1 vote
1 answer
132 views

How to find the mean and the variance of the normal distribution obtained using the advi method in PyMC?

I am using the advi method to find the posterior distribution. How can I find the mean and the std of the normal posterior distribution that we get using the advi and not that of the samples obtained ...
  • 49
0 votes
0 answers
87 views

Is there a PyMC3 function for counting all elements in a tensor that are greater than value

In the PyMC3 model below, I tried to determine the number of relevant parameters n_rel_vars according to the number of elements in joint_reg larger than a critical value threshold which is drawn from ...
  • 337
0 votes
0 answers
158 views

Pymc3 parameter estimation using custom likelihood function sampling error

I try to estimate parameters with a custom complex likelihood function (with 5 parameters to be estimated) using pm.DensityDist: with pm.Model() as model: # Define priors for unknown model ...
0 votes
2 answers
447 views

SciPy error: RuntimeWarning: overflow encountered in _beta_ppf

My SciPy version is 1.7.3 and I'm running on an Apple M1 chip (not sure if it's relevant). My Python version is 3.9.11, installed via Annaconda. I get the error message /opt/anaconda3/lib/python3.9/...
  • 185
0 votes
0 answers
57 views

pymc.Uniform giving ZeroProbability error: Stochastic alpha's value is outside its support, or it forbids its parents' current values

I am using a example given in web of pymc, when I try to run pymc.Uniform I am getting the following error --------------------------------------------------------------------------- ZeroProbability ...
0 votes
1 answer
806 views

Deterministic variable in posterior predictive samples

When generating posterior predictive samples using pm.sample_posterior_predictive the result only shows the observed variable. How can I access deterministic variables after sampling? Here is an ...
  • 1,486
0 votes
0 answers
199 views

How to solve the Mass matrix error with degree of freedom and scale parameters of Student T distribution using Pymc3?

I have been working using the following codes to acquire the Bayesian Fusion of StudentT distribution. Fusion code: def S2_0_Bayesian_Interface(data): ##################################################...
  • 339
1 vote
0 answers
1k views

Sampling of PyMC3 in Python gets runtime error of bootstrapping phase

I have the following PyMC3 code in Python, which are originated from here. In the last line, I got the error RuntimeError: An attempt has been made to start a new process before the current process ...
  • 703
5 votes
1 answer
354 views

How to do simple survival analysis with pymc3 (Weibull distribution regression)?

I'm new to using pymc3, I've read Bayesian Methods for Hackers and done my best to work through existing survival analysis tutorials in pymc3. However, I don't understand how to write/interpret the &...
  • 51
1 vote
0 answers
147 views

Fit chi squared distribution with Pymc

I am trying to fit a Chi-squared distribution using Pymc: # Context for the model with pm.Model() as normal_model: # The prior for the model parameters will be a normal distribution family = ...
  • 1,178
1 vote
1 answer
626 views

what is stable release version with regards to pymc3, arviz and theano packages?

I was working with Spyder IDE with python version 3.8.5 and I was using pymc3 (can't remember the exact version) and it was working fine and after upgrading scipy, spyder and python, everything went ...
  • 339
1 vote
0 answers
52 views

Have issues converting PYMC code to PYMC3

I am trying to convert PyMC code to PyMC. I didn't find a comprehensive guide on differences and I get an error just changing pymc to pm. I would appreciate the help! #hyperpriors home = pymc.Normal('...
3 votes
0 answers
282 views

theano with GPU support

I installed cuda and cudnn following the instructions here: https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html following that I set up a conda environment with python3.8 and installed ...
  • 457
2 votes
1 answer
280 views

pyMC3 - Using the value of a variable

I am simulating a very basic Bayesian Network using pyMC3. In this simulation, I have only categorical variables. Given the value of a variable, I would like to set the distribution of another ...

1
2 3 4 5
10