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
1answer
29 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 ...
1
vote
0answers
8 views

Plot of the LC50 Curve in R using ggplot2 with estimates obtained in the stan [closed]

I'm trying to make the following graphic below in ggplot2. See that I am adjusting a logistic regression model under the Bayesian approach using the stan package. data: https://drive.google.com/file/d/...
0
votes
0answers
16 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
0answers
12 views

Hierarchical Model for ragged/ unbalanced data (in STAN)

(I'm fairly new to Bayesian modelling please forgive me any minor accidents in my questions) I'm trying to model a data set in STAN, but don't understand why I get large no. divergent transitions. The ...
0
votes
0answers
18 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 ...
3
votes
0answers
43 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 ...
0
votes
0answers
15 views

How to implement a default prior in a stan_lmer() model?

I have found Rouder and Morey (2012) suggesting a default prior of cauchy(0,1). I would like to implement this in a linear mixed effects model I’m computing using stan_lmer(). However I have both ...
0
votes
0answers
19 views

Typical set clarification

I was reading more about the use of typical sets when it comes to MCMC methods, like this post by the Stan documentation. Unfortunately, I am confused by several points: One example I have seen ...
1
vote
0answers
44 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 ...
0
votes
1answer
19 views

Specifying specific priors for a correlation matrix via Stan

I'm trying to estimate a correlation matrix for a model where I already have a sense of the values of the off-diagonals based on existing studies. I'm quite new to Bayesian analysis so trying to learn ...
1
vote
0answers
21 views

Structuring Composed Bayesian Programs

I am considering writing some stan code to predict soccer game outcomes. More specifically, I thought that modelling the two halves of a game separately and then combining them would be an interesting ...
1
vote
0answers
75 views

Choosing a prior for the intercept in a logistic regression with increased -INF probability?

I am trying to fit a simple logistic regression of the kind: n ~ binomial(N, theta) theta = inv_logit( a + x * b ) where x is either 0 or 1 depending if a ...
2
votes
0answers
71 views

How to incorporate multiple likelihoods in a probabilistic graphical model with Stan?

Data composition: In beta testing of a video game, users were assigned tasks in a many-to-many relationship. At the end of every day, users were asked to self evaluate (for each task) whether they ...
0
votes
1answer
64 views

R Stan: Rejecting initial value error only with real data, not with simulated data

I am trying to fit a non-linear function to a dataset using Stan and R. I tested my model with a simulated dataset. It works nicely. However, as soon as I use real data that is formatted exactly the ...
3
votes
1answer
39 views

How to interpret the univariate Fisher's noncentral hypergeometric density PMF?

This is my first time posting so I apologize in advance for any errors! I am struggling to understand the probability mass function (PMF) of the Fisher's noncentral hypergeometric distribution, which ...
-1
votes
2answers
20 views

Stan syntax, arrays versus integers? [closed]

I'm new to STAN, and on the job I've been given some sample training code. ...
4
votes
1answer
82 views

Finite Beta mixture model in stan — mixture components not identified

I'm trying to model data $0 < Y_i < 1$ with a finite mixture of Beta components. To do this, I've adapted the code given in section 5.3 of the Stan manual. Instead of (log)normal priors, I am ...
1
vote
0answers
16 views

Generalised linear mixed model with Kent distribution family

I am working with spherical directional data. I need to estimate the parameters of the Kent distribution family. The data also has uniformly distributed noise. This paper describes similar problem ...
1
vote
1answer
40 views

Can divergent transitions signify that I am trying to fit too complex of a model / overfitting?

Divergent transitions are explained here (1) in the stan docs. They occur when the posterior has curvature that is varying too much. My thought was that maybe the posterior would vary a lot in regions ...
0
votes
0answers
19 views

Best way to get a single sequence of states using Viterbi algorithm in Stan/R

I am writing this up because it seems like there should be a standard, easy way to do this and I just haven't found it. I wrote up my Viterbi algorithm in Stan as shown here in the Stan User's Guide, ...
1
vote
1answer
74 views

Training a Bernoulli model using probabilities as inputs

I'm using two methods to train a Bernoulli model, and am trying to understand why they are not yielding similar results. For both methods, I have a length $N$ array of probabilities $\{\hat{y}^{(n)}\}...
1
vote
0answers
33 views

Marginalizing a time-series model in Stan

I'm trying to implement the following model in Stan $$ \theta[i] \thicksim Normal(0,1) \\ b[k] \thicksim Uniform(0.0, 2.5) \\ a[k] \thicksim Normal(0,1) \\ guess[k] \thicksim Uniform(0.0, 0.5) \\ ...
0
votes
0answers
37 views

Specifying several independent priors in stan_glm() in R

I am using the function stan_glm() in R. I am using 4 predictor variables and I want to specify a univariate independent prior for each regression parameter. Right ...
1
vote
0answers
17 views

How to model repeated measurements with the same outcome in a Bayesian framework?

Can't think of a more accurate title, so I'll illustrate the problem with an example. I want to record temperature using cheap noisy sensors. I also have recordings from a gold-standard reference ...
4
votes
0answers
38 views

Why does Quadratic (Normal/Laplace) Approximation fail on multilevel models?

In Statistical Rethinking, 2nd Edition, section 13.1, Richard McElreath says: Why doesn’t simple quadratic approximation, using for example quap, work with multilevel models? When a prior is itself a ...
2
votes
1answer
75 views

Interpretation of coefficients in mixed-effects model with circular response?

I have a dataset from an experiment where wild ants were surveyed continuously for 24 hours under a number of temperature treatments (chambers). Whenever an ant was observed, the species of the ant ...
1
vote
1answer
248 views

brms intercept only model runs very slow

I am trying to learn brms package for multilevel modeling. A reproducible code is as below: ...
1
vote
0answers
16 views

hierachical modeling of body temperature data to design thresholds for CoVID-19 testing

I am working through designing an approach to identifying temperature thresholds for CoVID-19 testing. I thought I would post my problem and see if any had recommendations. Basically, I have a large ...
0
votes
0answers
26 views

elpd_diff and se_diff

My comparision result from RSTAN is as below: elpd_diff se_diff fit2 0.0 0.0 fit4 0.0 0.0 fit3 -0.9 0.3 fit1 -1.8 2.7 ...
5
votes
1answer
79 views

Matt's trick (reparametrization) makes my models slower, not faster

I am currently programming a hierarchical model in Stan. Following the advice from section 22.7 from the Stan manual, I reparametrized my model so it samples the individual differences from a $N(0,1)$ ...
2
votes
0answers
27 views

Intuitive explanation of PSIS-LOO cross-validation

I've been using Pareto-smoothed importance sampling (PSIS-LOO) cross-validation for diagnosis and comparing Bayesian models fitted with Stan/brms for a while now. ...
0
votes
1answer
20 views

estimate distribution of results from one experiment based on earlier experiment

I have results from an experiment where I counted how many times I got a positive result from independent bernoulli trials. I can estimate the uncertainity on the rate, and get 2.5%-97.5% CI for the ...
0
votes
0answers
21 views

Coxme/Surv_Stan model to Quantify Individual Consistency/Repeatability

I am not sure if I am barking up the wrong tree here. Briefly, I have experimental data with 2 trials repeated across 25 subjects (individuals). End goal: to establish some measure of consistency ...
1
vote
1answer
25 views

How do you generate data that can be used for a binomial family stan_glmer model with random effects?

I am wondering how I can generate binomial sample data that can be used for a stan_glmer random effects model. For example, is this a correct example? ...
3
votes
2answers
131 views

Are Jacobian adjustments necessary when the target parameter is a difference between two parameters in Stan?

[Note on cross-posting: This question has now been posted on the Stan Forums as well.] I want to model the index called Delta P (e.g., p.144 of this paper), which is basically a difference between two ...
4
votes
1answer
138 views

What is the PDF of a Normal convolved with a Laplace

I'd like to see if using Stan or similar I can successfully model Laplace noise added to data through the use of a convolved Normal-Laplace distribution and MCMC sampling. In the literature I can only ...
2
votes
1answer
77 views

Structural equation models without circular definition of latent variables

I'm trying to perform Bayesian structural equation modeling in Python and PyMC3, but I think the problem is similar for most probabilistic progamming languages, include JAGS, Stan, etc. SEMs are ...
0
votes
1answer
25 views

Define log likelihood for CJS model in Stan

FYI, I'm new to Stan and this is my first question here. I'm unsure how to calculate the log likelihood for a Cormack-Jolley-Seber model in Stan. Can anyone help me with this? Background: I've made ...
1
vote
1answer
74 views

Bayesian matrix factorization

I am working with Bayesian matrix factorization using the MovieLens database. Data consist of a matrix $n \times d$ of $n=943$ users and $d=1682$ movies where users assign a rate (1-5) to movies. ...
0
votes
0answers
53 views

Correlated random slopes in brms

I am experiencing a problem in fitting a brms model to count data. The model specification below results in a fit with a relatively low ESS (~1000-1200) given 4000 post-warmup iterations. This appears ...
1
vote
1answer
45 views

Visualizing the variable DAG in a stan / brms model

I would like to visualize the relationships between variables in the brms / stan models I write. I could make these myself for each model, but I'm hoping there's a package to generate them ...
0
votes
1answer
68 views

Sum of N binomials with Stan

I'm having trouble implementing a sum of $N$ binomials (and a poisson distribution) with Stan. Observed data is $(y_i)$ for $1 \leq i \leq M$, and $(x_{ij})$ for $1 \leq i \leq M$, $1 \leq j \leq N$. ...
1
vote
1answer
42 views

Sample from the posterior of normal model using rstan?

I have a very simple Bayesian model $y_j \mid \mu ,\sigma^2 \sim N(\mu,\sigma^2)$, $\mu \sim N(0,100)$, $\sigma \sim InvGamma(0.01,0.01)$. I am try to sample from the posterior using ...
0
votes
1answer
33 views

Meaning of log-fit_ratio lnω in rstanarm AOV output

In the output of rstanarm's stan_aov() one of the parameters is the so-called log-fit_ratio, which, in one of the vignettes, is ...
1
vote
1answer
31 views

linear regression requirements in Bayesian stats

In Frequentist framework when someone runs a linear model has to check the assumptions. There is a need to check these assumptions in Bayesian Linear Regression too? Thanks
0
votes
0answers
27 views

R package for Bayesian generalized non-linear model

I would like to know if it is possible to fit the Lee-Carter model in a Bayesian setting. This model is used to forecast population mortality dynamics and has the following form: $$ log(\mu_{xt})=\...
2
votes
0answers
49 views

Generalized regression with both additive and multiplicative errors

For measurements of chemical concentrations, it is often the case that the error in the data increases as the true (or estimated) concentration increases. That is, the error is multiplicative and has ...
0
votes
0answers
41 views

Fitting Bayesian Hierarchical Models in rSTAN

The model I have is $$ \begin{align*} y_{ij} & \sim Normal\left(\alpha_j + \beta x_i, \sigma^2\right)\\ \alpha_j &\sim Normal\left(\gamma_0 + \gamma_1 u_j, \tau^2\right) \end{align*} $$ Where $...
0
votes
1answer
41 views

Does large Rhat for one parameter mean that marginal posterior for another cannot be trusted?

I'm using Stan to fit a model on some simulated data. The model has several parameters and one of them, say $\alpha$, has a large Gelman-Rubin statistic value, $\hat{R} > 1.1$. This is however a ...
0
votes
2answers
60 views

Pick a prior for my bayesian generalised linear model with binary outcomes

I need help in my choice of a prior for a bayesian model. I have data from a set of participants responding to a set of yes/no questions. Answers are correct or incorrect. I suspect some questions ...

1
2 3 4 5