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

Logistic regression via Stan, issues with data types?

I'm working on a Stan model that's effectively multiclass logistic regression. In my data, an event is observed and a classification assigned. Every day, this classification is reevaluated by experts ...
1
vote
0answers
38 views
+50

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
38 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
37 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
17 views

Stan syntax, arrays versus integers? [closed]

I'm new to STAN, and on the job I've been given some sample training code. ...
0
votes
0answers
23 views

STAN IRT via R programming, issue with parameter declaration? [migrated]

I'm following along with this official IRT w/ STAN tutorial. The details of the model are copied below: ...
4
votes
1answer
46 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
20 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
13 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
69 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
30 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
25 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 ...
3
votes
0answers
31 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
67 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
135 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
17 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
70 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
25 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
19 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
20 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
21 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
106 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
125 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
54 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
21 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
68 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
43 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
31 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
51 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
35 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
28 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
29 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
26 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
33 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
34 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
36 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
50 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 ...
0
votes
2answers
28 views

Stochastic process similar to poisson-process but where I can tune mu and sigma independently?

I've tried to find an answer to my question via Google, but without luck. Therefore I ask now here: Is there a stochastic process similar to the poisson-process, but for which I can tune mu and sigma ...
0
votes
0answers
19 views

Memory retention case study: modeling full individual differences using stan

I am currently working though the case studies in bayesian cognitive modeling book, specifically the memory retention chapter. I am trying to rework the https://github.com/stan-dev/example-models/blob/...
1
vote
0answers
45 views

The variance of Q in QR decomposition of linear model in rstanarm

I'm trying to understand this article "Estimating regularized linear models with rstanarm", but I'm having trouble with the section "Priors". As background, we are working with the linear model under ...
1
vote
1answer
19 views

Analysis of counts with changing rate of succes

I have a large number of locations, let's say they're stores. At each store, $N_{it} \sim Pois(n_i)$ people walk through the door each week. We know the $n_i$ for each location. Of the $N_{it}$, a ...
1
vote
0answers
57 views

Mixed model with panel data when some cases have constant responses (zero) over time

I have a panel data with about 300 units observed over a period of 4 weeks. In each week, I recorded a response that is a binary variable, y, for each unit of that week. For about 50% of the units, ...
2
votes
0answers
43 views

Computational time of a (fairly complex) GAM with ARMA structure in brms

I am fitting a model for time-series analysis of Wikipedia views with STAN through the brms package. I came up with a pretty good distributional model, which ...
3
votes
1answer
104 views

Why in Hamiltonian MCMC do we multiply the posterior distribution by the likelihood?

So maybe I am misunderstanding what the author is staying, but I am reading Chapter 14 of Kruschke's Doing Bayesian Analysis. I am reading about the software Stan and how it uses the Hamiltonian MCMC ...
7
votes
1answer
1k views

Divergent transitions in Stan

Intuitively, what does the warning "There were 214 divergent transitions after warmup." mean? I understand that the samples obtained are useless, and that increasing adapt_delta, and max_treedepth, ...
1
vote
1answer
60 views

Bayesian liability threshold model

Let $\bf{y}$ denote a vector of binary data, such as whether a group of individuals suffer from a particular disease, and let $\bf{X}$ denote a matrix of potential predictors, including an intercept ...
0
votes
1answer
357 views

Stan logistic regression with binary independent variables [closed]

I am developing my very first Stan (MCMC) model and naturally got hit by a problem. This is probably a very basic issue, but I did not find an answer in Stan documentation so asking your help now. My ...