Giter Site home page Giter Site logo

Comments (11)

andrjohns avatar andrjohns commented on May 27, 2024 1

Closing this issue given its age, but feel free to re-open if it was never resolved.

Additionally, the github version of rstantools now supports stan files comprised of only function definitions, which will be compiled and exported at installation.

from rstantools.

JohnReid avatar JohnReid commented on May 27, 2024

The bigger problem is that I'm trying to update my DeLorean package to use the rstantools recommended way to pre-compile models to fix some recent CRAN warnings/errors and I'm hitting this error there as well. See this branch: https://github.com/JohnReid/DeLorean/tree/stan-update

from rstantools.

bgoodri avatar bgoodri commented on May 27, 2024

from rstantools.

JohnReid avatar JohnReid commented on May 27, 2024

I called rstan_package_skeleton in order to see the boilerplate code required to implement pre-compiled models. It sounds like you are suggesting a more direct way of updating DeLorean. Regardless of how I update DeLorean, following the vignette shouldn't produce the error message. In fact I get the same error message when I copy the boilerplate code over to the DeLorean branch. This makes me believe there is something wrong in my set up but I have not been able to work out what it is. I updated StanHeaders, rstan and rstan_tools but that didn't help.

from rstantools.

bgoodri avatar bgoodri commented on May 27, 2024

from rstantools.

JohnReid avatar JohnReid commented on May 27, 2024

Great. Thanks for your help. I'll keep plugging away.

from rstantools.

JohnReid avatar JohnReid commented on May 27, 2024

I've followed the vignette through to the end. I have uncovered another problem. I need to expose some functions from my Stan code to R and this doesn't seem to be working as it should. I add a function to the top of lm.stan in the vignette, re-build the package and then get:

>   model <- stanmodels[['lm']]
>   message(class(model))
stanmodel
>   expose_stan_functions(model)
Error in (function (classes, fdef, mtable)  :
  unable to find an inherited method for function ‘get_stancode’ for signature ‘"stanmodel"’

but the expose_stan_functions explicitly says I should be able to pass a stanmodel in. Something pretty similar was working with my original set up so maybe it is to do with pre-compiled models?

from rstantools.

JohnReid avatar JohnReid commented on May 27, 2024

I would be happy passing the path to the lm.stan model description into expose_stan_functions but this is not installed with the package. Is this easy to do?

from rstantools.

JohnReid avatar JohnReid commented on May 27, 2024

Or maybe it is easy to compile the functions and expose them at package installation time?

from rstantools.

bgoodri avatar bgoodri commented on May 27, 2024

The expose_stan_functions() function is more intended for runtime. The binary it produces may not work on another computer. It is probably better to generate the C++ for the functions you want to expose once and then compile that as if you had written it by hand. @wds15 has gone through this process before I think.

from rstantools.

bart1 avatar bart1 commented on May 27, 2024

Just a quick note from my side, I run into the same problem that exposing the stan functions from a package is rather tricky. I first thought it might be an option to generate the code using expose_stan_functions copy the source to the package and then run compileAttributes. This does not work, nor anything else that works. It would be great if there would be an example how to approach this best.

from rstantools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.