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
0 votes
0 answers
12 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 ...
  • 249
0 votes
1 answer
39 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: ...
  • 11
1 vote
0 answers
34 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 ...
  • 21
0 votes
0 answers
13 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} = \...
  • 1,728
0 votes
0 answers
66 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 ...
  • 381
1 vote
0 answers
30 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
51 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 ...
  • 255
0 votes
1 answer
97 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
72 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
120 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)$ $\...
  • 3,395
1 vote
1 answer
55 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 ...
  • 541
1 vote
1 answer
56 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 ...
  • 165
0 votes
0 answers
17 views

Estimating Proportions with Uncertainty from the American Community Survey

I'm interested in estimating Bayesian statistics related to some proportions from the American Community Survey (ACS). The American Community Survey has several useful handbooks here and two pertinent ...
  • 141
9 votes
1 answer
286 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 ...
  • 125
0 votes
0 answers
195 views

fit a model with a skewed distribution response with brms R package

I have some basics with STAN, and would like to move to the brms package for data analysis. I would like to correlate a metric to several variable (6 traits) and I also included 2 random effects. I ...
  • 1
1 vote
1 answer
60 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 \\ \...
  • 11
0 votes
0 answers
30 views

Bayesian paired samples difference estimate

Let's say I have some observational clinical data of $N$ patients. They have a score (from 1 to 7) which is their level of symptom severity (1 being no symptoms, 7 being extremely symptomatic) at ...
0 votes
0 answers
9 views

How to properly state a change in the highest distribution interval width?

Dear Bayesian modelers, could you help me with some lingo? Consider that we fit a Bayesian regression, really generic, y ~ alpha + beta*x. Let's focus on beta, the regression slope, which supposedly ...
0 votes
0 answers
130 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, ...
  • 247
0 votes
0 answers
21 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
66 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
152 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
134 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 ...
  • 460
1 vote
1 answer
289 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
74 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
18 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 ...
  • 1,691
0 votes
1 answer
74 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
28 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)$$ $$ \...
2 votes
1 answer
427 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 ...
  • 21
1 vote
0 answers
231 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
143 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 ...
  • 21
0 votes
1 answer
87 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 ...
  • 3
1 vote
1 answer
74 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 ...
  • 11
1 vote
1 answer
388 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?
  • 113
1 vote
0 answers
100 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 ...
  • 121
6 votes
1 answer
769 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
62 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 ...
user avatar
2 votes
1 answer
159 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
634 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 ...
user avatar
2 votes
0 answers
15 views

Method for Predicting Longitudinal Diagnostic Switching and Instability

Context Within my field (neuropsychology), there is a well-known issue for some individuals to have very unstable diagnoses overtime. My area of interest is in dementia where the ideal diagnostic ...
  • 786
1 vote
1 answer
493 views

Eliminating divergent transitions in Stan

I have the following dataset - ...
0 votes
1 answer
320 views

How to extract predicted values from stan_lmer()

I fitted a stan_lmer model and tried to extract predicted (predict() function) but R suggested me to use posterior_predict() but cannot at this point plot the predicted vs observed plot, as I have a ...
  • 11
1 vote
0 answers
28 views

Using discrete random variable as index in JAGS

I have a model that can be distilled into, $$d \sim U(1,20)$$ $$Y_t \sim N(X_{t-d},\sigma^2)$$ for two time series that have observations from $Y_{1,..,t}$ and $X_{1,...,t}$. I'm trying to code it up ...
1 vote
2 answers
501 views

Why do Pareto/NBD models require custom likelihood functions in PyMC3 and Stan?

I'm interested in Bayesian modeling of customer lifetime value (CLV), preferably via PyMC3. I've found that research in this area started mid-to-late 1900's and has remained active since. It would ...
  • 1,728
2 votes
1 answer
158 views

Finite Binomial mixture model

I have a finite Binomial mixture model coded up in stan as below: ...
1 vote
1 answer
99 views

Why are my predictied values from a Bayesian AR(1) model lagging behind the data?

Summary: I have simulated some data on an AR(1) process in R and fit the model in Stan. When plotting the predictions, the predicted values tend to lag behind the true values. Why is this? Detail I am ...
  • 125
0 votes
0 answers
180 views

Bayesian model validation LOOCV

I am fitting a Bayesian logistic regression using Stan in R. My model will be used for drawing inference rather than prediction. My dataset is very small (around 50 observations) so I am planning on ...
0 votes
0 answers
61 views

How do I implement a default prior of cauchy(0,1) in rstanarm?

What I intend to do is use a default prior on my coefficients, and then to compute Bayes Factors for those coefficients. Rouder and Morey (2012) say: "When using the Cauchy prior, s describes the ...
  • 1,691
4 votes
0 answers
50 views

Priors as Controls : Bayesian Regression

I have a general question about Bayesian Regression Modeling and how a prior might be used as a means to control for (close to) simultaneous events. I often face a situation where I have a time series ...
  • 7,790
2 votes
0 answers
101 views

How to define informative priors from previous studies using stan_glm?

I am trying to develop a linear regression model for estimating stature from handprint measurements. I would like to employ the Bayesian approach and define informative priors from the previous ...
  • 21

1
2 3 4 5