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
0
votes
2 answers

How to specify informative prior only on one specific predictor in rstanarm

I'm currently trying to fit a Bayesian multilevel model using rstanarm. I expect - and there's evidence in literature - that the coefficient of my main predictor lies between 0.15 and 0.65. Therefore, I'd like to set an informative prior but only…
0
votes
1 answer

How to change my interval within the function stan_glm() in R?

when i use stan_glm(), i dont know how to change my interval. my code: mod_rstan <- stan_glm( formula = f, data = dat, family = gaussian(), prior_intercept = normal(0, 10), prior = normal(0, 2.5), prior_aux = cauchy(0,…
0
votes
1 answer

How to convert R objects of class "ppd" to a clean tibble?

rstanarm::posterior_predict() creates objects of class "ppd" "matrix" "array". I want to convert such objects to clean tibbles. I tried: library(tidyverse) library(rstanarm) #> Loading required package: Rcpp #> This is rstanarm version 2.21.1 #> -…
David Kane
  • 363
  • 1
  • 2
  • 8
0
votes
0 answers

Extracting coefficients with CIs from stan_glm model: Error with fixef-command: Error: Can't combine `..1$fixef` and `..3$fixef`

Goal: the estimation of coefficients with a confidence interval in one command for stan_glm models. When trying to extract coefficients CIs of my stan_glm model with fixef(), I get the error below. I try to use the fixef() from bayr instead of…
Steffi
  • 1
  • 3
0
votes
1 answer

Converting a R2jags object into a Stanreg (rstanarm) object

I made a model using R2jags. I like the jags syntax but I find the output produced by R2jags not easy to use. I recently read about the rstanarm package. It has many useful functions and is well supported by the tidybayes and bayesplot packages for…
Junitar
  • 905
  • 6
  • 13
0
votes
1 answer

Posterior_survfit() is not using the nd

I am having trouble generating posterior predictions using posterior_survfit(). I am trying to use a new data frame, but it is not using the new data frame and instead is using values from the dataset I used to fit the model. The fitted variables in…
0
votes
1 answer

How to specify a lognormal prior or user-define non-negative prior in rstanarm?

Suppose I have a following formula for a mixed-effects model: Precipitation ~ s(month,bs="cc")+s(time)+ humidity,random= ~(humidity|year) and I know that humidity will only have positive effects on precipitation. So I want to specify a log-normal…
0
votes
0 answers

How to specify priors distributions for variable transformation parameters in rstanarm which are external to the model?

Suppose, the response y can be modeled by the following generic equation: y = a + b1*x1, where x1 = func(p,q,r) Standard functions provided by rstanarm allow to specify the prior distributions for the coefficients (b1) and intercept (a). Do…
0
votes
1 answer

How to specify "strict" priors for fixed coefficients in rstanarm?

How do I provide a prior distribution for a coefficient with mean in the range 1e-05 and standard deviation (sd) in the range 1e-06? What are the distributions to choose for such high precision (sd <= 1e-06) parameters in rstanarm? 1) Student t…
0
votes
1 answer

"rstanarm does not permit formulas with duplicate group-specific terms", how do I fix this?

While trying bayesian approach on regression models using "rstanarm", duplicate group specific terms are not allowed. Is there any solution for this? Formula = "SleepTime ~ 1 + WorkingHours + (1 + WorkingHours | JobClass) + Tenure + (1 + Tenure |…
0
votes
0 answers

Cannot install rstanarm (R crashes)

A similar question was asked here, but I tried the code Tiago Lubiana posts there, to no avail. I haven't been able to install rstanarm after several attempts. R keeps crashing during the installation. I did install rstan by…
Nalerive
  • 113
  • 6
0
votes
1 answer

Missing predictor variable computing Bayesian ANOVA using stan_aov from rstanarm package

I am computing a Bayesian ANOVA to investigate how my heading variable affects FirstSteeringTime. Here is an example of my data set: x <- structure(list(FirstSteeringTime = c(0.433389999999999, 0.449999999999989, 0.383199999999988,…
codegoblin1996
  • 302
  • 2
  • 12
0
votes
1 answer

Use of different priors for groups of idepedent variables in a Bayesian Probit regression model (rstanarm)

I am using the Bayesian logistic regression (probit) from the rstanarm package to train a model on default events. As inputs the model accepts some financial ratios and some qualitative data. Is there a way where I can actually regularise the…
Jespar
  • 1,017
  • 5
  • 16
  • 29
0
votes
0 answers

simulating what if scenarios using Bayesian model - rstanarm

I am fitting a model (very much simplified for reproducible) like so: library(datasets) library(rstanarm) set.seed(42) rm(list = ls(all = TRUE)) prediction_data1 <- data.frame( Petal.Length = 1.4 ) prediction_data2 <- data.frame( …
cs0815
  • 16,751
  • 45
  • 136
  • 299
0
votes
1 answer

posterior prediction based on a grouping variable from `stan_glm()` in `rstanarm` package?

I was wondering how to obtain the posterior prediction based on a grouping variable from stan_glm() in rstanarm package? For example, if I have a binary (0, 1) coded grouping variable called "vs" in my data (base R data: mtcars), how can I obtain…
rnorouzian
  • 7,397
  • 5
  • 27
  • 72