Questions tagged [stan]
Stan is software for Bayesian estimation using the No-U-Turn sampling (NUTS) algorithm instead of the simpler Gibbs sampling (BUGS).
253
questions
0
votes
1
answer
21
views
Centering prior distributions on MLE/OLS estimates
Andrew Gelman recommends placing weakly-informative $N(0, 1)$ priors on unknown parameters fitted in Stan and often does so in his own models. In Stan, the Normal distribution is parameterized by the ...
1
vote
0
answers
21
views
Power of Bernoulli likelihood in Jags (R2jags) [closed]
In a fixed power prior model, the model is set up as:
$$ \pi(p_i \mid \alpha,\mathcal{D}_0) \propto L(p_i\mid \mathcal{D}_0)^{w} \pi(p_i) $$
Suppose that the event follows a Bernoulli distribution ...
0
votes
0
answers
34
views
Bayes factor for testing fit of different spatial models in Stan
I have a question about testing of different spatial specifications of a polynomial regression. I am using Stan for Bayesian inference, but I did some initial exploration using the R packages ...
1
vote
0
answers
31
views
When and how to use approximate leave-future-out cross-validation on hierarchical time series Stan model
I am fitting a hierarchical state space AR(1) model in Stan and am struggling use common model evaluation metrics on the model output. Computing the WAIC or using loo_cv in the loo package give ...
1
vote
0
answers
32
views
Multilevel Bayesian model for Experimental Design with levels in treatment and control groups
Context
I'm designing an experiment and Bayesian analysis to interpret results. I've used Statistical Rethinking as inspiration for model structure.
Suppose I want to study the effects of a sports ...
0
votes
0
answers
47
views
Why am I getting very different results from jags and stan
Why am I getting different results from jags and stan in a simple linear regression model?
Using Sepal.Length ~ Petal.Length in the ...
0
votes
0
answers
39
views
Latent variable estimation with fixed effects
I have survey data on political beliefs that I'd like to estimate latent ideology with. Survey questions are binary agree/disagree responses. However, respondents can repeat the survey and skip any ...
1
vote
0
answers
17
views
Find probability of students to cheat with Bernoulli model [closed]
I have been trying to solve this for a long time now, but I still can't figure it out.
Background of the problem:
I have data on two exams. There were suspicions that many people cheated on the first ...
0
votes
0
answers
51
views
Stan: modulated distribution
I am modeling a process where events happen every X days with X following a gamma distribution. I already have a model for that ...
1
vote
0
answers
31
views
Using survival analysis parameters from multilevel model as a workaround for censored predictor?
I am interested in predicting psychopathology development over time using survival parameters from the survival model.
I have data collected using ESM in daily life during which individuals reported ...
0
votes
1
answer
19
views
How to fit a stand model with two nested multiplications to mu
I'm studying the Statistical Rethinking 2ed book and trying to write the codes to Stan (I'm using pystan). And stuck on how to write the model below in stan.
This problem is described in the book page ...
0
votes
1
answer
32
views
Mixture of Two Normals
Suppose we have a data which consists of two normals,
x = rnorm(50,mean=1,sd=2)
y = rnorm(50,mean=2,sd=3)
z = sample( c(x,y) , size = 100, replace=FALSE )
The goal ...
0
votes
0
answers
12
views
Equivalent of (Ordered) Logistical Distribution for Aggregate Data
I am trying to estimate an item-response like model (or more accurately graded-response type model), but for aggregate data. I am working in Stan (but that is a detail for present purposes). What I ...
0
votes
0
answers
20
views
Stan model for estimating counts of categories within a defined hierarchy
I am in the process of coding up a model in Stan which involves categories of items which fall into a natural hierarchy. For the sake of exposition, let's say that I am interested in modelling sales ...
0
votes
0
answers
7
views
Failing to reproduce a stan fit, is it a dependency issue?
I am trying to reproduce the Stan results in this jupyter notebook (github link).
Background
This model is a PCA / factor-analysis model where we observe data matrix $Y=X W^T+ \epsilon$ and we want to ...
1
vote
1
answer
71
views
Using a Generalized Beta Distribution of the Second Kind as a Prior in Stan Linear Regression
So I'm considering a simple linear regression model with $p = 1$ predictor $$y = \beta x + \epsilon$$ where $\epsilon \sim N(0,\sigma^2)$. I want to use a generalised beta distribution of the second ...
0
votes
1
answer
72
views
Negative binomial not capturing overdispersion in glm model
Following this example, I am fitting a glm model with rstanarm to count data that look like this:
The simple specification below runs just fine:
...
1
vote
0
answers
88
views
Inv-Wishart against LKJ prior for multivariate meta analysis model
I am working in Stan on a three-dimensional multivariate problem. The model assumed is that the data are from a multivaraite normal with study level mean and covariance matrix, with the covariance ...
0
votes
0
answers
14
views
Multi-level model for for multi-level data
I have data split by two axes, experiment (test vs control) and demand (high vs low). I'd like to pull information in such a way that
$ \mu_{high-test} = \mu_{high} * \mu_{test} $
$ \mu_{low-test} = \...
0
votes
0
answers
297
views
Posterior predictive distribution: Sampling vs calculating
I am having trouble understanding how to make predictions with the posterior predictive distribution. Posterior predictive is $p(y|x,D)=\int p(y|x,\theta)p(\theta|D) d\theta$ where $D$ is the training ...
1
vote
0
answers
65
views
Categorical model divergences/high parameter density near zero in Stan
I'm working on a hierarchical categorical/multinomial logit model in Stan. I thought I'd expand my question to stack exchange to see if anyone has any suggestions on the statistical model, since it's ...
1
vote
1
answer
54
views
Methods for modelling distributions?
As predictor X I have particle size distributions
and I would like to run a model y ~ X.
I.e. each trial has a response ...
1
vote
1
answer
233
views
What is the correct bayesian formulation for the zero-truncated Poisson lognormal model?
In ecology we use compound distributions to describe species-abundance data. One example is the Poisson Lognormal (PLN) distribution which is a Poisson distribution with rate parameter $\lambda$ that ...
1
vote
1
answer
162
views
Parallel with Weighted Least Squared in Bayesian Regression
I have a dataset with a column of ratios $Y = z_1 / z_2$, which will be my depending variable, and a set of columns that explain $Y$.
Here $z_1$ means "imports" and $z_2$ means "exports&...
0
votes
0
answers
230
views
Can we define inverse gamma priors in stan_glmer()?
Although I tried to read the manual, I don't quite see how I can incorporate the following model in stan_glmer().
$Y_{ij}|\mu_j,\sigma_y \sim N(\mu_j,\sigma_y^2)$
$\...
1
vote
1
answer
93
views
Posterior distributions --- what's the correct way to see it?
When running models from a bayesian perspective — a regression for example — we get posterior distribution for every parameter/statistic we want, right? I’m wondering whether I should see this this ...
1
vote
1
answer
81
views
Bayesian GLM where the response variable is count classes
Description of data
I have to analyze some data where the response variable is the counts of number of insects observed feeding on a bait at many time points. The treatments are three different types ...
9
votes
1
answer
443
views
Marginalizing out discrete response variables in Stan
There's been quite a bit of discussion and confusion about how to marginalize out discrete response variables in Stan (e.g. binary or ordinal data). See, for instance:
Impute binary outcome variable ...
1
vote
1
answer
83
views
How to write proportionality in a Stan model?
I am having difficulties in writing the following equation into a Stan model.
$$
y_i = \mu(x_i) + \epsilon_i
\\ \epsilon_i \sim N(\theta,\sigma^2)
\\ \mu(x_i) = a + b x_i
\\ p(a) = p(b) \propto 1
\\ \...
0
votes
0
answers
221
views
Does thinning in JAGS/Stan reduce computational time for simulating a chain of a given length?
Question
Let's say we have a complicated model whose posterior distribution we want to draw from using MCMC. To do this, we simulate a chain of total length $N=10,000$. For the sake of this question, ...
0
votes
0
answers
22
views
Analysing repeated movement trajectories - is a GP the right approach?
I have some data where I have multiple conditions per subject (humans, in this case), who made repeated movements under these conditions. I'm interested in the variability of these movements.
The data ...
1
vote
1
answer
85
views
Help with rstan models [closed]
I would need help in order to write a specific Stan model.
The biological question
The idea of the model is modeling the number of Bones (NbBones : discret ...
2
votes
1
answer
228
views
Difference in fitting to right censored data between MLE and Bayesian method
I am fitting a Weibull curve to right censored data. I am doing it by general MLE method using Survival::survreg() as well as Bayesian method using brms::brm.
I am pretty sure that I am getting the ...
1
vote
0
answers
164
views
How to fit a scalable Bayesian VAR model in Stan/JAGS
I am trying to fit a Bayesian vector auto regressive model but I am struggling with the computation. I tried both JAGS and Stan to fit the model but I have never been able to fit it successfully. It ...
1
vote
1
answer
414
views
How to add Gaussian noise on top of a logistic regression model in Stan?
I am building the following model for logistic regression in Stan (pystan):
Predictor: $\eta_t = \beta_1 x_{1,t} + \beta_2 x_{2,t} + \beta_3 x_{3,t} + \beta_4 x_{4,t} + \sigma \epsilon_t$
Outcome: $...
1
vote
1
answer
129
views
In JAGS, how can I fix a parameter to a distribution, as opposed to just a constant?
The first code chunk below (model1) is a JAGS script designed to estimate a two-group Gaussian mixture model with unequal variances. I am looking for a way to fix one of the parameters (say $\mu_2$) ...
0
votes
0
answers
26
views
When doing a ROPE analysis for dichotomous predictors what kind of coding should I use?
I am using stan_lmer() to run a mixed effects analysis. The key variable I am interested in testing for the ROPE is an interaction between two dichotomous predictors. I understand that the scale of ...
0
votes
1
answer
125
views
How do I write the Jeffreys prior for error variances in stan? $p(\mu, \sigma_1^2, \dots, \sigma_C^2) \propto \Pi{ \sigma_i^{-2}}$ [closed]
I need to model the Jeffreys prior for error variances in a heteroscedastic ANOVA design in rstan.
That is to say, $\pi(\mu,\sigma_1^2,\dotsb,\sigma_C^2)\varpropto\Pi_{i=1}^{C}\sigma_i^{-2}$.
Is the ...
1
vote
0
answers
29
views
Bayesian estimation of ARMA coefficients
It's clear to me how to find the parameters of an AR(p) process in a Bayesian setting. E.g., AR(2), we could do
$$ \alpha_1 \sim \mathcal{Normal}(0, 1)$$
$$ \alpha_2 \sim \mathcal{Normal}(0, 1)$$
$$ \...
3
votes
1
answer
647
views
Default Priors for Intercept and Standard Deviations in R package brms
The only resource I found explaining the default priors in brms is its manual (newest version, updated 03/14/2021) for function set_prior().
For the intercept, the manual does not specify how the ...
1
vote
0
answers
328
views
Is my Stan model correct? The Jeffreys prior for a heteroscedastic mixed-effects model
I am using rstan to obtain MCMC samples from a heteroscedastic mixed-effects model with different residual variances $\sigma_j^2$ for each experimental condition $j$.
One assumption is the Jeffreys ...
0
votes
0
answers
224
views
Reproduce results of bayesglm with stan_glm
As indicated in the title, I am trying to reproduce the
results of the bayesglm function with the stan_glm. In
principle, the ...
0
votes
1
answer
138
views
Stop stan when it reaches convergence (Rhat = 1) [closed]
I'm doing a Bayesian analysis, which involves changing the warmup and iterations (many times per day). I wanted to know if there is a loop to automatically change warmups and interactions and stop the ...
1
vote
1
answer
79
views
Survival analysis for different diseases on same patients
I want to apply survival analysis on UFC-fights. Each fighter represents a "disease" and each knock-out is a "death". Each UFC fight consists of a number of rounds and the number ...
1
vote
1
answer
528
views
Can PyStan models be used to make predictions after fitting?
Once I've fit a PyStan model, how can I use it to make future predictions without re-fitting?
1
vote
0
answers
133
views
Regression with SARIMA errors
After an SARIMA transformation, is $\epsilon_t$ equal to the difference in observed original $y_t$ from its estimate or the equivalent quantity for transformed $y_t$, $y'_t$?
The motivation: I am ...
6
votes
1
answer
1k
views
How to propagate measurement uncertainty in predictors *and* responses for multidimensional, non-parametric regression (and software to do it)?
Background
Errors-in-variables models are defined as:
regression models that account for measurement errors in the independent variables. In contrast, standard regression models assume that those ...
0
votes
0
answers
71
views
Bayesian sequential updating with current Bayesian sampling software?
I'm having a hard time implementing sequential updating with current software, I don't even know how to start. Basically, I'm having to refit the whole model by simply appending the new data to the ...
2
votes
1
answer
248
views
How do I get around this "Argument 'coef' may not be specified when using boundaries."
I have a model, the brms code is given below. It is a system of equations (I am estimating demand for two categories of goods). Economic theory tells me that the intercepts have to be restricted to ...
6
votes
2
answers
967
views
Example where the posterior from Jags and Stan are really different and have real impacts on decisions using the model
I have seen many people claiming Stan is "much better" than JAGS, meaning roughly this: "although Jags is much faster, the quality of the samples is worse. So it's worth waiting for the ...