Git Product home page Git Product logo

dbda2estan's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dbda2estan's Issues

some comments on Stan programs

First, I'd put the Stan programs in their own files. It makes it easier to line up error messages and lets you reuse the model in other scripts.

OneOddGroupModelComp2E_Stan.R

  real<lower=0> kappa[nCond];
  for ( j in 1:nCond ) {
    kappa[j] <- kappaMinusTwo[j] + 2;
  }

can be

  vector<lower=0>[nCond] kappa = kappaMinusTwo + 2;

if you also declare kappaMinusTwo as a vector.

Same thing for a and b local variables in the model block, though you're much better off for efficiency defining true constants as transformed data (then they don't waste time during derivative calculations that go unused).

Pretty much everything you're doing can be vectorized, so this

for ( s in 1:nSubj ) {
    nCorrOfSubj[s] ~ binomial( nTrlOfSubj[s],  theta[s] );

is just

nCorrOfSubj ~ binomial(nTrlOfSubj, theta);

beta_log is deprecated in favor of beta_lpdf.

<- is deprecated in favor of =. The deprecations matter because they'll go away in a future release.

The bigger problem is that you almost never want to work on the exponentiated scale, so this is a big red flag:

prob1 <- modelProb1*exp(beta_log( theta[s], aBeta, bBeta ));

You have to stay on the log scale to prevent underflow and go back to that log_sum_exp form, which is right, though log1m(u) is more stable than log(1 - u) and there's a log_mix function in Stan that turns this all into a one-liner.

Vectorize

kappaMinusTwo ~ gamma( 2.618 , 0.0809 );

but that is a suspicious prior both in its decimal points of precision and where its mean and tail go.

omega ~ beta(aP, bP);

You also don't need all the spaces. There's a style guide in the Stan manual that basically follows C++ programming standards.

modelProb1 ~ beta(1,1);

is redundant because beta(1, 1) is uniform. It won't be too bad as Stan will drop it from everything other than error checking (1 > 0, 1 > 0, modelProb in (0, 1)).

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.