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
15 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
33 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
10 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
14 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
2 votes
1 answer
99 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
16 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
49 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
45 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
50 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
  • 482
1 vote
1 answer
24 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
0 votes
0 answers
7 views

Criterion to assign individuals to clusters in bayesian mixed model with distribution of probabilities

I have a dataset with a set of individuals indexed by $i = \{ 1, ..., N \}$, and I make a number of measuremenets under two conditions for each individual to measure the effect $\beta$ of my ...
dherrera's user avatar
  • 1,268
2 votes
0 answers
26 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
23 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
  • 32.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
0 votes
0 answers
32 views

Cluster based on random effects, STAN

I have a problem where I measure repeated responses in condition A and in condition B for a set of individuals $i=1,...,n$. I am interested in learning about the effect of the condition in the ...
dherrera's user avatar
  • 1,268
0 votes
0 answers
10 views

Arithmetic using summary means of the MCMC chains, differ from when I do the arithmetic directly using each row of the MCMC chains

I am trying to calculate the 'absolute risk difference' and 'needed to treat' (NNT). NNT is 1/(absolute risk difference) where the absolute risk difference is just the rate of an event in one ...
sol libes's user avatar
0 votes
0 answers
40 views

Associative mapping in Stan using canonical regression approach

I've got 19 independent plant observations that consist of roughly 300 binary (dichotomous) genetic marker sightings at particular loci and 30 continuous concentrations of different types of ...
Adam Ryczkowski's user avatar
0 votes
0 answers
44 views

Estimation with Random Walk 2 Priors

In (https://becarioprecario.bitbucket.io/inla-gitbook/ch-smoothing.html#sec:smoothterms), they show an example of a Random Walk 2 (RW2) prior being used on the LIDAR dataset. For the model set-up, we ...
user1848065's user avatar
3 votes
2 answers
95 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
0 votes
0 answers
44 views

Parameters Correlation in STAN

I am fitting a simple normal distribution in stan through R. The distribution depends on two parameters, $\mu$ and $\sigma$. Here the sample code: ...
Marco De Virgilis's user avatar
2 votes
0 answers
72 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,020
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
32 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
100 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
211 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
63 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,557
1 vote
0 answers
46 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
100 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,020
1 vote
0 answers
149 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
58 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
23 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
67 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
120 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
45 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
132 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
  • 321
0 votes
1 answer
137 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
175 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
57 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
  • 479
1 vote
1 answer
372 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
373 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
399 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,595
1 vote
1 answer
126 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
99 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
784 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
117 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
366 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
  • 442

1
2 3 4 5 6