Relating to the R bindings for mc-stan
Questions tagged [rstan]
41 questions
15
votes
4 answers
How best to deal with a left-censored predictor (because of detection limits) in a linear model?
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 of my predictors is left-censored because it falls below the detection limit for a…

mkt
- 11,770
- 9
- 51
- 125
6
votes
1 answer
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 typically use the lme4 package in R (maximum…

Dylan_Gomes
- 177
- 12
5
votes
2 answers
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 proportions (i.e., $\frac{n_1}{N_1}$ -…

Akira Murakami
- 263
- 2
- 9
4
votes
1 answer
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…

user3322865
- 41
- 2
3
votes
1 answer
Nonlinear sin model with brms
I try to fit sin function with brms using next code:
library(tidyverse)
library(brms)
N <- 100
x <- seq(0, 10, length.out = N)
e <- rnorm(N)
y <- 7 * sin(2.5 * x) + e
inp_data <- tibble(x, y)
plot(inp_data, type = 'l')
priors <- prior(normal(7,…

user2579566
- 174
- 1
- 7
3
votes
1 answer
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., biomass for each family) and in some sites no families…

Jess
- 33
- 1
- 3
3
votes
0 answers
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 those who like bayes factors for these purposes.
I…

BKV
- 380
- 2
- 10
3
votes
1 answer
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
We default to reporting 90% intervals rather than…

BKV
- 380
- 2
- 10
2
votes
0 answers
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 studies. I have a data set with several predictors…

ivanJ
- 21
- 1
2
votes
2 answers
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 model's predictive accuracy with the remaining…

Dylan_Gomes
- 177
- 12
2
votes
2 answers
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.
# Dataset prep
non_zero <- rbinom(1000, 1, 0.1)
g_vals <- rgamma(n = 1000,…

Srivatsa Srinath
- 61
- 6
2
votes
1 answer
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$, with parameters $m_i$ (the number of trials)…

The Pointer
- 1,064
- 13
- 35
2
votes
0 answers
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 parameters. Something like this:
data {
int…

user2089357
- 448
- 2
- 9
1
vote
1 answer
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
\\ \sigma^2 \sim Inv-Gamma(0.001,…

John
- 11
- 1
1
vote
1 answer
Help with rstan models
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 continuous count) according to Orders (3 different discret orders) and Time (continuous).…

chippycentra
- 193
- 6