GithubHelp home page GithubHelp logo

Comments (5)

bob-carpenter avatar bob-carpenter commented on July 24, 2024 1

You also don't need blocks with nothing in them and you can vectorize everything. This model should look like this:

data {
  int N[2];
  vector[N[1]] y1;
  vector[N[2]] y2;
}
parameters {
  vector[2] mu;
  vector<lower=0>[2] sigma;
}
model {
  mu ~ normal(0, 10);
  sigma ~ cauchy(0, 5);
  y1 ~ normal(mu[1], sigma[1]);
  y2 ~ normal(mu[2], sigma[2]);
}

It'd be even easier if we had ragged arrays.

from example-models.

bob-carpenter avatar bob-carpenter commented on July 24, 2024

The case studies eventually go on the web site repo. Your Stan model has lots of problems you can see in just this fragment:

parameters { //The primary parameters of interest that are to be estimated. 
  real mu1; // mean of y1
  ...
  real<lower=0> sigma1; // standard deviation of y1
  ...
}
model { // Where your priors and likelihood are specified. Uniform, cauchy, and normal 
        // priors might be a good place to start?
  mu1 ~ uniform(0, 30); // uniform prior, maybe try half-normal, exp, or half-cauchy
  ...
y1 ~ normal(mu1, sigma1);
...

The code itself has some problems:

  • if you put a uniform distribution on mu1, then you need to constrain the parameter to have matching lower and upper bounds---Stan models should have a finite log likelihood for all parameter values meeting the declared constraints
  • we recommend much more informative priors

The doc also has some issues

  • mu1 isn't the mean of y1, it's a location parameter
  • you don't want to doc the language in a program, such as what the parameters block is
  • you have lingering open-ended questions on the model---these are best left on the outside

from example-models.

anmwinter avatar anmwinter commented on July 24, 2024

@bob-carpenter Thanks for the feedback! I'll work on correcting this. This is a learning process for me.

from example-models.

bob-carpenter avatar bob-carpenter commented on July 24, 2024

For the moment, we're trying to keep the case studies to best practices recommendations for Stan. We're working on establishing a place for more community oriented sharing of work we wouldn't need to vet so closely. There are prior recommendations on the stan-dev/stan wiki and in the manual regression chapter.

from example-models.

anmwinter avatar anmwinter commented on July 24, 2024

Thanks again @bob-carpenter ! I am working on how to vectorize data. I appreciate the model re-write.

ara

from example-models.

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.