Questions tagged [rstan]
Relating to the R bindings for mc-stan
45
questions
0
votes
1
answer
30
views
Title: How to fit a Frequentist Equivalent of Bayesian mixed-effects model with nlme or lme4 and obtain category-specific variances and intercepts?
I am interested in fitting a Bayesian mixed-effects model to my data using the brms package. My data includes three grouping variables (Category, BioRep, and TechRep), and I want to estimate category-...
2
votes
0
answers
98
views
Hurdle model for non-count continuous data with both positive and negative values
I am aiming to estimate a hurdle model (where being non-zero is the hurdle) in the vein of Cragg. My data is both positive and negative where the data reflects the difference between a value reported ...
1
vote
1
answer
26
views
Why am I getting negative means from a hierarchical clustering model fitted to binomial data using RStan
Apologies in advance - I'm new to Bayesian statistical methods and may not get all the terminology correct.
I am trying to run some Bayesian analysis on survey data using the rstan package in R but I'...
1
vote
0
answers
63
views
Quadratic regression with orthogonal polynomials vs. raw polynomials with QR decomposition
I'm using rstanarm to estimate random slopes for second-order polynomial coefficients. My model has the basic form:
...
0
votes
1
answer
134
views
CIs for random intercepts from gam and stan_gamm4 are similar, but those from gamm4 are not. why?
Question: how can one obtain a good confidence interval for the estimated random effects from gamm4?
Motivation: The example below, using binomial data with a random intercept, shows that estimated ...
0
votes
0
answers
363
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)$
$\...
1
vote
1
answer
105
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
\\ \...
1
vote
1
answer
128
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 ...
0
votes
1
answer
213
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 ...
0
votes
1
answer
260
views
Reporting guideline for bayesian using pd and ROPE
In the bayestestR articles, I came across the reporting guidelines that they recommend
“the effect of X has a probability of pd of being negative (Median = median, ...
1
vote
0
answers
391
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 ...
1
vote
0
answers
113
views
Find latent variable using rSTAN
I have the following simulated data:
...
0
votes
1
answer
612
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 ...
2
votes
0
answers
152
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
1
answer
725
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
2
answers
378
views
Cross validation on a single model (not model comparison)
I understand the method of cross validation to be to leave out some part of a dataset (whether that be one data point at a time = LOO, or subsets = K fold), and train the model on some data, test the ...
20
votes
4
answers
1k
views
How best to deal with a left-censored predictor (because of detection limits) in a multiple regression with interactions?
Context: I'm new to Bayesian stats and am trying to fit a multiple regression with rstan. All variables are continuous and there is no hierarchical structure.
One ...
2
votes
2
answers
1k
views
Need help understanding hurdle model specification and results interpretation
I am trying to use hurdle gamma model for one of my use cases, to handle a zero-inflated scenario. I have a very simple code creating dummy data with quite a few zeros.
...
5
votes
2
answers
770
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 ...
8
votes
1
answer
676
views
Why do model selection (AIC and LOO) outcomes differ between ML and bayesian approaches
I am interested in understanding whether my continuous data (dput code at bottom for reproducibility) are fit better by a linear model (Gaussian distribution) or a gamma distributed model.
I ...
1
vote
1
answer
245
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
0
answers
114
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
1
answer
104
views
the marginal likelihood of analytical result is different from that of bridge_sampler
I try to calculate the marginal likelihood of the example in the article " a tutorial on bridge sampling", which is estimating the marginal likelihood for a binomial model assuming a uniform prior on ...
1
vote
0
answers
70
views
RStan v.s. simple lm for multivariate regression [closed]
I want to fit a multivariate linear regression, with $Y_1, \dots,Y_4$ as the response and $X_1,\dots,X_n$ as the explanatory variables. $X_1$ and $X_2$ are two components of a mixture, and $X_3,\dots ,...
2
votes
1
answer
342
views
Parameter Updates in Stan
I am working on an example in which I have obtained parameter estimates using Stan.
In a real life scenario, I would receive more data every week. The data are covariates of a product which are used ...
5
votes
1
answer
2k
views
Why is a Gelman-Rubin diagnostic of < 1.1 considered acceptable?
In multiple sources a Gelman-Rubin MCMC convergence diagnostic of less than 1.1 is considered evidence that chains have converged.
For example in this thread:
https://stackoverflow.com/questions/...
3
votes
1
answer
381
views
Nonlinear sin model with brms
I try to fit sin function with brms using next code:
...
1
vote
1
answer
139
views
Forward algorithm for ZIP - Hidden Markov model
I'm trying to adjust a Zero Inflated Poisson Hidden Markov Model with Stan. For the Poisson-HMM in a past forum this setting was shown. see link.
While to adjust the ZIP with the classical theory is ...
1
vote
0
answers
598
views
Suggested noninformative hyperprior distributions?
I have a hierarchical model that includes a normal distribution and a beta distribution.
For the normal distribution, it has two parameters: $\mu$ and $\tau^2$. However, I want to implement ...
1
vote
1
answer
447
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
1
answer
125
views
Curved regression lines
I had already asked a similar question here, but I'm experiencing the same problem for a different data-set and for a different family of mixed models.
My response variable is a binary outcome of ...
0
votes
0
answers
146
views
Non-straight lines in random intercept random slope plots
I'm trying to see how boldness of individuals change over time. For this, I constructed a repeated measures random intercept random slope model with boldness scores (measured as latency to resume ...
0
votes
1
answer
139
views
Intercepts of repeated measures
I'm examining how boldness of individuals change with time. My data consists of individuals repeatedly measured across trials for boldness scores. First, I plotted each individual to see its mean and ...
0
votes
1
answer
52
views
how can this missing observation model be extended to include cases where sigma is a function of other variables?
Richard McElreath's blog entry Algebra and the Missing Oxen describes a simple missing observation model in RStan. At the end of the blog, he says it can be extended easily to cases in which the ...
1
vote
1
answer
978
views
performance issues with linear mixed model
I am fitting a linear mixed model
$y_{t} = \beta_0 + \beta_1x_{1t} + \beta_2x_{2t}+ \beta_{0i[t]} + \beta_{1i[t]}x_{1t} + \beta_{2i[t]}x_{2t} + \beta_{0j[t]} + \epsilon_t$
with ...
2
votes
1
answer
161
views
Modelling Parameter $r = \max\limits_{i = 1, \dots , 10} p_i - \min\limits_{i = 1, \dots , 10} p_i$ of Binomial Random Variable in Stan/RStan/R
I'm trying to use Stan and R to fit a model that, uhh, models the observed realisations $y_i = 16, 9, 10, 13, 19, 20, 18, 17, 35, 55$, which are from a binomial distributed random variable, say, $Y_i$,...
5
votes
1
answer
5k
views
hurdle model with non-zero gaussian distribution in R
I have biomass data (continuous response variable). If sufficient data is collected, the log(Biomass) follows a normal distribution. However, I am separating the overall biomass by family (i.e., ...
2
votes
1
answer
278
views
Obtaining effect size from "rstanarm" package's linear regression
In my study a control group (c) is pretested (pre.c) and post-tested (pos.c). Similarly a ...
3
votes
0
answers
77
views
Is there a way to use the brms function bayes_factor without having to refit models to not have prior samples?
In the brms package the function bayes_factor allows you to compare two models. Personally, I prefer the WAIC or LOO methods of comparing, but it is helpful to have both these and bayes factors for ...
0
votes
0
answers
20
views
Is this a sensible way to examine the effects of x on y for two different groups?
Let's say I have data from a number of brain regions in both teenagers and adults. I want to know if brain regions b1, b2, etc (selected based on theory) differ in their effect on a normally ...
3
votes
1
answer
1k
views
What exactly does it mean that a 90% Credible Interval is computationally stable?
I was reading the rstanarm documentation and came across this about its use of 90% intervals as the default. I was hoping someone might be able to provide some clarification.
Default 90% intervals
...
1
vote
1
answer
88
views
Stan - find dimensions of an object - lower and upper question [closed]
I have a bunch of objects (roughly rectangular) , for some of which I know what their dimesions - x, y, and ...
2
votes
0
answers
623
views
stan - 2 approaches to missing value imputation; which is better and why?
So, me and a colleague have to impute some data, x, given a categorical variable. We arrived at two different approaches:
a) as in the tutorial: split x into x_obs and x_mis, and treat x_mis as ...
2
votes
1
answer
955
views
Why does MCMCpack use normal priors when running Poisson regression?
I thought that since the conjugate prior of Poisson distribution is gamma, we needed to use that when assigning prior distributions to the beta coefficient. MCMCpack and rstanarm both specify a ...
1
vote
1
answer
231
views
How to add random walk in rstanarm [closed]
I have used rstanarm GLM model without the intercept like below in R
...