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
5 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
10 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 ...
0
votes
1answer
12 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? ...
2
votes
0answers
40 views

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

I want to model the index called Delta P (e.g., p.144 of this paper), which is basically a difference between two proportions (i.e., $\frac{n_1}{N_1}$ - $\frac{n_2}{N_2}$), as a function of a ...
4
votes
1answer
105 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
26 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
14 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
60 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
26 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
19 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
32 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
24 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
21 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
26 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
23 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
23 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
28 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
29 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
39 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
25 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
18 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
41 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
48 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
28 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 ...
2
votes
1answer
94 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 ...
5
votes
1answer
666 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
52 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
265 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 ...
0
votes
0answers
45 views

Where is Stan sampling from?

I found a link that shows a simple Stan model for linear regression: ...
0
votes
0answers
14 views

Most likely domain element in probabalistic forward model

Suppose I have some probablistic forward model $m: T \rightarrow U$, and that the model is then conditioned on observations $u_1, \dots, u_N$ from U. [More specifically, by 'probabalistic model' here,...
0
votes
1answer
39 views

When to exponentiate: the mean of the chain or at every step in the chain?

I am interested in when it is best to exponentiate a difference in log-odds Here is a sample problem in the stan language, three groups of forty binary observations, group 1 with hit probability = 0....
2
votes
1answer
118 views

Why does Stan initialize an MCMC chain with a random value generated uniformly from [-2, 2] instead of a random value generated from the prior?

From Stan reference, The default is to randomly generate initial values between -2 and 2 on the unconstrained support It seems to me that it makes more sense to randomly generate initial values ...
2
votes
1answer
342 views

Low effective sample size but good R-hat is this a problem?

I am using Stan (Hamiltonian Monte-Carlo) to run a highly paramaterized model. One of the parameters in particular has a very low effective sample size (n_eff < .10*number of retained draws), but ...
0
votes
0answers
79 views

Multilevel Negative Binomial fails with MLE

I have a pretty complex multilevel neg. binomial regression that does not converge when using a regular MLE (but from what I understand, when dealing with multilevel models, MLE is not regular, per se)...
1
vote
1answer
92 views

How to include seasonal effects into the system matrices of a state space model

I am working on learning state space models and am leaning heavily on this very helpful documentation. However, I'm really confused about the best way to include both a seasonal effect and dynamic ...
0
votes
0answers
33 views

Translate data into parameter coefficients - Bayesian regression

I Have a data set of accident rates from a population in which I'm attempting to identify which factors have the most effect on how many injuries occur from each accident. Since I am trying to ...
7
votes
1answer
81 views

Is it appropriate to estimate a random slope without estimating the overall mean slope?

I am trying to estimate whether there are differences in how individuals in different cities (my grouping variable) respond to a few predictor variables. So, in practice, I am interested in learning ...
1
vote
0answers
145 views

Problems estimating a “Bayesian version of FIML”

I am anticipating that my question exposes some basic ignorance about how mcmc works, but here we go: In an attempt to deal with missing data I am trying to simultaneously estimate a regression model ...
1
vote
1answer
61 views

Estimating the standard deviation of Bayesian regression

When developing a Bayesian multiple linear regression model, how do you estimate the parameters of the standard deviation? From my understanding, the standard deviation is associated with each ...
0
votes
1answer
666 views

Long data format for Mixed linear modeling

I have a data set from an experiment with two conditions: a control condition, and a testing condition. It's an experiment performed in pairs. Each condition was undertaken by 20 pairs of subjects (...
1
vote
1answer
65 views

Generalization performance in Bayesian errors-in-covariates model

I'm working on a model with this basic structure: The square nodes are data, and the round nodes are parameters and/or latent variables. The left plate represents the "training observations" we ...
1
vote
1answer
99 views

Stan: output some (but not all) intermediate variables of interest [closed]

I am a newcomer to Stan but quite a Stan enthusiast by now. Currently I am working on a Stan application involving a somewhat complex computation with a bunch of intermediate variables of which I ...
1
vote
2answers
127 views

NUTS Drawing samples from slice sampler; how to keep bounds on log scale?

I'm currently working to adapt the No U-Turn Sampler from this paper for a model I'm working on. The No-U Turn sampler augments the typical hamiltonian system by incorporating a slice variable $u$ ...
0
votes
1answer
150 views

Should weights be applied in generated quantities block in stan?

I want to do predictions via generated quantities block in stan. I have two questions: Should the weights be applied again in the generated quantities block in addition to the likelihood in the ...
0
votes
1answer
93 views

How to use a G-Wishart distribution in stan

I would like to use the following kind of prior in a Stan simulation $$ f_{K \mid G} (k \mid g) = \frac{1}{I_g(b,D)}|k|^{\frac{b-2}{2}} \exp \biggl \{ -\frac{1}{2} \text{tr} (Dk) \biggr \}\mathbb{1}_{...
2
votes
2answers
205 views

Timeseries with multiplicative noise in Stan

Say we have a monthly time series $y_t \geq 0$ dominated by seasonality, where the absolute differences from year to year are much smaller during low season. To avoid negative values and capture the ...
1
vote
1answer
223 views

GLM and implementation of Poisson regression model in R by hand

first of, this is not my school exercise but a given example that I'd like to convert from Stan to my own code. I am very much a pragmatic learner so doing this helps me a lot to visualize the problem....
6
votes
1answer
1k views

What is the purpose of “transformed variables” in Stan?

I find references to transformed values in the Stan Reference and User Guides, and example code but no clear tutorial explanation. I'd be grateful for a link. Michael Betancourt, in his Stan ...
1
vote
2answers
76 views

Two priors on the same parameter?

I received a text where the author was employing Stan language in order to show how to create a random walk with normally distributed parameters. His model had parameters $\mu_{t}$, ($1,2,...,T$), ...