Questions tagged [rstan]

RStan is an API in R for the STAN programming language for Bayesian Statistical Inference.

Stan uses an R-like language for specifying statistical models, and has an R interface for compiling and running the markov chain analyses, and reporting the results back to R.

Links

299 questions
23
votes
0 answers

How to incorporate weights into the likelihood of a WinBUGS model?

I want to incorporate weights into the likelihood of a WINBUGS model to do what brms does with weights. The usual BUGS approaches to accomplish that for dnorm and dpois are not working for dbin. In brms, as paul.buerkner says here, that is…
Krantz
  • 1,424
  • 1
  • 12
  • 31
18
votes
2 answers

How to represent a categorical predictor rstan?

What is the proper way to format a categorical predictor to use in STAN? I cannot seem to input a categorical predictor as a normal factor variable, so what is the quickest way to transform a normal categorical variable such that Stan can accept…
goldisfine
  • 4,742
  • 11
  • 59
  • 83
10
votes
1 answer

How do I get standard errors of maximum-likelihood estimates in STAN?

I am using maximum-likelihood optimization in Stan, but unfortunately the optimizing() function doesn't report standard errors: > MLb4c <- optimizing(get_stanmodel(fitb4c), data = win.data, init = inits) STAN OPTIMIZATION COMMAND (LBFGS) init =…
Tomas
  • 57,621
  • 49
  • 238
  • 373
9
votes
5 answers

rstan C++14 error while installing (centos)

while installing rstan getting following error: Error in .shlib_internal(args) : C++14 standard requested but CXX14 is not defined from research got to know that C++14 compiler should be available. How to install the same while configuring R. …
Charvee Punia
  • 423
  • 1
  • 6
  • 17
9
votes
2 answers

How to use stan in rmarkdown

I would like to get the estimated coefficients of a model using rstan in an rnotebook I have the following stan chunk: ```{stan output.var="rats"} data { int N; int T; real x[T]; real y[N,T]; real xbar; } parameters { …
Alex
  • 2,603
  • 4
  • 40
  • 73
8
votes
3 answers

Plotting posterior parameter estimates from multiple models with bayesplot

I am using the great plotting library bayesplot to visualize posterior probability intervals from models I am estimating with rstanarm. I want to graphically compare draws from different models by getting the posterior intervals for coefficients…
gfgm
  • 3,627
  • 14
  • 34
5
votes
0 answers

sampling from posterior predictive distribution (stan vs inla)

I'm trying to implement functions from bayesplot package on a INLA object and a little unsure of how to draw from the posterior predictive distribution. I think I almost have it but rstan draws are more variable than the INLA ones. In rstan, using…
user63230
  • 4,095
  • 21
  • 43
5
votes
2 answers

Sampling from prior without running a separate model

I want to graph the histograms of parameter estimates from a stan model against the priors for those parameters. I have tried doing this by running a model in stan, graphing it with ggplot2, then overlaying an approximation of the prior distribution…
llewmills
  • 2,959
  • 3
  • 31
  • 58
5
votes
0 answers

How to efficiently parallelize brms::brm?

Problem summary I am fitting a brms::brm_multiple() model to a large dataset where missing data has been imputed using the mice package. The size of the dataset makes the use of parallel processing very desirable. However, it isn't clear to me how…
Will
  • 53
  • 8
5
votes
1 answer

RStan: Specifying a Three-Level Random Slopes Model?

I've been working on a three-level RStan model where repeated broadband measurements (year ID = yrid) are nested within local authorities (LA ID = laid), which are finally nested within regions (region ID = rnid). The (logged)dependent variable is…
Thirst for Knowledge
  • 1,606
  • 2
  • 26
  • 43
5
votes
3 answers

Mixed Pareto and Normal Stan model not working

I'm trying to learn Stan via rstan (since I'm familiar with R). I've tried running a simple mixed Pareto and Normal model. It compiles fine (as far as I can tell), but it fails to sample, giving me the error: "Initialization between (-2, 2) failed…
ASGR
  • 86
  • 3
4
votes
1 answer

Cannot get install of brms or rstan to compile

I have been trying to get brms/rstan to work on my system with limited luck. I have R 4.2 and am using R studio. I originally started doing this in R, because I couldn't get any Bayes packages to work in Python and I (it seems incorrectly) thought…
Beth
  • 41
  • 2
4
votes
0 answers

R/RStudio unable to run, with looping socketConnection error

A few days ago, I was having an error running models in R using 'brms', which said that my posterior samples didn't exist. Upon reading further, these links (1, 2, 3, 4) led me to think it was an rstan problem playing with my macOS (Catalina…
mthebee
  • 41
  • 1
4
votes
1 answer

Specifying priors for each predictor in rstanarm

I'm developing a Bayesian regression model through rstanarm that combines multinomial, binomial, and scale predictors on a scale dependent variable. As a regular model, my model would look as it does below: ```` * deaths - scale gender -…
r_user
  • 317
  • 3
  • 11
4
votes
1 answer

recompiling to avoid crashing R session

How to avoid recompiling? My stan() is recompiling to avoid crashing R session. To validate my model, I want to replicate various models for many data from known distributions. However rstan::stan() always recompile my stan file, so it took a very…
Camford Oxbridge
  • 834
  • 8
  • 21
1
2 3
19 20