r/BayesianProgramming • • Sep 11 '24

State Space Models in Stan

5 Upvotes

Just wondering if anyone in here has some sort of experience with state space models in stan?

I’m struggling with a few things - one of those is the output csv stan creates. Does it have to output the value of each variable at each timestep for example? I am only interested at the current time step.

The file is consuming multiple GBs for example, and if I increase the model complexity, I dread to think what it will be like.

I’d like to chat to someone who has experience in this area, as it seems I’m doing something fundamentally wrong.

Thanks


r/BayesianProgramming • • Jun 25 '23

Bayesian Counterfactual Inference Using Time Series Data

Thumbnail
medium.com
5 Upvotes

r/BayesianProgramming • • Jan 03 '23

Want to learn Bayesian Modeling in Python? - Join the Scicloj Online Book Club starting Saturday January 7th 2023 12:00 EST

Thumbnail self.bayes
5 Upvotes

r/BayesianProgramming • • Oct 03 '22

Struggling about multiple regression with one continuous and one categorical variable

5 Upvotes

Hello all,

I'm very new to Bayesian models and couldn't get over a problem.

I have a correlational data collected from two countries. In this data, which aims to examine the relationship of X score with Y score in two countries, Y and X scores are continuous and country variable is a two-level categorical value.

In order to analyze this data, I need to write a model with RJAGS. I have a lot of information that I can use as a priori, but I think I'm a bit confused about the prior specification. Since all of the prior information I have comes from frequentist papers, the slopes generally represent the effect of the X variable on Y. At this point I don't know how to use a prior for the country slope and how to specify it.

First I thought of writing multiple regression that comes to mind first. I added just the likelihood part of the model below.

mod_string = "model {
  for(i in 1:length(y)){
    y[i] ~ dnorm(mu[i],tau)
    mu[i] = b0 + b1*x_score[i] + b2*country[i] + b3*x_score[i]*country[i]
  }
}"

Accordingly, my prior slope is valid only for b1. For b2, ie country slope, I don't have a prior. In general, the articles comparing the countries have given the slopes of the two countries separately, so I cannot write a single prior for country variable. For this reason, I decided to convert the model to a hierarchical one.

mod2_string = "model{
  for(i in 1:length(y)){
    y[i] ~ dnorm(mu[i],prec)
    mu[i] = b0 + b[country[i]]*x_score[i]
  }
  b0 ~ dnorm(0,1/1e6)
  b[1] ~ dnorm(0.097,1/100) # country 1
  b[2] ~ dnorm(0.255,1/100)T(mu[1],) # country 2
  
  prec ~ dgamma(1/2,1*1/2)
  sig = sqrt(1/prec)
  
}"

In the model I added above, the problem is that it has very high autocorrelation and very high penalized deviance.

> autocorr.diag(mod2_sim)

            b[1]      b[2]        b0         sig
Lag 0  1.0000000 1.0000000 1.0000000 1.000000000
Lag 1  0.9999319 0.9597951 0.9999303 0.012235047
Lag 5  0.9997074 0.9425989 0.9997043 0.009645540
Lag 10 0.9994477 0.9407265 0.9994447 0.007380016
Lag 50 0.9973992 0.9385895 0.9973919 0.007932208

> dic_samples

Mean deviance:  7756 
penalty 2.624 
Penalized deviance: 7758 

I couldn't fix this problem even though I tried with many chains and iterations. I currently have two different prior types. One is a general slope from meta-analyses for variable X. Other one is two separate slopes for X variable coming from two countries separately. How can I build a model with these priors? Can I create one general country prior from the slopes of the two countries? Or how can I solve the second model's converge problem? Apart from these, I am open to any ideas and suggestions. I would be very glad if someone can help.

Thanks,


r/BayesianProgramming • • Feb 13 '22

Gaussian Process Model Building Interface

Thumbnail
github.com
5 Upvotes

r/BayesianProgramming • • Oct 31 '21

Credibility of my credible interval in PyMC3

5 Upvotes

Hello!

So for practice, I was trying to implement the beta binomial model shown here in PyMC3, and a question popped up. So in short this article aims to find out the 95% credible interval for the vaccine efficacy and finds it out to be this interval: (90.82613011726424, 97.87004356894292)

I implement the model in PyMC3 as follows:

with model:

    v_irr = pm.Beta("v_irr", alpha=8, beta=17403)
    c_irr = pm.Beta("c_irr", alpha=162, beta=17349)   
    ve = pm.Deterministic("ve", 100*(1-(v_irr/c_irr)))

    v_like = pm.Binomial("v_like", n=17411, p=v_irr, observed=8)
    c_like = pm.Binomial("c_like", n=14511, p=c_irr, observed=162)

    trace1 = pm.sample(draws=10000, return_inferencedata=False)

With this, I get my 95% credible interval to be: (92.91799613, 97.34246435)

So now i have 2 questions:

(1) My CI is a subset of the CI in the article, so is mine more accurate?

(2) Both of us used the same model. So since I am getting a different answer, is my implementation wrong? If yes, are there any alternate implementations in PyMC3?


r/BayesianProgramming • • Mar 09 '21

In this video we explain the basic methodology and show based on a specific example how it works. We focus especially on the acquisition function and also the difference of optimization performance using hyperparameters within the Bayesian optimization. Check out our Channel and KEEP OPTIMIZING!!

Thumbnail
youtube.com
5 Upvotes

r/BayesianProgramming • • Feb 02 '21

Making a Board Game using MCMC (ritvikmath on YouTube)

Thumbnail
youtube.com
5 Upvotes

r/BayesianProgramming • • Feb 01 '21

particles 0.2: Python library for sequential Monte Carlo

Thumbnail
statisfaction.wordpress.com
5 Upvotes

r/BayesianProgramming • • Jan 14 '21

Ruben Mak - The causal problem of overexposure to repetitive ads: instrument variables and pymc3

Thumbnail
youtube.com
5 Upvotes

r/BayesianProgramming • • Oct 18 '20

Live Structured Bayesian Training using Python - 25 hours

Post image
5 Upvotes

r/BayesianProgramming • • Jun 08 '20

R_hat ~=2 meaning

5 Upvotes

Hi,

I am computing a Bayesian multilevel hierarchical model. I have around 1000 parameters.

While using 2 chains for MCMC and 3000 steps (half of them as Burn in step) I wanted to test the non-centred reparametrized model vs the original one. So I used R hat and the effective sample size.

My values for R hat are around 2 for the 2 models and my effective sample size is very volatile depending on the parameters. I have 12000 data points but the maximum effective sample size that I got is 940.

Can someone help me interpret the results? I am lost

thanks


r/BayesianProgramming • • Apr 13 '20

Time for draws too long in NUTS solver pymc3

5 Upvotes

Hello,

I am using NUTS solver to compute the posterior for Multilevel models using pymc3 on python.

The draws are taking ~20-30 sec (which I assume is long).

Does anyone know what might be the reasons and possible solutions to make the simulation faster.

Thanks a lot


r/BayesianProgramming • • Mar 14 '20

twiecki/covid19

Thumbnail
github.com
5 Upvotes

r/BayesianProgramming • • Feb 29 '20

Holes in Bayesian Statistics « Statistical Modeling, Causal Inference, and Social Science

Thumbnail statmodeling.stat.columbia.edu
5 Upvotes

r/BayesianProgramming • • Dec 17 '19

Benchmarks for Mass Matrix Adaptation

Thumbnail
eigenfoo.xyz
5 Upvotes

r/BayesianProgramming • • Jul 18 '19

Chriss Fonnesbeck: An introduction to Markov Chain Monte Carlo using PyMC3 | PyData London 2019

Thumbnail
youtube.com
5 Upvotes

r/BayesianProgramming • • Jun 15 '19

OATML/bdl-benchmarks

Thumbnail
github.com
5 Upvotes

r/BayesianProgramming • • Mar 22 '19

[news] Nordic Probabilistic AI School (ProbAI), June 3-7, Trondheim (Norway)

Thumbnail
self.machinelearning
5 Upvotes

r/BayesianProgramming • • Nov 09 '18

google-research/simple_probabilistic_programming at master · google-research/google-research

Thumbnail
github.com
5 Upvotes

r/BayesianProgramming • • Oct 04 '18

[1809.10756] An Introduction to Probabilistic Programming

Thumbnail
arxiv.org
5 Upvotes

r/BayesianProgramming • • Aug 31 '18

Multi-Armed Bandits, Conjugate Models and Bayesian Reinforcement Learning

Thumbnail
eigenfoo.xyz
5 Upvotes

r/BayesianProgramming • • Apr 24 '18

[1804.06458] Deep Probabilistic Programming Languages: A Qualitative Study

Thumbnail
arxiv.org
5 Upvotes

r/BayesianProgramming • • Apr 02 '18

From Gaussian Algebra to Gaussian Processes, Part 1

Thumbnail
willwolf.io
5 Upvotes