Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [stan]

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

0
votes
0answers
15 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
7 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 ...
6
votes
1answer
61 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
34 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
24 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
206 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
40 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
55 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
21 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
69 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
109 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
65 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
37 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
125 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
68 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....
3
votes
1answer
260 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
1answer
43 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
48 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 ...
0
votes
0answers
68 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
149 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
23 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
37 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
0answers
43 views

Advice on the Efficiency of Stan Specification

I am interested to model the probability that a consumer will buy each of the choices available given the price of these choices. To model the probability, I represented the data in a new format and ...
0
votes
1answer
52 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: ...
4
votes
1answer
87 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
29 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: ...
0
votes
1answer
125 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 ...
16
votes
1answer
1k 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
236 views

Directed Acyclic Graph of Stan Model

I have the following Stan model: ...
3
votes
0answers
754 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
132 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 ...
2
votes
2answers
349 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
54 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
160 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
83 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
62 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/...
2
votes
3answers
123 views

Disentangling and estimating between-day and between-time variability in a longitudinal study

In a longitudinal study, the hand grip strength of subjects is measured. Each subject is measured at 7 times ($T_1-T_7$): $T_1-T_6$ are measurements at different days and different but fixed hours (...
10
votes
2answers
750 views

Why are there recommendations against using Jeffreys or entropy based priors for MCMC samplers?

On their wiki page, the developers of Stan state: Some principles we don't like: invariance, Jeffreys, entropy Instead, I see a lot of normal distribution recommendation. So far I used Bayesian ...
1
vote
2answers
355 views

Determining normalizing constant for Weibull distribution

I am fitting a Weibull distribution to some data in Stan. I am trying to reproduce some published values of parameters from a paper. However I am running into problems because I believe the ...
1
vote
1answer
211 views

Fitting regression spline [closed]

I am reading the paper by Willemsen et al (2015), "A multivariate Bayesian model for embryonic growth", Statistics in Medicine, 34:8, 1351–1365 I have a model like $$y_{ij} = \gamma_{i2} + f((t_{ij} ...
6
votes
1answer
414 views

Guassian Process for Data Imputation

I recently came across Gaussian Processes in Gelman et al. (2013), and I am trying to learn more about their potential application for use in imputing time series data. The data of interest is a ...
0
votes
1answer
48 views

Estimate a parameter from subset of the data, other parameters from all data

I use Bayesian random effects models [$y_i \sim bernoulli\_logit(\beta + \alpha_{subj})$ $\alpha_{subj} \sim normal(0, \gamma)$], the $y$ outcome is binary. Part of the subjects have two observations,...
1
vote
1answer
291 views

Problem with “log(0)” error while using brms in R to do Bayesian analysis [closed]

I'm using brms to conduct a multilevel regression in R. I've been getting warnings and errors of the following type: ...
1
vote
1answer
41 views

Stan - find dimensions of an object - lower and upper question [closed]

I have a bunch of objects (roughly rectangular) , for some of which I know what their dimesions - x, y, and ...
0
votes
1answer
53 views

Best modeling approach for “two-factor varying slope” model?

I'm new to this forum so I hope this question is appropriate. Please let me know if there is anything I can do to improve the question. I simply have a situation in which I am considering the best ...
1
vote
0answers
192 views

stan - 2 approaches to missing value imputation; which is better and why?

So, me and a colleague have to impute some data, x, given a categorical variable. We arrived at two different approaches: a) as in the tutorial: split x into x_obs and x_mis, and treat x_mis as ...
1
vote
1answer
58 views

re.form specifying one random effect but not the other

I have fitted a multilevel model using stan_lmer that has two sets of varying intercepts, one for categories and one for subjects. The code essentially looks like ...
0
votes
1answer
82 views

How to add random walk in rstanarm [closed]

I have used rstanarm GLM model without the intercept like below in R ...
1
vote
0answers
26 views

“Blocking” effects in probabilistic programs

I'm trying to estimate a regression where: I can only see the sex of a subset of the population I do know the total population size I'd like to know how many events are driven my men vs women, using ...
0
votes
1answer
141 views

Comparing posteriors distributions between models

I have two models (which I'm estimating by MCMC with Stan). There are more parameters in reality, but a simplified example is: A: y ~ (1|group) B: y ~ X + (1|group) I then calculate the ICC in each ...