# \#r

**URL:** https://discourse.mc-stan.org/tag/r/41.md

[Latest](https://discourse.mc-stan.org/latest.md) · [Categories](https://discourse.mc-stan.org/categories.md) · [Tags](https://discourse.mc-stan.org/tags.md)

---

## [How to quantify the effects of moderate correlation (dependent variable and random intercept)?](https://discourse.mc-stan.org/t/how-to-quantify-the-effects-of-moderate-correlation-dependent-variable-and-random-intercept/40221)

<div class="topic-metadata">

**Author:** [@Nate\_L](https://discourse.mc-stan.org/u/Nate_L)\
**Replies:** 0\
**Last updated:** [August 19, 2025, 3:35pm UTC](https://discourse.mc-stan.org/t/how-to-quantify-the-effects-of-moderate-correlation-dependent-variable-and-random-intercept/40221 "2025-08-19T15:35:48Z")

</div>

Hello, I have a dependent variable in my model that is moderately correlated (0.5) with the random intercept, and I’m wondering if there is a way to visualize or estimate how much of an effect this correlation has on my…

---

## [Dealing with convergence issues when fitting a complex Bayesian nonlinear model to a small dataset using brms in R](https://discourse.mc-stan.org/t/dealing-with-convergence-issues-when-fitting-a-complex-bayesian-nonlinear-model-to-a-small-dataset-using-brms-in-r/39647)

<div class="topic-metadata">

**Author:** [@Sophie\_Pere](https://discourse.mc-stan.org/u/Sophie_Pere)\
**Replies:** 2\
**Last updated:** [June 14, 2025, 5:52am UTC](https://discourse.mc-stan.org/t/dealing-with-convergence-issues-when-fitting-a-complex-bayesian-nonlinear-model-to-a-small-dataset-using-brms-in-r/39647 "2025-06-14T05:52:37Z")

</div>

Hello, I am fitting a nonlinear model with seven parameters to a small dataset (27 observations) using a Bayesian approach. I use the brms package in R, which interfaces with Stan for sampling. The nonlinear model is bim…

---

## [Troubleshooting pathological fitting in multiple decay model](https://discourse.mc-stan.org/t/troubleshooting-pathological-fitting-in-multiple-decay-model/39472)

<div class="topic-metadata">

**Author:** [@Jaime](https://discourse.mc-stan.org/u/Jaime)\
**Replies:** 1\
**Last updated:** [May 19, 2025, 4:10pm UTC](https://discourse.mc-stan.org/t/troubleshooting-pathological-fitting-in-multiple-decay-model/39472 "2025-05-19T16:10:30Z")

</div>

I am trying to fit a model of pathogen decay where we have three point sources of pathogens “farms”, using a laplace dispersal kernel model. I am seeing an issue, where the peak estimate of pathogen density is really hi…

---

## [Actuaries that use Stan?](https://discourse.mc-stan.org/t/actuaries-that-use-stan/38484)

<div class="topic-metadata">

**Author:** [@RaNT132](https://discourse.mc-stan.org/u/RaNT132)\
**Replies:** 12\
**Last updated:** [March 28, 2025, 4:18pm UTC](https://discourse.mc-stan.org/t/actuaries-that-use-stan/38484 "2025-03-28T16:18:41Z")

</div>

I work as a healthcare actuary. Three years ago, I took a Coursera class on Bayesian Statistics (UCSC Matthew Heiner) and learned rjags, and a year after that, I did the Statistical Rethinking lectures on YouTube and lea…

---

## [How to calculate mean difference from ordinal regression model](https://discourse.mc-stan.org/t/how-to-calculate-mean-difference-from-ordinal-regression-model/39084)

<div class="topic-metadata">

**Author:** [@Ern\_N](https://discourse.mc-stan.org/u/Ern_N)\
**Replies:** 7\
**Last updated:** [March 25, 2025, 4:43am UTC](https://discourse.mc-stan.org/t/how-to-calculate-mean-difference-from-ordinal-regression-model/39084 "2025-03-25T04:43:08Z")

</div>

Hi there, I am modelling the effects of age on the number of treatment doses over 3 months. Due to the shape of this distribution, I’m finding that the model is best fit using ordinal regression (see an example of the c…

---

## [Dynamically specifying which parameters to estimate in stan](https://discourse.mc-stan.org/t/dynamically-specifying-which-parameters-to-estimate-in-stan/38808)

<div class="topic-metadata">

**Author:** [@marianklose](https://discourse.mc-stan.org/u/marianklose)\
**Replies:** 4\
**Last updated:** [February 20, 2025, 12:48pm UTC](https://discourse.mc-stan.org/t/dynamically-specifying-which-parameters-to-estimate-in-stan/38808 "2025-02-20T12:48:34Z")

</div>

Hello everyone, I am wondering if it is possible to dynamically specify (e.g., from R) which parameters should be estimated in a Stan model. Use case I am developing an RShiny app that allows physicians/clinicians to i…

---

## [Parallelized loading of csv files](https://discourse.mc-stan.org/t/parallelized-loading-of-csv-files/36512)

<div class="topic-metadata">

**Author:** [@mippeqf](https://discourse.mc-stan.org/u/mippeqf)\
**Replies:** 3\
**Last updated:** [September 6, 2024, 8:14pm UTC](https://discourse.mc-stan.org/t/parallelized-loading-of-csv-files/36512 "2024-09-06T20:14:18Z")

</div>

I have 20 csv files that each take around 15mins to load into R, which adds up to 5h when done sequentially with either as\_cmdstan\_fit, or read\_cmdstan\_csv. Since 5h is really a lot, I’ve parallelized the the process lik…

---

## [R-User but Stan-Curious](https://discourse.mc-stan.org/t/r-user-but-stan-curious/36244)

<div class="topic-metadata">

**Author:** [@mtenan](https://discourse.mc-stan.org/u/mtenan)\
**Replies:** 2\
**Last updated:** [August 26, 2024, 9:26pm UTC](https://discourse.mc-stan.org/t/r-user-but-stan-curious/36244 "2024-08-26T21:26:24Z")

</div>

I’ve been heavily using the R ‘brms’ package for a while now and love it. I’ve been a power user of the multivariate distributional models with splines (among other things). My question is if there is value in my transit…

---

## [Fit multivariate non-linear model with shared parameters](https://discourse.mc-stan.org/t/fit-multivariate-non-linear-model-with-shared-parameters/36243)

<div class="topic-metadata">

**Author:** [@Julien-Beaulieu](https://discourse.mc-stan.org/u/Julien-Beaulieu)\
**Replies:** 2\
**Last updated:** [August 22, 2024, 8:12pm UTC](https://discourse.mc-stan.org/t/fit-multivariate-non-linear-model-with-shared-parameters/36243 "2024-08-22T20:12:41Z")

</div>

Hello! I want to fit a multivariate non-linear model with shared parameters. I am used to work with brms and I tried specifying the model in brms in a way that express what I want it to do: # make inverse logit link fun…

---

## [AD with stan math, Rcpp](https://discourse.mc-stan.org/t/ad-with-stan-math-rcpp/35889)

<div class="topic-metadata">

**Author:** [@Josh\_Knecht](https://discourse.mc-stan.org/u/Josh_Knecht)\
**Replies:** 2\
**Last updated:** [July 17, 2024, 2:04pm UTC](https://discourse.mc-stan.org/t/ad-with-stan-math-rcpp/35889 "2024-07-17T14:04:52Z")

</div>

Hey Everyone, I have been trying to use the stan math library and Rcpp to use autodiff in R. At this point, I’m just trying to figure out how to make it work. I haven’t used c++ before, so I’m sure that it is just a sil…

---

## [Post-hoc test for multinomial logistic regression brm model (categorical responce)](https://discourse.mc-stan.org/t/post-hoc-test-for-multinomial-logistic-regression-brm-model-categorical-responce/35707)

<div class="topic-metadata">

**Author:** [@LeoJha](https://discourse.mc-stan.org/u/LeoJha)\
**Replies:** 4\
**Last updated:** [July 7, 2024, 1:40am UTC](https://discourse.mc-stan.org/t/post-hoc-test-for-multinomial-logistic-regression-brm-model-categorical-responce/35707 "2024-07-07T01:40:46Z")

</div>

I apologise as I am very new to this package and I really appreciate any help I can get. I have a brms model with a categorical response variable (Species) with the following formula, running a multinomial logistics reg…

---

## [Setting priors to produce bayesian comparison - syntax](https://discourse.mc-stan.org/t/setting-priors-to-produce-bayesian-comparison-syntax/35593)

<div class="topic-metadata">

**Author:** [@agata](https://discourse.mc-stan.org/u/agata)\
**Replies:** 3\
**Last updated:** [July 6, 2024, 9:13am UTC](https://discourse.mc-stan.org/t/setting-priors-to-produce-bayesian-comparison-syntax/35593 "2024-07-06T09:13:24Z")

</div>

I’m trying to replicate the analysis from this code (OSF) and compare two models that have either 2 or 6 predictor variables, but I don’t really understand the syntax for setting the priors. My models are: prior1 \<- c(…

---

## [Bmm: R package for easy and flexible Bayesian Measurement Modeling (v1.0.0)](https://discourse.mc-stan.org/t/bmm-r-package-for-easy-and-flexible-bayesian-measurement-modeling-v1-0-0/35483)

<div class="topic-metadata">

**Author:** [@Ven\_Popov](https://discourse.mc-stan.org/u/Ven_Popov)\
**Replies:** 6\
**Last updated:** [June 19, 2024, 4:58pm UTC](https://discourse.mc-stan.org/t/bmm-r-package-for-easy-and-flexible-bayesian-measurement-modeling-v1-0-0/35483 "2024-06-19T16:58:10Z")

</div>

I’m really happy to share the first official CRAN release of the Bayesian Measurement Modeling (bmm) R package, developed together with @g.frischkorn 🥳 🥳 🥳 tldr; 🥇 Hierarhical Bayesian estimation of complex measurme…

---

## [Random walk in RStan](https://discourse.mc-stan.org/t/random-walk-in-rstan/34308)

<div class="topic-metadata">

**Author:** [@lukaseamus](https://discourse.mc-stan.org/u/lukaseamus)\
**Replies:** 11\
**Last updated:** [June 12, 2024, 6:45am UTC](https://discourse.mc-stan.org/t/random-walk-in-rstan/34308 "2024-06-12T06:45:50Z")

</div>

I recently attempted using random walk in the rethinking::ulam interface to RStan and failed. @richard\_mcelreath replied that ulam does not currently support random walk. Now I am looking into achieving this directly in…

---

## [How to test the hypothesis of a positive correlation between group-level effects in brms model](https://discourse.mc-stan.org/t/how-to-test-the-hypothesis-of-a-positive-correlation-between-group-level-effects-in-brms-model/34914)

<div class="topic-metadata">

**Author:** [@stanbeginner](https://discourse.mc-stan.org/u/stanbeginner)\
**Replies:** 1\
**Last updated:** [April 26, 2024, 8:19am UTC](https://discourse.mc-stan.org/t/how-to-test-the-hypothesis-of-a-positive-correlation-between-group-level-effects-in-brms-model/34914 "2024-04-26T08:19:30Z")

</div>

I know how to get the Bayes Factor for population-level effects, e.g., hypothesis(bayesmodel, "condition:tester \> 0") However, for a planned study I need to get the magnitude of the evidence for a correlation between t…

---

## [R Packages for Plotting 'brms' models](https://discourse.mc-stan.org/t/r-packages-for-plotting-brms-models/34302)

<div class="topic-metadata">

**Author:** [@mtenan](https://discourse.mc-stan.org/u/mtenan)\
**Replies:** 4\
**Last updated:** [March 3, 2024, 12:57am UTC](https://discourse.mc-stan.org/t/r-packages-for-plotting-brms-models/34302 "2024-03-03T00:57:07Z")

</div>

This is not an analytical question. I am simply curious which packages people prefer or suggest is “best” for making publication quality plots for models developed using the ‘brms’ R package. So far I’ve identified the …

---

## [Using cmdstanr crashing RStudio](https://discourse.mc-stan.org/t/using-cmdstanr-crashing-rstudio/33081)

<div class="topic-metadata">

**Author:** [@marcdotson](https://discourse.mc-stan.org/u/marcdotson)\
**Replies:** 7\
**Last updated:** [December 15, 2023, 9:46pm UTC](https://discourse.mc-stan.org/t/using-cmdstanr-crashing-rstudio/33081 "2023-12-15T21:46:26Z")

</div>

I’ve recently updated to macOS Sonoma and started using {renv} when using cmdstanr started causing fatal errors and crashing RStudio (i.e., loading it using library(cmdstanr) or just making function calls using cmdstanr:…

---

## [Deleting brms messages in markdown](https://discourse.mc-stan.org/t/deleting-brms-messages-in-markdown/33245)

<div class="topic-metadata">

**Author:** [@brophyj](https://discourse.mc-stan.org/u/brophyj)\
**Replies:** 1\
**Last updated:** [November 17, 2023, 8:02am UTC](https://discourse.mc-stan.org/t/deleting-brms-messages-in-markdown/33245 "2023-11-17T08:02:32Z")

</div>

When I run the following code in my console, all is well dat \<- data.frame( Status = c("Primary", "Primary", "Secondary","Secondary"), RX = c("B","P","B","P"), Deaths = c(75, 109, 359, 311), #JAMA (primary) =…

---

## [Baking a cake - how to find the perfect recipe?](https://discourse.mc-stan.org/t/baking-a-cake-how-to-find-the-perfect-recipe/24360)

<div class="topic-metadata">

**Author:** [@JamesHWade](https://discourse.mc-stan.org/u/JamesHWade)\
**Replies:** 7\
**Last updated:** [September 24, 2021, 11:12pm UTC](https://discourse.mc-stan.org/t/baking-a-cake-how-to-find-the-perfect-recipe/24360 "2021-09-24T23:12:58Z")

</div>

Let’s say I’m baking a cake. I want to find the “perfect” recipe. I specify a model using the weight percent of each ingredient and cooking conditions as model inputs. Tastiness is the outcome. cake\_data \<- read\_csv("t…

---

## [How to increase size of output from multiple plots](https://discourse.mc-stan.org/t/how-to-increase-size-of-output-from-multiple-plots/32965)

<div class="topic-metadata">

**Author:** [@pehkawn](https://discourse.mc-stan.org/u/pehkawn)\
**Replies:** 0\
**Last updated:** [October 3, 2023, 12:47pm UTC](https://discourse.mc-stan.org/t/how-to-increase-size-of-output-from-multiple-plots/32965 "2023-10-03T12:47:03Z")

</div>

I am trying to adjust the height and width of the output comprised of the plots of the posterior draws of multiple variables, using the mcmc\_combo() function (trace and density plots), as the size does not scale with the…

---

## [Cannot open plots created with brms::mcmc\_plot due to lack of \`discrete\_range\` function](https://discourse.mc-stan.org/t/cannot-open-plots-created-with-brms-mcmc-plot-due-to-lack-of-discrete-range-function/31040)

<div class="topic-metadata">

**Author:** [@pablobernabeu](https://discourse.mc-stan.org/u/pablobernabeu)\
**Replies:** 6\
**Last updated:** [August 4, 2023, 12:12pm UTC](https://discourse.mc-stan.org/t/cannot-open-plots-created-with-brms-mcmc-plot-due-to-lack-of-discrete-range-function/31040 "2023-08-04T12:12:34Z")

</div>

Hello, I would like to ask for advice regarding some plots that were created using brms::mcmc\_plot(), and cannot be opened in R now. The plots were created last year using brms 2.17.0, and were saved in RDS objects. Th…

---

## [Compiler and build tool problems](https://discourse.mc-stan.org/t/compiler-and-build-tool-problems/31888)

<div class="topic-metadata">

**Author:** [@BadgerBadger](https://discourse.mc-stan.org/u/BadgerBadger)\
**Replies:** 1\
**Last updated:** [July 13, 2023, 9:17pm UTC](https://discourse.mc-stan.org/t/compiler-and-build-tool-problems/31888 "2023-07-13T21:17:16Z")

</div>

I was running a bunch of models in Brms that were running well. I then updated R to 4.3.1 and Rstudio to the latest versions and now the models won’t run. Every time I attempt to run the model now a popup window appears…

---

## [Fitting values between 0 to 1](https://discourse.mc-stan.org/t/fitting-values-between-0-to-1/31781)

<div class="topic-metadata">

**Author:** [@Alex\_Ilyaev](https://discourse.mc-stan.org/u/Alex_Ilyaev)\
**Replies:** 2\
**Last updated:** [June 19, 2023, 1:34pm UTC](https://discourse.mc-stan.org/t/fitting-values-between-0-to-1/31781 "2023-06-19T13:34:24Z")

</div>

Hello, I’m new to this kind of modeling. say i have y variables, and its values are between 0 and 1 (not including 0 and 1), and my predictor is a categorical variable, with 4 levels: animals, people, items, insects. I…

---

## [Syntax and Divergent Transitions in Binomial Models using R](https://discourse.mc-stan.org/t/syntax-and-divergent-transitions-in-binomial-models-using-r/30417)

<div class="topic-metadata">

**Author:** [@Non\_Praying\_Mantis](https://discourse.mc-stan.org/u/Non_Praying_Mantis)\
**Replies:** 0\
**Last updated:** [February 16, 2023, 1:27pm UTC](https://discourse.mc-stan.org/t/syntax-and-divergent-transitions-in-binomial-models-using-r/30417 "2023-02-16T13:27:31Z")

</div>

Hi all, I’m aiming to model binary species traits (presence = 1, absence = 0) as a function of some sampling variables. So I built a brms model adding to it a phylogenetic structure, and a Gaussian process, gp(), to han…

---

## [Permissions error running brms on Windows with "cmdstanr" backend](https://discourse.mc-stan.org/t/permissions-error-running-brms-on-windows-with-cmdstanr-backend/28429)

<div class="topic-metadata">

**Author:** [@peopletrees](https://discourse.mc-stan.org/u/peopletrees)\
**Replies:** 4\
**Last updated:** [February 14, 2023, 10:11pm UTC](https://discourse.mc-stan.org/t/permissions-error-running-brms-on-windows-with-cmdstanr-backend/28429 "2023-02-14T22:11:15Z")

</div>

I’m on a work computer that’s very locked down, except for a single folder that is allowed to run stan executables. When I’m using cmdstanr I can force the use of this permitted directory by running: file \<- write\_stan\_f…

---

## ["Expected non-array type after "array" declaration" error in ODE solver of Cmdstanr with missing data](https://discourse.mc-stan.org/t/expected-non-array-type-after-array-declaration-error-in-ode-solver-of-cmdstanr-with-missing-data/30339)

<div class="topic-metadata">

**Author:** [@geraltofrivia](https://discourse.mc-stan.org/u/geraltofrivia)\
**Replies:** 4\
**Last updated:** [February 10, 2023, 9:07am UTC](https://discourse.mc-stan.org/t/expected-non-array-type-after-array-declaration-error-in-ode-solver-of-cmdstanr-with-missing-data/30339 "2023-02-10T09:07:52Z")

</div>

I am trying to run a Measurement error model using CmdStan’s ode\_rk45 solver. The data set has T rows and 3 columns, only the first column’s data is available. But the initial condition is available for all 3 columns (th…

---

## [.so file size when building an R package that uses compiled Stan code](https://discourse.mc-stan.org/t/so-file-size-when-building-an-r-package-that-uses-compiled-stan-code/16530)

<div class="topic-metadata">

**Author:** [@harrelfe](https://discourse.mc-stan.org/u/harrelfe)\
**Replies:** 8\
**Last updated:** [February 6, 2023, 8:00pm UTC](https://discourse.mc-stan.org/t/so-file-size-when-building-an-r-package-that-uses-compiled-stan-code/16530 "2023-02-06T20:00:39Z")

</div>

@bgoodri has prompted me to build a separate R package for my R functions that use rstan. I followed the instructions here: https://mc-stan.org/rstantools/articles/minimal-rstan-package.html except that I did not run co…

---

## [Problem running stan() function. October 2022. R version 4.2.1. Windows 10](https://discourse.mc-stan.org/t/problem-running-stan-function-october-2022-r-version-4-2-1-windows-10/29199)

<div class="topic-metadata">

**Author:** [@Salvador\_Rodriguez](https://discourse.mc-stan.org/u/Salvador_Rodriguez)\
**Replies:** 3\
**Last updated:** [October 19, 2022, 8:36pm UTC](https://discourse.mc-stan.org/t/problem-running-stan-function-october-2022-r-version-4-2-1-windows-10/29199 "2022-10-19T20:36:15Z")

</div>

I am unable to run the stan function from the rstan package. I get the next error: \*Error in compileCode(f, code, language = language, verbose = verbose) : \* \* C:\\rtools42\\x86\_64-w64-mingw32.static.posix\\bin/ld.exe: fi…

---

## [Correlated predictors vs fewer predictors with small dataset?](https://discourse.mc-stan.org/t/correlated-predictors-vs-fewer-predictors-with-small-dataset/28916)

<div class="topic-metadata">

**Author:** [@Deronda](https://discourse.mc-stan.org/u/Deronda)\
**Replies:** 8\
**Last updated:** [October 3, 2022, 5:18pm UTC](https://discourse.mc-stan.org/t/correlated-predictors-vs-fewer-predictors-with-small-dataset/28916 "2022-10-03T17:18:53Z")

</div>

Hi there, I wonder if you might be able to help me with a variable selection conundrum i’m having when the dataset is fairly small and a couple of the predictors are highly correlated. I am fitting a Bayesian mixed-eff…

---

## [Fitting unique priors per coefficient with Rstanarm](https://discourse.mc-stan.org/t/fitting-unique-priors-per-coefficient-with-rstanarm/28754)

<div class="topic-metadata">

**Author:** [@HavenAWilliams](https://discourse.mc-stan.org/u/HavenAWilliams)\
**Replies:** 1\
**Last updated:** [September 26, 2022, 3:29pm UTC](https://discourse.mc-stan.org/t/fitting-unique-priors-per-coefficient-with-rstanarm/28754 "2022-09-26T15:29:52Z")

</div>

Hello, I’m hoping this is more a gentle-push-in-the-right-direction question because I feel like I’m stuck on something pretty minor. I can’t figure out from the documentation for Rstanarm how to fit priors per differen…

[Next page](https://discourse.mc-stan.org/tag/r/41.md?match_all_tags=true&page=1&tags%5B%5D=r)
