# RStan

**URL:** https://discourse.mc-stan.org/c/interfaces/rstan/29.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)

---

## [About the RStan category](https://discourse.mc-stan.org/t/about-the-rstan-category/374)

<div class="topic-metadata">

**Author:** [@betanalpha](https://discourse.mc-stan.org/u/betanalpha)\
**Replies:** 0\
**Last updated:** [May 3, 2017, 6:34pm UTC](https://discourse.mc-stan.org/t/about-the-rstan-category/374 "2017-05-03T18:34:32Z")

</div>

This category is for questions regarding the installation and use of RStan. If you have installation issues then please provide as much information about your system as possible, especially the output of the commands w…

---

## [Libtbb Linking Issues When Trying To Run RStan](https://discourse.mc-stan.org/t/libtbb-linking-issues-when-trying-to-run-rstan/42018)

<div class="topic-metadata">

**Author:** [@lightday](https://discourse.mc-stan.org/u/lightday)\
**Replies:** 1\
**Last updated:** [November 22, 2026, 2:00am UTC](https://discourse.mc-stan.org/t/libtbb-linking-issues-when-trying-to-run-rstan/42018 "2026-11-22T02:00:25Z")

</div>

Computer: Intel Mac, macOS Sequoia 15.7.4 R: 4.6.2, initialized to base packages only (although I have encountered similar problems with 4.5). Installing per the website instructions, \> install.packages("rstan", repos…

---

## [Error in sink(type = "output") : invalid connection](https://discourse.mc-stan.org/t/error-in-sink-type-output-invalid-connection/41634)

<div class="topic-metadata">

**Author:** [@kieran.mcadams](https://discourse.mc-stan.org/u/kieran.mcadams)\
**Replies:** 12\
**Last updated:** [October 12, 2026, 6:02am UTC](https://discourse.mc-stan.org/t/error-in-sink-type-output-invalid-connection/41634 "2026-10-12T06:02:19Z")

</div>

Hello, I’m new to running stan code and seem to be having issues having my model run in R. Versions: R 4.6.0 RTools 4.5 rstan 2.32.7 StanHeaders 2.39.1 Rcpp 1.1.2 I’ve tried running a simple model to test whether…

---

## [RStan compilation error with R 4.6.1, Rtools45 and rstan 2.39](https://discourse.mc-stan.org/t/rstan-compilation-error-with-r-4-6-1-rtools45-and-rstan-2-39/41589)

<div class="topic-metadata">

**Author:** [@Marta](https://discourse.mc-stan.org/u/Marta)\
**Replies:** 4\
**Last updated:** [September 12, 2026, 9:07am UTC](https://discourse.mc-stan.org/t/rstan-compilation-error-with-r-4-6-1-rtools45-and-rstan-2-39/41589 "2026-09-12T09:07:05Z")

</div>

Hello, I am having a compilation problem with RStan on Windows and would appreciate your help identifying the cause. My current setup is: Windows 10 Pro R 4.6.1 (2026-06-24 ucrt) Rtools45 GCC 14.3.0 rsta…

---

## [Saving and sharing an rstan model fit](https://discourse.mc-stan.org/t/saving-and-sharing-an-rstan-model-fit/1059)

<div class="topic-metadata">

**Author:** [@jeremy.koster](https://discourse.mc-stan.org/u/jeremy.koster)\
**Replies:** 5\
**Last updated:** [August 24, 2026, 7:01am UTC](https://discourse.mc-stan.org/t/saving-and-sharing-an-rstan-model-fit/1059 "2026-08-24T07:01:57Z")

</div>

This might be a basic question, but a search on relevant terms did not reveal a discussion. Apologies if I missed anything. I have estimated a model with rstan, and I would like to save the model fit object to send to …

---

## [Compile Stan model in Shiny App?](https://discourse.mc-stan.org/t/compile-stan-model-in-shiny-app/10022)

<div class="topic-metadata">

**Author:** [@winterstat](https://discourse.mc-stan.org/u/winterstat)\
**Replies:** 22\
**Last updated:** [June 23, 2026, 11:51pm UTC](https://discourse.mc-stan.org/t/compile-stan-model-in-shiny-app/10022 "2026-06-23T23:51:59Z")

</div>

Hello, I hope this is the place to ask this. Let me know if I need to go elsewhere! I’m trying to run rstan in a shiny app I’m creating. It runs fine locally, but then when I deploy it to shinyapps.io, I seem unable to …

---

## [Rstan process on remote desktop stops when I'm disconnected](https://discourse.mc-stan.org/t/rstan-process-on-remote-desktop-stops-when-im-disconnected/41215)

<div class="topic-metadata">

**Author:** [@bugay-yildirim](https://discourse.mc-stan.org/u/bugay-yildirim)\
**Replies:** 6\
**Last updated:** [May 20, 2026, 7:24am UTC](https://discourse.mc-stan.org/t/rstan-process-on-remote-desktop-stops-when-im-disconnected/41215 "2026-05-20T07:24:22Z")

</div>

Hello everyone, I am running a model using rstan in RStudio on a remote Windows laptop that is connected to my university’s server. I access it from my local computer using Windows Remote Desktop Connection (RDP) over m…

---

## [Timeline for Rstan update on CRAN](https://discourse.mc-stan.org/t/timeline-for-rstan-update-on-cran/41038)

<div class="topic-metadata">

**Author:** [@novice](https://discourse.mc-stan.org/u/novice)\
**Replies:** 5\
**Last updated:** [April 28, 2026, 9:01am UTC](https://discourse.mc-stan.org/t/timeline-for-rstan-update-on-cran/41038 "2026-04-28T09:01:39Z")

</div>

I’m writing an R package that relies on Rstan and plan to put it on CRAN once an accompanying article has been published. I want use some functionality from Stan 2.36 (sum-to-zero-vectors), but CRAN is still at Rstan ver…

---

## [Problem with Stan modeling extremely slow compilation](https://discourse.mc-stan.org/t/problem-with-stan-modeling-extremely-slow-compilation/36899)

<div class="topic-metadata">

**Author:** [@blasbats](https://discourse.mc-stan.org/u/blasbats)\
**Replies:** 13\
**Last updated:** [August 27, 2025, 7:51pm UTC](https://discourse.mc-stan.org/t/problem-with-stan-modeling-extremely-slow-compilation/36899 "2025-08-27T19:51:31Z")

</div>

Hello, I just upgraded my computer (MacBook Air M1 2020) to a more powerful one (MacBook Air M3 with additional RAM), and started to re-use RStan. To my surprise, Stan is extremely slow, both for starting models and comp…

---

## [Generate quantities in Stan or R](https://discourse.mc-stan.org/t/generate-quantities-in-stan-or-r/40267)

<div class="topic-metadata">

**Author:** [@benjamin\_hlina](https://discourse.mc-stan.org/u/benjamin_hlina)\
**Replies:** 5\
**Last updated:** [August 22, 2025, 8:08pm UTC](https://discourse.mc-stan.org/t/generate-quantities-in-stan-or-r/40267 "2025-08-22T20:08:39Z")

</div>

This might already be out there so if it is sorry for making a duplicate post but is there a preferred way to generate quantities. I’m in the process of building a package that has Stan models in it. I initially put the …

---

## ["Largest R-hat" warning does not match actual maximum rhat](https://discourse.mc-stan.org/t/largest-r-hat-warning-does-not-match-actual-maximum-rhat/40130)

<div class="topic-metadata">

**Author:** [@William\_Bradley](https://discourse.mc-stan.org/u/William_Bradley)\
**Replies:** 1\
**Last updated:** [August 21, 2025, 11:43am UTC](https://discourse.mc-stan.org/t/largest-r-hat-warning-does-not-match-actual-maximum-rhat/40130 "2025-08-21T11:43:09Z")

</div>

I am in the (hopefully) final stages of the Bayesian workflow process. I get the following warnings after running my model (~16k parameters, 10 chains, 10 cores, adapt\_delta = 0.99, 4000 iters of which 2000 are warmup): …

---

## [Installation Problems - Load Library Failure](https://discourse.mc-stan.org/t/installation-problems-load-library-failure/39901)

<div class="topic-metadata">

**Author:** [@cMiIIer](https://discourse.mc-stan.org/u/cMiIIer)\
**Replies:** 2\
**Last updated:** [July 26, 2025, 12:15am UTC](https://discourse.mc-stan.org/t/installation-problems-load-library-failure/39901 "2025-07-26T00:15:55Z")

</div>

Hello! I am new to Stan and this side of R and I am trying to be able to get some scripts up and running. However, whenever I try to run anything regarding the package (both the library() and example() function from the …

---

## [Error in dim(sssf)](https://discourse.mc-stan.org/t/error-in-dim-sssf/12222)

<div class="topic-metadata">

**Author:** [@Lucas\_Leemann](https://discourse.mc-stan.org/u/Lucas_Leemann)\
**Replies:** 5\
**Last updated:** [May 23, 2025, 3:50pm UTC](https://discourse.mc-stan.org/t/error-in-dim-sssf/12222 "2025-05-23T15:50:44Z")

</div>

Hi, I am dealing with an error message that I do not fully understand and I am also unable to get my model to work. Whenever I run a Stan model in R with thin=5 I get this error message: Error in dim(sssf) \<- c(n2, ob…

---

## [Error in compileCode](https://discourse.mc-stan.org/t/error-in-compilecode/39483)

<div class="topic-metadata">

**Author:** [@mattansb](https://discourse.mc-stan.org/u/mattansb)\
**Replies:** 2\
**Last updated:** [May 17, 2025, 7:55pm UTC](https://discourse.mc-stan.org/t/error-in-compilecode/39483 "2025-05-17T19:55:39Z")

</div>

I am teaching Stan and many of my students are getting the following error when following the RStan Getting Started guide: remove.packages("rstan") if (file.exists(".RData")) file.remove(".RData") # Close all RStudio se…

---

## [RStan Installation problems, missing stable version for installation?](https://discourse.mc-stan.org/t/rstan-installation-problems-missing-stable-version-for-installation/39176)

<div class="topic-metadata">

**Author:** [@mbrabec](https://discourse.mc-stan.org/u/mbrabec)\
**Replies:** 7\
**Last updated:** [April 9, 2025, 7:03pm UTC](https://discourse.mc-stan.org/t/rstan-installation-problems-missing-stable-version-for-installation/39176 "2025-04-09T19:03:02Z")

</div>

I am trying to install rstan (which I did several times before) but now with no success. I am following the instructions on page: So that, I first install Rtools from the Rtools43 installer which is linked at that pag…

---

## [Map index of unconstrained parameter to constrained parameter](https://discourse.mc-stan.org/t/map-index-of-unconstrained-parameter-to-constrained-parameter/38423)

<div class="topic-metadata">

**Author:** [@lukelikelihood](https://discourse.mc-stan.org/u/lukelikelihood)\
**Replies:** 5\
**Last updated:** [January 9, 2025, 11:21pm UTC](https://discourse.mc-stan.org/t/map-index-of-unconstrained-parameter-to-constrained-parameter/38423 "2025-01-09T23:21:59Z")

</div>

Hey all! I am looking for a way to automatically discern which components of the unconstrained parameter vector map to which constrained parameters. The following function I wrote does the trick (it first “constrains” t…

---

## [Trouble installing RStan](https://discourse.mc-stan.org/t/trouble-installing-rstan/37677)

<div class="topic-metadata">

**Author:** [@AliW](https://discourse.mc-stan.org/u/AliW)\
**Replies:** 17\
**Last updated:** [January 7, 2025, 1:40pm UTC](https://discourse.mc-stan.org/t/trouble-installing-rstan/37677 "2025-01-07T13:40:34Z")

</div>

Hello everbody, I am new to RSTAN and I have low experience with installing interfaces. Since several weeks, I try to make RStan run but I do not succeed. I have not found a post with a similar error message, this is …

---

## [Create a R package using rstan](https://discourse.mc-stan.org/t/create-a-r-package-using-rstan/37617)

<div class="topic-metadata">

**Author:** [@Taioba](https://discourse.mc-stan.org/u/Taioba)\
**Replies:** 4\
**Last updated:** [December 16, 2024, 6:39pm UTC](https://discourse.mc-stan.org/t/create-a-r-package-using-rstan/37617 "2024-12-16T18:39:26Z")

</div>

I am creating a package in R that uses Rstan. When I try to iterate the model and use options(mc.cores = parallel::detectCores()) beforehand, it generates the error below. If I run the iteration without using this code,…

---

## [Rstan::expose\_stan\_function on R4.4.0 / Rstan2.32.6 / rcpp 1.0.13](https://discourse.mc-stan.org/t/rstan-expose-stan-function-on-r4-4-0-rstan2-32-6-rcpp-1-0-13/37237)

<div class="topic-metadata">

**Author:** [@notastudent](https://discourse.mc-stan.org/u/notastudent)\
**Replies:** 1\
**Last updated:** [November 14, 2024, 8:35pm UTC](https://discourse.mc-stan.org/t/rstan-expose-stan-function-on-r4-4-0-rstan2-32-6-rcpp-1-0-13/37237 "2024-11-14T20:35:38Z")

</div>

expose\_stan\_function ends up with message: Error in expose\_stan\_functions("NormRNG.stan", show\_compiler\_warnings = T) : Compilation failed! stan file “NormRNG.stan” // This Stan defines a random normal number gener…

---

## [Rstan expose\_stan\_functions and random seed](https://discourse.mc-stan.org/t/rstan-expose-stan-functions-and-random-seed/37049)

<div class="topic-metadata">

**Author:** [@jroon](https://discourse.mc-stan.org/u/jroon)\
**Replies:** 5\
**Last updated:** [October 24, 2024, 8:10pm UTC](https://discourse.mc-stan.org/t/rstan-expose-stan-functions-and-random-seed/37049 "2024-10-24T20:10:00Z")

</div>

I 'm trying to debug some code by matching outputs from exposed stan and r functions. And as this involves generating a random number, I’m trying to set the random seed before calling each function. A toy example - give…

---

## [Memory not mapped](https://discourse.mc-stan.org/t/memory-not-mapped/36537)

<div class="topic-metadata">

**Author:** [@icstan](https://discourse.mc-stan.org/u/icstan)\
**Replies:** 2\
**Last updated:** [October 17, 2024, 2:12pm UTC](https://discourse.mc-stan.org/t/memory-not-mapped/36537 "2024-10-17T14:12:30Z")

</div>

Hello, I’m fitting a Markov model to a large data set using RStan. However, before calculating the likelihood and LOO, the server runs out of memory (server has 512GB RAM). So, I save the fit and load the rds file in a s…

---

## [Help a new user run flipMaxDiff](https://discourse.mc-stan.org/t/help-a-new-user-run-flipmaxdiff/36931)

<div class="topic-metadata">

**Author:** [@SEJW](https://discourse.mc-stan.org/u/SEJW)\
**Replies:** 4\
**Last updated:** [October 16, 2024, 4:32pm UTC](https://discourse.mc-stan.org/t/help-a-new-user-run-flipmaxdiff/36931 "2024-10-16T16:32:17Z")

</div>

Hi there, New Stan user here and am struggling, and hoping someone can find time to help. I have setup Stan and rtools43 according to instructions here: All seems to run fine and I can load the rstan library into RSt…

---

## [Rtools re-install every time i try to run](https://discourse.mc-stan.org/t/rtools-re-install-every-time-i-try-to-run/36426)

<div class="topic-metadata">

**Author:** [@Jonathan\_Tullis](https://discourse.mc-stan.org/u/Jonathan_Tullis)\
**Replies:** 1\
**Last updated:** [September 20, 2024, 8:53pm UTC](https://discourse.mc-stan.org/t/rtools-re-install-every-time-i-try-to-run/36426 "2024-09-20T20:53:54Z")

</div>

I have been trying to get rstan installed and running. I have followed the instructions here (RStan Getting Started · stan-dev/rstan Wiki · GitHub) as closely as possible. After following all of the steps, I get to thi…

---

## [Expose\_stan\_functions not working with tuple](https://discourse.mc-stan.org/t/expose-stan-functions-not-working-with-tuple/36573)

<div class="topic-metadata">

**Author:** [@Ben\_Lambert](https://discourse.mc-stan.org/u/Ben_Lambert)\
**Replies:** 3\
**Last updated:** [September 15, 2024, 6:05pm UTC](https://discourse.mc-stan.org/t/expose-stan-functions-not-working-with-tuple/36573 "2024-09-15T18:05:44Z")

</div>

Using rstan, the following works fine: model\_code \<- ' functions { real standard\_normal\_rng() { return normal\_rng(0,1); } } ' expose\_stan\_functions(stanc(model\_code = model\_code)) but the following e…

---

## [Fatal error when installing older version of RStan](https://discourse.mc-stan.org/t/fatal-error-when-installing-older-version-of-rstan/36401)

<div class="topic-metadata">

**Author:** [@b\_e\_xiao](https://discourse.mc-stan.org/u/b_e_xiao)\
**Replies:** 2\
**Last updated:** [August 29, 2024, 1:33pm UTC](https://discourse.mc-stan.org/t/fatal-error-when-installing-older-version-of-rstan/36401 "2024-08-29T13:33:03Z")

</div>

I tried to install a specific version of rstan with: remotes::install\_version(package = "rstan", version = "2.21.8") And I encountered the error: chains.cpp:19:10: \*\*fatal error：\*\*stan/math/prim/mat/fun/mean.hpp：No su…

---

## [Can’t compile example stan code on M1 Pro with MacOS Sonoma](https://discourse.mc-stan.org/t/can-t-compile-example-stan-code-on-m1-pro-with-macos-sonoma/35232)

<div class="topic-metadata">

**Author:** [@p0bs](https://discourse.mc-stan.org/u/p0bs)\
**Replies:** 3\
**Last updated:** [August 21, 2024, 9:27pm UTC](https://discourse.mc-stan.org/t/can-t-compile-example-stan-code-on-m1-pro-with-macos-sonoma/35232 "2024-08-21T21:27:57Z")

</div>

I wonder if you can help me. I have a similar (but seemingly different) problem to this issue. Specifically, having followed the online documentation for getting started, when I run … library(rstan) example(stan\_model,…

---

## [Rstan package: No such file or directory #include \<boost/date\_time/posix\_time/posix\_time\_types.hpp\>](https://discourse.mc-stan.org/t/rstan-package-no-such-file-or-directory-include-boost-date-time-posix-time-posix-time-types-hpp/36325)

<div class="topic-metadata">

**Author:** [@ignacio](https://discourse.mc-stan.org/u/ignacio)\
**Replies:** 1\
**Last updated:** [August 21, 2024, 8:23pm UTC](https://discourse.mc-stan.org/t/rstan-package-no-such-file-or-directory-include-boost-date-time-posix-time-posix-time-types-hpp/36325 "2024-08-21T20:23:16Z")

</div>

I’m having troubles getting a package that uses stan to run. When I run roxygen2::roxygenise() I get the following fatal error: g++ -std=gnu++17 -I"/usr/local/lib/R/include" -DNDEBUG -I"../inst/include" -I"/usr/local…

---

## [getDLLRegisteredRoutines.DLLInfo(dll, addNames = FALSE)](https://discourse.mc-stan.org/t/getdllregisteredroutines-dllinfo-dll-addnames-false/36148)

<div class="topic-metadata">

**Author:** [@ignacio](https://discourse.mc-stan.org/u/ignacio)\
**Replies:** 1\
**Last updated:** [August 6, 2024, 4:09pm UTC](https://discourse.mc-stan.org/t/getdllregisteredroutines-dllinfo-dll-addnames-false/36148 "2024-08-06T16:09:24Z")

</div>

I’m having troubles compiling an R package that uses Stan. This is the error I’m getting: Error in getDLLRegisteredRoutines.DLLInfo(dll, addNames = FALSE) : must specify DLL via a “DLLInfo” object. See getLoadedDLLs(…

---

## [Rstan does not work after each restart of R for R4.4.0](https://discourse.mc-stan.org/t/rstan-does-not-work-after-each-restart-of-r-for-r4-4-0/36107)

<div class="topic-metadata">

**Author:** [@pko](https://discourse.mc-stan.org/u/pko)\
**Replies:** 0\
**Last updated:** [August 2, 2024, 1:21pm UTC](https://discourse.mc-stan.org/t/rstan-does-not-work-after-each-restart-of-r-for-r4-4-0/36107 "2024-08-02T13:21:16Z")

</div>

After updating to R4.4.0 (or R4.4.1), installing rtools44, uninstalling rstan and re-installing it (from source or not), rstan works, but when I close RStudio and re-open it, rstan does not work any more: I get the error…

---

## [Error in rstan compilation after installation of Rtools](https://discourse.mc-stan.org/t/error-in-rstan-compilation-after-installation-of-rtools/35917)

<div class="topic-metadata">

**Author:** [@ckeith](https://discourse.mc-stan.org/u/ckeith)\
**Replies:** 3\
**Last updated:** [July 19, 2024, 7:55pm UTC](https://discourse.mc-stan.org/t/error-in-rstan-compilation-after-installation-of-rtools/35917 "2024-07-19T19:55:51Z")

</div>

First time user of rstan/Rtools here. After installing Rtools 43 and rstan and running the test model example(stan\_model, package = “rstan”, run.dontrun = TRUE) I see the following error message… “Error in compileCod…

[Next page](https://discourse.mc-stan.org/c/interfaces/rstan/29.md?page=1)
