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
1
vote
0answers
25 views

Mixed model with panel data when some cases have constant responses (zero) over time

I have a panel data with about 300 units observed over a period of 4 weeks. In each week, I recorded a response that is a binary variable, y, for each unit of that week. For about 50% of the units, ...
2
votes
0answers
16 views

Computational time of a (fairly complex) GAM with ARMA structure in brms

I am fitting a model for time-series analysis of Wikipedia views with STAN through the brms package. I came up with a pretty good distributional model, which ...
2
votes
1answer
80 views

Why in Hamiltonian MCMC do we multiply the posterior distribution by the likelihood?

So maybe I am misunderstanding what the author is staying, but I am reading Chapter 14 of Kruschke's Doing Bayesian Analysis. I am reading about the software Stan and how it uses the Hamiltonian MCMC ...
3
votes
1answer
156 views

Divergent transitions in Stan

Intuitively, what does the warning "There were 214 divergent transitions after warmup." mean? I understand that the samples obtained are useless, and that increasing adapt_delta, and max_treedepth, ...
1
vote
1answer
27 views

Bayesian liability threshold model

Let $\bf{y}$ denote a vector of binary data, such as whether a group of individuals suffer from a particular disease, and let $\bf{X}$ denote a matrix of potential predictors, including an intercept ...
0
votes
1answer
118 views

Stan logistic regression with binary independent variables [closed]

I am developing my very first Stan (MCMC) model and naturally got hit by a problem. This is probably a very basic issue, but I did not find an answer in Stan documentation so asking your help now. My ...
0
votes
0answers
37 views

Where is Stan sampling from?

I found a link that shows a simple Stan model for linear regression: ...
0
votes
0answers
14 views

Most likely domain element in probabalistic forward model

Suppose I have some probablistic forward model $m: T \rightarrow U$, and that the model is then conditioned on observations $u_1, \dots, u_N$ from U. [More specifically, by 'probabalistic model' here,...
0
votes
1answer
26 views

When to exponentiate: the mean of the chain or at every step in the chain?

I am interested in when it is best to exponentiate a difference in log-odds Here is a sample problem in the stan language, three groups of forty binary observations, group 1 with hit probability = 0....
2
votes
1answer
59 views

Why does Stan initialize an MCMC chain with a random value generated uniformly from [-2, 2] instead of a random value generated from the prior?

From Stan reference, The default is to randomly generate initial values between -2 and 2 on the unconstrained support It seems to me that it makes more sense to randomly generate initial values ...
2
votes
1answer
124 views

Low effective sample size but good R-hat is this a problem?

I am using Stan (Hamiltonian Monte-Carlo) to run a highly paramaterized model. One of the parameters in particular has a very low effective sample size (n_eff < .10*number of retained draws), but ...
0
votes
0answers
65 views

Multilevel Negative Binomial fails with MLE

I have a pretty complex multilevel neg. binomial regression that does not converge when using a regular MLE (but from what I understand, when dealing with multilevel models, MLE is not regular, per se)...
1
vote
1answer
66 views

How to include seasonal effects into the system matrices of a state space model

I am working on learning state space models and am leaning heavily on this very helpful documentation. However, I'm really confused about the best way to include both a seasonal effect and dynamic ...
0
votes
0answers
28 views

Translate data into parameter coefficients - Bayesian regression

I Have a data set of accident rates from a population in which I'm attempting to identify which factors have the most effect on how many injuries occur from each accident. Since I am trying to ...
0
votes
0answers
43 views

Stan: Ancova with a Poisson distribution

I am trying to code an Ancova with a block effect for count data. Here I will simplify the Ancova to a simple linear regression with a block effect. As I am using count data with low observed values ...
0
votes
0answers
31 views

Enforcing positive sign on random effects coefficient

I have a mixed effects model in brms of the form (lme4 notation): y ~ x + (1 + z1 + z2|g) where g is a grouping factor on ...
0
votes
0answers
81 views

JAGS: Posterior Predictive Check for a Logistic Regression Model

I want to perform a posterior predictive check on some simple logistic regression models that I fitted in JAGS. I found a function in the R package jagsUI called pp.check (see doc here: (pp.check ...
7
votes
1answer
71 views

Is it appropriate to estimate a random slope without estimating the overall mean slope?

I am trying to estimate whether there are differences in how individuals in different cities (my grouping variable) respond to a few predictor variables. So, in practice, I am interested in learning ...
1
vote
0answers
85 views

Problems estimating a “Bayesian version of FIML”

I am anticipating that my question exposes some basic ignorance about how mcmc works, but here we go: In an attempt to deal with missing data I am trying to simultaneously estimate a regression model ...
1
vote
1answer
37 views

Estimating the standard deviation of Bayesian regression

When developing a Bayesian multiple linear regression model, how do you estimate the parameters of the standard deviation? From my understanding, the standard deviation is associated with each ...
0
votes
1answer
659 views

Long data format for Mixed linear modeling

I have a data set from an experiment with two conditions: a control condition, and a testing condition. It's an experiment performed in pairs. Each condition was undertaken by 20 pairs of subjects (...
0
votes
0answers
46 views

Hierarchical bayesian model: should I account for lack independence?

I am working with vegetation surveys that were conducted in several river networks. See the attached image that shows one of the those river basins/networks. I am interested in analyzing how the ...
1
vote
1answer
62 views

Generalization performance in Bayesian errors-in-covariates model

I'm working on a model with this basic structure: The square nodes are data, and the round nodes are parameters and/or latent variables. The left plate represents the "training observations" we ...
1
vote
1answer
33 views

Stan: output some (but not all) intermediate variables of interest [closed]

I am a newcomer to Stan but quite a Stan enthusiast by now. Currently I am working on a Stan application involving a somewhat complex computation with a bunch of intermediate variables of which I ...
1
vote
2answers
98 views

NUTS Drawing samples from slice sampler; how to keep bounds on log scale?

I'm currently working to adapt the No U-Turn Sampler from this paper for a model I'm working on. The No-U Turn sampler augments the typical hamiltonian system by incorporating a slice variable $u$ ...
0
votes
0answers
211 views

Getting main and interaction effects from Bayesian factorial ANOVA in Stan

I am using Rstan to build a factorial ANOVA model with two factors and their interaction. The sample dataset has 2 factors, A (levels A1 and A2) and B (levels B1, B2, B3) and 10 replicates for each ...
0
votes
1answer
94 views

Should weights be applied in generated quantities block in stan?

I want to do predictions via generated quantities block in stan. I have two questions: Should the weights be applied again in the generated quantities block in addition to the likelihood in the ...
0
votes
1answer
66 views

How to use a G-Wishart distribution in stan

I would like to use the following kind of prior in a Stan simulation $$ f_{K \mid G} (k \mid g) = \frac{1}{I_g(b,D)}|k|^{\frac{b-2}{2}} \exp \biggl \{ -\frac{1}{2} \text{tr} (Dk) \biggr \}\mathbb{1}_{...
1
vote
2answers
173 views

Timeseries with multiplicative noise in Stan

Say we have a monthly time series $y_t \geq 0$ dominated by seasonality, where the absolute differences from year to year are much smaller during low season. To avoid negative values and capture the ...
1
vote
1answer
118 views

GLM and implementation of Poisson regression model in R by hand

first of, this is not my school exercise but a given example that I'd like to convert from Stan to my own code. I am very much a pragmatic learner so doing this helps me a lot to visualize the problem....
4
votes
1answer
774 views

What is the purpose of “transformed variables” in Stan?

I find references to transformed values in the Stan Reference and User Guides, and example code but no clear tutorial explanation. I'd be grateful for a link. Michael Betancourt, in his Stan ...
1
vote
2answers
64 views

Two priors on the same parameter?

I received a text where the author was employing Stan language in order to show how to create a random walk with normally distributed parameters. His model had parameters $\mu_{t}$, ($1,2,...,T$), ...
0
votes
1answer
81 views

Intraclass Correlation Coefficient with Bayesian ordered-logit GLMM (STAN)

I am fitting a Generalized Linear Mixed Model for an ordered outcome, in form of an ordered logit, with random intercept and slope. For this task, I am going Bayesian by handling STAN through the ...
2
votes
0answers
184 views

Guessing the probability of heads while tossing two biased coins

A game is played at a computer, as follows: There are two coins, one silver coin and one gold coin, in a box. The computer “shakes” the box, and then tells the player whether the two coins landed on ...
4
votes
1answer
270 views

Coding resources: Accessible introductions to Bayesian Structural Time series?

Hello, all. I am asking this question in not necessarily a "subjectively recommend something for me" approach, but with a clear focus on just an accessible beginner's reference. My situation is I have ...
0
votes
1answer
67 views

performance issues with linear mixed model

I am fitting a linear mixed model $y_{t} = \beta_0 + \beta_1x_{1t} + \beta_2x_{2t}+ \beta_{0i[t]} + \beta_{1i[t]}x_{1t} + \beta_{2i[t]}x_{2t} + \beta_{0j[t]} + \epsilon_t$ with ...
0
votes
0answers
48 views

linear mixed model gives wrong results

I am currently learning Stan (MCMC C++ engine with wrappers in python and R) and implemented a linear mixed model $y_{i,j} = \beta_0 + \mathbf{x}_{i,j}^T\beta + \alpha_i + \epsilon_{i,j},\ 1\leq i\...
0
votes
1answer
76 views

Does there exist theory behind how many knots one should use in a stan_gamm4() model for a given set of UNIQUE covariates?

Currently, I am working with trying to fit a non-linear model with stan_gamm4. This can be done through specifying smoothing functons, such as: ...
5
votes
1answer
160 views

What do blank cells mean in the output of prior_summary in the brms package?

The brms package is an R package for fitting Bayesian models using lme4-like syntax using Stan as the back-end. In the package, ...
1
vote
0answers
35 views

Mixed effects model with proportionally dependent intersects

I have a dataset with both fixed and random effect and I'm trying to build a mixed effects model for it. The data looks like the following: ...
2
votes
1answer
240 views

Impute binary outcome variable for GLM using Stan in R

My outcome variable is a series of Bernoulli trials where some values are missing y $\in$ {0, 1, NA} How do you impute NA values for an outcome variable in rstan in the context of a GLM, assuming ...
15
votes
1answer
2k views

Stan $\hat{R}$ versus Gelman-Rubin $\hat{R}$ definition

I was going through the Stan documentation which can be downloaded from here. I was particularly interested in their implementation of the Gelman-Rubin diagnostic. The original paper Gelman & ...
1
vote
1answer
363 views

Directed Acyclic Graph of Stan Model

I have the following Stan model: ...
3
votes
0answers
1k views

Implementing Predictive Posterior Distribution Using Stan

Background I had an example that sought to demonstrate the posterior predictive distribution in the context of a normal measurement model. The data that was used is as follows: ...
2
votes
1answer
141 views

Bayesian models: Bayesian t-test on effect posterior against 0 as index of effect existence

I am fitting Bayesian models (using R and rstanarm). Beyond estimating the effect of each predictor (and extracting pointwise indices such as median, MAD and 90% CI), I am also interested in having a ...
3
votes
2answers
443 views

comparing distributions - bayesian decision analysis

I am attempting to use Bayesian analysis to compare distributions to help with decision analysis - when to treat a patient based on a blood measurement X. Here you can see 1000 samples from two ...
0
votes
1answer
80 views

Parameter draws from KDE

I am working on a GARCH estimation with a slight twist. For that I need to use a modified posterior distribution as prior for something else. The posterior distribution from Stan is a sample of ...
0
votes
1answer
177 views

In the rstanarm package, is there a way to incorporate random effects in the stan_glm function? [closed]

I am wondering if there was an option to incorporate random effects in the stan_glm function in the rstanarm package within <...
1
vote
1answer
104 views

Obtaining effect size from “rstanarm” package's linear regression

In my study a control group (c) is pretested (pre.c) and post-tested (pos.c). Similarly a ...
0
votes
0answers
93 views

Strength Parameter in ICAR Spatial Model

As I understand it, the parameter $\alpha \in [0, 1]$ that controls strength of spatial association in a CAR model gets set to 1 in an Intrinsic CAR model. Does this mean that an ICAR model cannot/...