# Questions tagged [stan]

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

242 questions
Filter by
Sorted by
Tagged with
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
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
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
13 views

• 3,395
1 vote
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
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
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
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
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
60 views

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
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 ...
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
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 ...
1 vote
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
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
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
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 ...
• 69
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 ... 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 ...
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 ... 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
493 views

### Eliminating divergent transitions in Stan

I have the following dataset - ...
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
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 ...
• 523
1 vote
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
158 views

### Finite Binomial mixture model

I have a finite Binomial mixture model coded up in stan as below: ...
1 vote
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
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 ...
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
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