Questions tagged [stan]

Stan is software for Bayesian estimation using the No-U-Turn sampling (NUTS) algorithm instead of the simpler Gibbs sampling (BUGS).

Filter by
Sorted by
Tagged with
3 votes
1 answer
140 views

Estimating coin bias from multiple adversary observations

I have a set of biased coins $N$, where each coin has a different bias $\theta_i$ (probability of heads for $i$th coin is $\theta_i$). This bias is unknown and needs to be estimated. There are $K$ ...
Vladislavs Dovgalecs's user avatar
2 votes
2 answers
3k views

Highest Density Interval in Stan [closed]

I fit this very simple model in pyStan. ...
Gianluca's user avatar
  • 293
3 votes
1 answer
145 views

Recovering noise-free variables in binary trials

I have a collection of $N$ different objects. An expert "looks" at the object $O_i$ and produces a prediction: binary label $y_i\in\{0,1\}$. The predicted binary label $y_i$ is observed (data) and is ...
Vladislavs Dovgalecs's user avatar
3 votes
1 answer
337 views

Multilevel Model for Regression in STAN [closed]

I have, for N_countries countries and for each day during a certain period, a list of purchases from my website and how much each purchase was. I think that money ...
Red's user avatar
  • 525
1 vote
0 answers
1k views

JAGS better than Stan for fitting CPDs in a Bayesian Network?

I have a Bayesian network DAG structure, and a conditional probability distribution (CPD) for each node. I want to fit the parameters of the CPDs with a Bayesian method, since I have some prior ...
Count Zero's user avatar
  • 1,029
2 votes
0 answers
611 views

Implementing a hierarchical bayesian model with latent independent and dependent variables for spatial analysis (in stan)

I am moderately familiar with frequentist hierarchical modeling, structural equation modeling, and hierarchical structural equation modeling. I am also moderately familiar with bayesian graphical ...
Joe Hoover's user avatar
2 votes
0 answers
1k views

Interpreting bivariate/multivariate probit model (Rstan implementation)

I'm having trouble with inference from the posterior predictive distribution I've generated from a multivariate probit model I constructed using Rstan. My primary interest in the model is to estimate ...
RWM's user avatar
  • 21
8 votes
3 answers
2k views

In Stan is there a way to use parameter posterior from old analysis as prior in new analysis?

Normally within the model block I might specify a prior on a parameter with y ~ normal(mu, sigma); But what if I already have a posterior on y from a previous ...
Count Zero's user avatar
  • 1,029
3 votes
0 answers
312 views

Bayesian word2vec

I'm trying to implement word2vec in pymc3 as shown here: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/udacity/5_word2vec.ipynb. Now I can implement everything with regards ...
sachinruk's user avatar
  • 1,353
11 votes
1 answer
2k views

How to plot prior distributions in Stan?

I tried to run a Stan model without data to get plots for the prior distributions. However, this does not seem to be possible, I get an error message about my model not containing samples. So, is ...
Jens Kouros's user avatar
  • 1,075
2 votes
1 answer
406 views

Censored Count Data in Stan?

I'm trying to fit a negative binomial regression model in Stan to estimate determinants of fertility. Unfortunately the dependent variable (number of children) is censored at a value of 8, therefore I'...
aeq's user avatar
  • 43
5 votes
1 answer
1k views

Marginalizing a Poisson-distributed count parameter in a Binomial Distribution

I'm trying to implement the following model in Stan: $$\begin{align} \text{Pr}(y|n,p) & \sim \text{Binomial}(n,p)\\ \text{Pr}(n|\lambda) & \sim \text{Poisson}(\lambda) \end{align}$$ In this ...
C.R. Peterson's user avatar
2 votes
1 answer
2k views

Stan: Multilevel Ordinal Logistic Regression

I'm trying to create a multilevel ordinal logistic regression model in Stan and the following code would seem to work, in the sense that Stan seems to convergence to sensible answers: ...
Anton's user avatar
  • 409
2 votes
1 answer
2k views

Multilevel Ordered Logistic regression in Stan

I'm trying to create a multilevel ordinal logistic regression model in Stan and the following converges: ...
Anton's user avatar
  • 409
2 votes
1 answer
1k views

Using posterior predicted values in estimation in Stan

I have some data on prices that I would like to predict as a function of covariates. One of those covariates is the predicted rating of that item as estimated from totally separate item rating data. I ...
Brash Equilibrium's user avatar
2 votes
1 answer
411 views

Is correlation between a parameter and the log posterior inherently problematic?

In fitting quasi-Poisson models using RStan, I often see a negative correlation between the variance of the overdispersion term and the overall log posterior (lp__). Other diagnostics such as Rhat, ...
pbee's user avatar
  • 63
0 votes
1 answer
2k views

Bayesian estimation of Dynamic Linear Models with RStan

I'm reading the Dynamic Linear Models with R book, where most of chapter 4 is devoted to bayesian estimation of parameters. They code most of it manually though, and it seems it can get quite tricky ...
Alex's user avatar
  • 247
0 votes
1 answer
1k views

setting log-uniform priors in Stan

I have been using Stan for a couple months now and I want to adopt a log-uniform prior on some parameter array real theta[N]. I want to do something like a ...
Ben Nelson's user avatar
6 votes
1 answer
789 views

Does JAGS have an R front end like brms for Stan? [closed]

Does JAGS have an R front end like brms / rstanarm for Stan? Is anyone working on one for JAGS?
John K. Kruschke's user avatar
5 votes
4 answers
2k views

"Unidentified" hierarchical model in brms/stan - where to go from here?

I am evaluating an intervention in which participants are grouped in teams and each participant fills in a survey before and after the intervention. As such, the data presents a classic multilevel ...
NilsR's user avatar
  • 51
1 vote
0 answers
107 views

HMM prior on stationary probability

I am trying to model a sensor that when mis-calibrated tends to vibrate alot (or atleast high varying readings). I used a HMM to model these vibrations. It is known that the sensor was calibrated ...
sachinruk's user avatar
  • 1,353
0 votes
0 answers
498 views

Posterior predictive density with latent variables in STAN

Using STAN, how do one calculate the posterior predictive density in a model with latent variables in a specified point. As an example consider a model with a single random effect: $ Y_{ij} = a\...
Tobias Madsen's user avatar
3 votes
0 answers
1k views

How to specify the Bayesian version of a clustered-robust standard error OLS in BUGS/JAGS or Stan?

I am trying to reproduce a simple OLS model fitted with clustered-robust standard errors within the Bayesian framework (be it with BUGS/JaGS or with Stan). In R, my frequentist model is the following:...
MAnd's user avatar
  • 139
2 votes
1 answer
408 views

What makes parallel/distributed probabilistic inference difficult to implement?

My knowledge of probabilistic inference is severely limited, so coming from a Computer Science background I'm trying to understand what makes probabilistic inference difficult to implement in a ...
Bar's user avatar
  • 2,862
8 votes
1 answer
3k views

Sampling from Truncated Distribution in STAN

Based on section 26.3 of the stan user guide, I'm trying to specify a model in which observed values are rounded and the true values are known to fall in a certain range (between observed and observed ...
Glen's user avatar
  • 7,290
0 votes
1 answer
589 views

rstan: gamma coef, convergence

I want to familiarise myself with rstan and have this simulated example, where I want to force b to be above 0 (coef on x) using a gamma distribution. Despite 5000 iter (2500 after burn) I get R_hat ...
Dirk Nachbar's user avatar
1 vote
2 answers
2k views

What is the distribution of the ratio of two normals?

I need to use the ratio of two variables as the dependent variable in a regression. Both variables are normally distributed but with positive values. I can either center them or use as it is. If I ...
George Michaelides's user avatar
1 vote
1 answer
1k views

Understanding Prior in rstanarm

I want to to fit y~intercept+x.1*x+x.2*x^2. Here is the indata. The items "ab" and "ad" have the same underlying formula as "aa" and "ac". ...
Chris's user avatar
  • 214
9 votes
0 answers
3k views

Horseshoe priors and random slope/intercept regressions

I'm interested in using the horseshoe prior (or the related hierarchical-shrinkage family of priors) for regression coefficients of a traditional multilevel regression (e.g., random slopes/intercepts)....
C.R. Peterson's user avatar
23 votes
2 answers
4k views

How to summarize credible intervals for a medical audience

With Stan and frontend packages rstanarm or brms I can easily analyze data the Bayesian way as I did before with mixed-models ...
Dieter Menne's user avatar
4 votes
3 answers
546 views

Bespoke MCMC priors & likelihoods, & feeding a posterior joint pdf back in as the prior next time

We're looking at PyStan, PyMC3 and emcee. (switching to R could also be an option, if need be). We have a lot of bespoke priors and bespoke likelihood functions: they are bespoke in the sense that ...
410 gone's user avatar
  • 1,060
0 votes
1 answer
27 views

What is the type of precision in the prior distribution over user's and item's latent factors in PMF?

I am trying to implement the pmf model in stan. paper In this model, there are two prior normal distribution over the latent factors of users and items: $U_i$ ~ $normal(0,\sigma^2I$) And it is said ...
user103553's user avatar
10 votes
2 answers
3k views

priors for Gamma shape and scale parameters

I have a random variable $X$ that is Gamma distributed with unknown parameters $\alpha$ and $\beta$: $$ X\sim \text{Gamma}(\alpha, \beta) $$ I now want to estimate $\alpha$ and $\beta$ from samples $...
spore234's user avatar
  • 1,741
8 votes
1 answer
3k views

Interpretation of mixed model output in lme4 and stan

here's my model in lme4 ...
spore234's user avatar
  • 1,741
2 votes
1 answer
479 views

Multilevel model with partially pooled variance

I have a model with N data points and J groups, where I want to partially pool the means and the variances of the groups. Within group j, for data $\{y_i\}$ I'm assuming $y[i] \sim \mathcal{N}(\...
tkunk's user avatar
  • 1,511
2 votes
2 answers
1k views

Bayesian estimation of GEE models

I'm facing a problem where I want to model a GEE with a tweedie distribution but it's not implemented in any R package that I found. I know that GEEs and linear mixture models (LMM) are somehow ...
spore234's user avatar
  • 1,741
0 votes
0 answers
324 views

Probability of discrete Ornstein-Uhlenbeck process

I am modelling some time-series data as a discrete Ornstein-Uhlenbeck process (not sure if this terminology is correct): $$X[t+1] = X[t] + \theta(mean-X[t]) + \epsilon$$ $$\epsilon \sim \mathcal{N}(...
Pedro Tabacof's user avatar
3 votes
1 answer
1k views

Interesting / strange behavior of one chane on different [unrelated] variables in STAN

I have a quite complex hierarchical model for which I'm estimating parameters and producing posterior predictive using STAN (rstan) for some psychophyiscal data. I'm (sometimes) observing some ...
Jan Tünnermann's user avatar
6 votes
1 answer
927 views

Fit a time series model with unknown lag in Stan

I try to fit a population time-series model in stan/rstan(2.7.0) where the death rate depends on the generation before (n-1) but the reproduction depends on a unknown generation (n-x). I haven't found ...
Julian's user avatar
  • 163
4 votes
1 answer
2k views

How do I compute the posterior predictive distribution of a logit model?

So I used stan to take samples from a logit model. I want to compute the posterior predictive distribution of this model, but I am having trouble figureing out the logit link function and how it ...
Rick726's user avatar
  • 193
5 votes
1 answer
9k views

How do I use Stan to fit a covariance matrix? [closed]

I'm new to Stan (and bayesian methods in general), so this is likely very simple. I'm trying to model some multivariate normal data. All I want to know is the covariance matrix generating the data, ...
Kewl Dude's user avatar
3 votes
1 answer
649 views

Weighted log-probabilities in generalised gamma distribution

This question is related to the problems I mentioned in this question. I am not sure if there is a good solution, but am hoping someone more experienced with this type of thing can help out. I am ...
StevenMurray's user avatar
3 votes
1 answer
1k views

Weighting observations and measurement uncertainty in bayes

I am working on using MCMC (via STAN) to estimate model parameters for a bunch of observations with measurement uncertainty. I'm having problems with weighting each observation, and have reduced the ...
StevenMurray's user avatar
0 votes
1 answer
153 views

Observed function of hidden random variables

Let's say a worker can perform 4 types of tasks in a day: A,B,C,D. Each of which tasks takes time that is distributed according to some probability distribution, say $$ T_A \sim Gamma(\alpha_A, \...
brian's user avatar
  • 3
6 votes
1 answer
4k views

Define own noninformative prior in stan

In the simple case of normally distributed data with unknown mean and variance, Jeffrey's prior is given by $$p(\mu, \sigma^2)=\frac{1}{\sigma^2}.$$ How can I define such a prior in the Stan language,...
Nussig's user avatar
  • 490
3 votes
1 answer
94 views

Representing a Suite of Hypothesis with Stan

After having read the excellent Think Bayes from Allen Downey, I'm now diving deeper into Bayesian Analysis and learning MCMC with Stan. The dice problem in Think Bayes goes like this: Suppose I ...
Hugo Sereno Ferreira's user avatar
3 votes
1 answer
179 views

When is mu_a used in this STAN example?

I'm looking at an example of a random effects model with 2 random effects fit by Peter Li demonstrating how get models fit in lmer into STAN. The code for this and the accompanying data are stored ...
goldisfine's user avatar
3 votes
1 answer
134 views

STAN slowed by rank deficiency?

Does having a set of predictors which are not linearly separable slow down the model fit in STAN? If so, why? I have tried to test this, and it appears to slow down the fit. I fit a model with 10,000 ...
goldisfine's user avatar
0 votes
0 answers
151 views

Combining several posteriors

Is there an accepted method of combining the posterior distributions from a model fit to several participants to obtain a posterior for the entire group of participants? The reason I am asking is ...
Pavel's user avatar
  • 281
0 votes
0 answers
298 views

How can I use the posterior distribution of parameters from one model in another model?

I would like to model different effects of siRNA treatment on measurements. Cells are grown in 384-well plates, subjected to different siRNA treatment and then imaged to determine parameters. Around ...
Michael Kuhn's user avatar