Questions tagged [rstanarm]

An R package providing an interface for building and running inference for Bayesian regression models.

Estimates previously compiled regression models using the rstan package, which provides the R interface to the Stan C++ library for Bayesian estimation. Users specify models via the customary R syntax with a formula and data.frame plus some additional arguments for priors.

http://mc-stan.org/rstanarm/

66 questions
2
votes
1 answer

Why does tab_model (sjPlot) re-run MCMC with rstanarm model?

I am creating a table with tab_model from the package sjPlot (https://cran.r-project.org/web/packages/sjPlot/vignettes/tab_model_estimates.html). However, when I use a negative binomial rstanarm model object, tab_model re-runs MCMC chains. My actual…
Dylan_Gomes
  • 2,066
  • 14
  • 29
2
votes
1 answer

Standardizing priors in rstanarm Bayesian regressions

I am not sure if my results can be trusted. Let's say I fitted this model with informative priors: library(rstanarm) data <- iris[, c("Sepal.Length", "Petal.Width")] model1 <- stan_glm(Sepal.Length ~ Petal.Width, data=iris, prior=normal(2, 3,…
Dominique Makowski
  • 1,511
  • 1
  • 13
  • 30
2
votes
1 answer

How to pass a list of vectors with various length and list of matrices with various dimensions in Stan model?

I need to pass the data as a list of vectors with various length and a list of matrices with the same number of rows but with a different number of columns. Is there a way to pass the data in Rstan?
2
votes
0 answers

How to pass multiple columns of weights to brms

I would appreciate any help to specify my brms model below in order to be able to pass multiple columns of weights to the model as illustrated in the stan code below. I need to do this in brms or stanarm rather than stan directly because I want to…
Krantz
  • 1,424
  • 1
  • 12
  • 31
2
votes
1 answer

Obtaining Standardized coefficients from "rstanarm" package in R?

I was wondering if it might be possible (and perhaps recommended) to obtain standardized coefficients from stan_glm() in the rstanarm package? (did not find anything specific in the documentation) Can I just standardize all variables as in normal…
rnorouzian
  • 7,397
  • 5
  • 27
  • 72
2
votes
1 answer

rstanarm for Bayesian hierarchical modeling of binomial experiments

Suppose there are three binomial experiments conducted chronologically. For each experiment, I know the #of trials as well as the #of successes. To use the first two older experiments as prior for the third experiment, I want to "fit a Bayesian…
rnorouzian
  • 7,397
  • 5
  • 27
  • 72
2
votes
1 answer

Calculating marginal effects in binomial logit using rstanarm

I am trying to get the marginal effects, according to this post: http://andrewgelman.com/2016/01/14/rstanarm-and-more/ td <- readRDS("some data") CHAINS <- 1 CORES <- 1 SEED <- 42 ITERATIONS <- 2000 MAX_TREEDEPTH <- 9 md <- td[,.(y,x1,x2)] #…
quant
  • 4,062
  • 5
  • 29
  • 70
1
vote
0 answers

create sequence of predictor values to generate posterior predictions of simultaneous change in predictors

I am trying to create a data frame using (either tidyr::expand.grid or tibble::data_frame) in order to then generate posterior predictions using the tidybayes::epred_draws function from tidybayes (akin to posterior_predict). I have three continuous…
AJ_0000
  • 61
  • 5
1
vote
0 answers

How to distribute Stan function definitions?

I'm creating an R package that contains a selection of new probablity distributions. In addition to implementing the density functions in R I have also implemented them as Stan functions. My idea is that people can create their own models based on…
andypea
  • 1,343
  • 11
  • 22
1
vote
0 answers

rstanarm - error when running Bayesian model

EDIT - I have managed to resolve this. See my comment below I am running a Bayesian regression in R using rstanarm using priors I have set, using the following code: priors <- rstanarm::normal(location = c(-1, 0.5, 2), scale = c(1, 2, 0.5)) bmd <-…
1
vote
1 answer

Best way to present results of rstanarm output?

I'm wondering if anyone has any recommendations for the best way to display output from rstanarm. I like texreg::screenreg and stargazer typically, but neither one accepts rstanarm objects. Bonus if it's something that takes a regular lm object as…
g_t_b
  • 143
  • 9
1
vote
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
  • 11
  • 1
1
vote
0 answers

How can I specify an informative prior for a stan_lmer multilevel model in rstanarm?

I'm creating a Bayesian multilevel model in rstanarm to predict satisfaction by party identity in each year (using year as the second level), with demographic controls. (I'm new to rstanarm so my syntax may be off). The formula is: stanmodel_levels…
1
vote
1 answer

Setting individual colors in rstanarm/bayesplot plots, rather than color scheme

I am wondering if one can apply colors directly to parameters from rstanarm models with bayesplot For example from https://mc-stan.org/bayesplot/articles/plotting-mcmc-draws.html: library("bayesplot") library("ggplot2") library("rstanarm") fit <-…
Dylan_Gomes
  • 2,066
  • 14
  • 29
1
vote
1 answer

How to reduce size of regression object fit inside function that explodes in size when saved to .rds

I’m using rstanarm to fit stan_glm models inside a function. Running into a problem where the size of the saved stanfit object explodes in size when saved to .rds, but only when the model is fit inside a function. The issue seems to be that the…
DanO
  • 600
  • 3
  • 11