rstan

repository·develop·Indexed 22 days ago

https://github.com/stan-dev/rstan

The R interface to the Stan probabilistic programming language, enabling users to define statistical models in Stan and perform Bayesian inference using R.

Tokens
1.1K
Snippets
5
Records
6
Agent score
76%

What's inside rstan

  1. Compare Devel vs CRAN installation behavior for Stan packages

    develop

    The provided logs demonstrate a discrepancy between Devel and CRAN installation paths for packages like idem and visit on macOS:

    1. Devel Installation: Often fails during the clang++ compilation step due to missing members in the global namespace (e.g., lgamma_r) when using StanHeaders/new.
    2. CRAN Installation: Successfully completes the installation process, including byte-compilation, help index installation, and vignette installation, using StanHeaders/old.

    If you encounter compilation errors in a development environment, switching to the CRAN version of the headers may resolve the issue.

  2. Get started with RStan

    develop

    To install RStan and begin using the R interface to Stan, follow the official installation instructions and setup tips provided in the RStan Getting Started guide. This guide covers the necessary steps to configure your environment for probabilistic programming in R.

    See: https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started
  3. Install the 'beanz' package

    develop

    The beanz package (version 2.4) can be installed via Devel or CRAN methods. Note that Devel installations may fail due to lgamma_r compilation errors depending on the StanHeaders version used.

    # Example Devel installation log snippet
    * installing *source* package ‘beanz’ ...
    ** package ‘beanz’ successfully unpacked and MD5 sums checked
    ** using staged installation
    ** libs
    "/Library/Frameworks/R.framework/Resources/bin/Rscript" -e "source(file.path('..', 'tools', 'make_cc.R')); make_cc(commandArgs(TRUE))" stan_files/bs.stan
  4. Install the 'dfpk' package

    develop

    The dfpk package (version 3.5.1) can be installed via Devel or CRAN. Similar to beanz, Devel installations may encounter lgamma_r errors in Modules.cpp during the compilation of StanHeaders primitives.

    # Example Devel installation log snippet
    * installing *source* package ‘dfpk’ ...
    ** package ‘dfpk’ successfully unpacked and MD5 sums checked
    ** using staged installation
    ** libs
    clang++ -arch arm64 ... -c Modules.cpp -o Modules.o
  5. Troubleshoot 'lgamma_r' compilation error in Devel installations

    develop

    When installing packages from the Devel (development) version of StanHeaders on macOS (arm64), you may encounter a compilation error where lgamma_r is not found in the global namespace. This error occurs during the compilation of the generated C++ file from a .stan file.

    Error Signature: error: no member named 'lgamma_r' in the global namespace

    This issue appears to be specific to the Devel environment and is not present in the CRAN version of the headers.

    In file included from stan_files/idem.cc:3:
    ...
      return ::lgamma_r(x, &sign);
             ~~^
    /Users/andrew/Downloads/StanHeaders/revdep/library.noindex/StanHeaders/new/StanHeaders/include/stan/math/prim/fun/lgamma.hpp:85:12: error: no member named 'lgamma_r' in the global namespace
      return ::lgamma_r(x, &sign);
             ~~^
  6. Troubleshoot 'lgamma_r' compilation errors in StanHeaders

    develop

    When installing packages that depend on StanHeaders (such as beanz or dfpk) on macOS (arm64), you may encounter a compilation error in lgamma.hpp. This error occurs because the compiler cannot find lgamma_r in the global namespace.

    Error Signature:

    /StanHeaders/include/stan/math/prim/fun/lgamma.hpp:85:12: error: no member named 'lgamma_r' in the global namespace
      return ::lgamma_r(x, &sign);
             ~~^

    This error is observed in both Devel and CRAN installation paths when using certain versions of StanHeaders during the compilation of .cc or .cpp files.

    error: no member named 'lgamma_r' in the global namespace
      return ::lgamma_r(x, &sign);