Skip to main content

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
0 answers
20 views

What is the difference between hierarchical modeling and setting a (fixed) prior on a parameter?

I was reading through Chapter 11 of Data Analysis using Regression & Multilevel Models, and was confused by a slight variation of a simple hierarchical model posed in the text. Lets say I have a ...
Arvind's user avatar
  • 11
2 votes
0 answers
67 views

Can an outcome variable be used twice in the same model?

When is it appropriate to use the same outcome variable in two likelihoods in the same model framework? Here is a specific example: ...
Benny Borremans's user avatar
1 vote
0 answers
29 views

Inconsistent posterior from hierarchical survival model

I asked about this question on Stan forum but no one replied so dual posting here. I'd really appreciate some insight, as I'm completely stuck. I’m trying to do hierarchical survival modeling using ...
Ville's user avatar
  • 81
1 vote
0 answers
51 views

How could I fit a model of a non-homogeneous Poisson process in STAN? [closed]

I have some data $t_1, t_2, ..., t_n$ where $0 < t_i < T$ for all $t_i$. I assume that this has been generated by an inhomogeneous Poisson process with parameter $\lambda(t)$ defined again for $...
user1747134's user avatar
2 votes
1 answer
83 views

Can you specify correlated coefficients in Stan models?

Closest question I could find to mine was this one, which doesn't cover it. Is it possible to specify a correlation between two parameters in a Stan model? Consider a linear regression specified by: $$...
Corned Beef Hash Map's user avatar
0 votes
0 answers
13 views

Using PCA to check if parameters simulated from a hierarchical Bayesian model are close to real parameters

I have a hierarchical Bayesian model that learns a 5-parameter function for each of the N participants. The priors on each of the 5 parameters are parameterized by a scale parameter, so, it also ...
vishu's user avatar
  • 111
0 votes
0 answers
17 views

Lotka-Volterra ordinary differential equation model to describe oscillations in a single observed entity

Background The Lotka-Volterra model is the starting point for any model of ecological dynamics. It can be described as a set of two ordinary differential equations (ODEs) with varying complexity. ...
Luka Seamus Wright's user avatar
3 votes
1 answer
126 views

Choosing Bayesian Priors [duplicate]

I am fairly new to Bayesian Modeling, however I am experimenting with such framework in order to produce several estimates. The part I am struggling the most with is the selection of prior ...
Marco De Virgilis's user avatar
1 vote
1 answer
18 views

Efficient construction of correlation matrix—serial correlation

Given $\rho$, is there a way to efficiently construct this matrix (i.e., as a product of matrices, rather than using a for loop)? $$ \Sigma = \begin{pmatrix} 1 & \rho & \rho^2 &\cdots &...
veloskaraptor's user avatar
0 votes
0 answers
59 views

Why are my random effects and variance zero?

I'm trying to implement a logistic regression model with random effects and interactions. For some reason, when I remove an interaction between a parameter and a random effect parameter (Player and ...
Jethro R. Lee's user avatar
1 vote
0 answers
41 views

Model test sensitivity to ability

I have a set of tests and a population of agents whose ability I want to assess. Each agent has taken some of the tests. The agents have no memory of the tests they have taken, so each time an agent ...
Epimetheus's user avatar
1 vote
0 answers
54 views

Bayesian model with maybe-missing data

Suppose we have data that come from a normal distribution with unknown $\mu$ and $\sigma$ parameters. The twist is that each value is missing with the given probability $p$, i.e. we observe a vector ...
Adam Ryczkowski's user avatar
1 vote
0 answers
60 views

Two different methods to plot residuals with rstan but two different distributions [closed]

The following is the first exercice of chapter 5 from the Book 'Bayesian Statistical Modeling with Stan, R and Python' of Kentaro Matsuura, 2023. I am fitting a bayesian linear model in rstan and I ...
lulufofo's user avatar
  • 472
1 vote
2 answers
31 views

Incorporating neighboring years in multilevel model, estimated in Stan using brms

I am estimating a multilevel model in Stan, using the brms package. Specifically, I am estimating a model of the following form: m1 <- brm(y ~ 1 + (1 | year)) ...
user2018396's user avatar
2 votes
0 answers
31 views

How do I evaluate correlation of model parameters using MCMC posterior samples from a rstan fit?

Is there a better way to do so than simply by taking posterior parameter estimates and calculating the Spearman or Pearson correlation between them? Anything specific to having posterior samples from ...
thlpswm's user avatar
  • 21
0 votes
0 answers
25 views

Defining parameters so that they obey multiple constraints

I'd like to define parameters $\beta_i$ for $i=1,\ldots,I$ for a problem so that they automatically obey some constraints. The constraints are: $\sum_{i=1,\ldots,I} w_i \beta_i = c_1$ and $\sum_{i=1,\...
Björn's user avatar
  • 34.2k
2 votes
0 answers
106 views

Probability that $\beta_A$ > $\beta_B$ using the posterior distributions directly

Suppose a regression coefficient was estimated in sample A (from country A) through a Bayesian linear regression model. The resulting posterior distribution, comprising 10,000 simulations, was ...
Jacob's user avatar
  • 540
3 votes
2 answers
109 views

In Bayesian linear regression Advantages of predictive posterior compared to posterior of model coefficients

In Bayesian linear regression, if we want to get confidence intervals for predictions of a new observation. I was thinking of the following two options. Use the quantiles from samples sampled from ...
Dylan Dijk's user avatar
2 votes
0 answers
75 views

Generalized Difference in Differences model: time*group interaction contradicts lift

I've constructed a Bayesian Generalized Difference in Differences model. I model an intercept as well as three coefficients; one for treatment_group assignment, one for post-start period, and one for ...
jbuddy_13's user avatar
  • 3,386
0 votes
0 answers
16 views

Intermediate variables in Bayesian model for binomial data

Let us assume we have the data modeled $D|\pi\sim Binomial (N,\pi)$, where we assume $N$ is given throughout. We also have that $\pi|\theta \sim V( \theta )$ where $V$ is a known distribution and $\...
Jesús A. Piñera's user avatar
0 votes
1 answer
33 views

Modeling simple longitudinal data, unknown trend

Suppose I have many sensors recording a certain measure at discrete times (not too many times, something around 20/30 max). I want to get an idea of the average trend of the measure over time without ...
golra's user avatar
  • 3
0 votes
1 answer
136 views

How can I solve identifiability problems in my STAN estimation?

So I am trying to validate my STAN model before using real data and am having some trouble estimating parameters separately. My data structure contains count data with people on the rows, and test ...
Gregtt's user avatar
  • 1
2 votes
1 answer
262 views

How to model a combination of measurement error and missing data in R and Stan

The data Consider some simulated data: ...
Luka Seamus Wright's user avatar
1 vote
1 answer
76 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 ...
compbiostats's user avatar
  • 1,589
1 vote
0 answers
50 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 ...
Schnappiii's user avatar
1 vote
0 answers
129 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 ...
Alice's user avatar
  • 11
1 vote
0 answers
49 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 ...
jbuddy_13's user avatar
  • 3,386
1 vote
0 answers
171 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 ...
geom_na's user avatar
  • 151
0 votes
0 answers
64 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 ...
Oct's user avatar
  • 1
1 vote
0 answers
24 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 ...
Linda's user avatar
  • 11
0 votes
0 answers
68 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 ...
salva's user avatar
  • 31
1 vote
0 answers
127 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 ...
Sara's user avatar
  • 11
0 votes
1 answer
25 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 ...
Rodolpho's user avatar
1 vote
1 answer
50 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 ...
Nicolas Bourbaki's user avatar
1 vote
1 answer
142 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 ...
Pame's user avatar
  • 331
0 votes
1 answer
154 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: ...
atmo's user avatar
  • 21
1 vote
0 answers
198 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 ...
kat's user avatar
  • 21
1 vote
0 answers
121 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 ...
Jason Hawkins's user avatar
2 votes
1 answer
58 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 ...
Lefty's user avatar
  • 499
1 vote
1 answer
403 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 ...
MGonzalez's user avatar
1 vote
1 answer
412 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&...
pachadotdev's user avatar
0 votes
0 answers
448 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)$ $\...
Blain Waan's user avatar
  • 3,605
1 vote
1 answer
127 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 ...
Nip's user avatar
  • 561
2 votes
1 answer
106 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 ...
qdread's user avatar
  • 295
11 votes
1 answer
859 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 ...
user_15's user avatar
  • 185
1 vote
1 answer
126 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 \\ \...
John's user avatar
  • 11
0 votes
0 answers
396 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, ...
bschneidr's user avatar
  • 497
0 votes
0 answers
25 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 ...
janfreyberg's user avatar
1 vote
1 answer
161 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 ...
chippycentra's user avatar
2 votes
1 answer
428 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 ...
PitPartizan's user avatar

1
2 3 4 5 6