Giter Site home page Giter Site logo

tan or atan link function about rethinking HOT 3 OPEN

rmcelreath avatar rmcelreath commented on July 22, 2024
tan or atan link function

from rethinking.

Comments (3)

rmcelreath avatar rmcelreath commented on July 22, 2024

I suggest using Stan directly for now. Sorry. But I do have a hack below that might be alright for you.

More detail:

I don't understand why you're getting a unknown distribution error. I'd have to see the code you are attempting. But this kinda works:

m <- map2stan(
    alist(
        b <- 0 + 1*tan(bu),
        bu ~ dunif("-pi()/2","pi()/2")
    ),
    data=list(y=1),
    sample=TRUE )

The major issue here is that variable assignments in map2stan are assumed to be indexed by the outcome variable cases. In the above example, there is just one case, so b gets a single value for each bu sample. But that won't be true in ordinary regression examples. Maybe just doing b[1] in the code would work though? Haven't tried.

All of this feels kludgy and probably dangerous. But it might work fine in your current context.

On the horizon, I have been planning to just allow users to insert raw Stan code into any of Stan's blocks. So a parameter transform could be done like:

TV : beta <- mu + tau*tan(beta_unif)

That would define beta in the transformed variables block in Stan, so it could be used in the model block.

As for adding link functions, in principle that is trivial. We just need more entries in this list:
https://github.com/rmcelreath/rethinking/blob/master/R/map2stan.r#L33

I will put this on my to-do list. I already have a plan to add cloglog there. So might as well as common trig functions.

from rethinking.

jgabry avatar jgabry commented on July 22, 2024

I don't remember if we put this in the Stan manual, but sometimes it can
also be helpful to formulate the Cauchy as a ratio of normals. Maybe that's
an easier parameterization to do in the current version of rethinking (not
sure)?

On Thursday, July 28, 2016, Richard McElreath [email protected]
wrote:

Reopened #45 #45.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#45 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AHb4Qx66_75QH2j4lp3flVlC-C_5n0Ltks5qaGAWgaJpZM4JW3NY
.

from rethinking.

tom-christie avatar tom-christie commented on July 22, 2024

Great, thank you to both of you. I'll try both suggestions. Appreciate the help!

from rethinking.

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.