Coder Social home page Coder Social logo

Comments (2)

jgabry avatar jgabry commented on June 11, 2024

@bgoodri Can you take a look at this? It's also breaking some code from Regression and Other stories (see below for more details).

@invertdna Thanks for reporting this. I think this is a bug introduced with the latest update when we switched to using Stan 2.26. This happens when there's only 1 predictor (it should work fine if you add another variable on the RHS of the formula) when using stan_lm or stan_polr.

@bgoodri any idea why this fails with 2.26? This causes some of the examples from Regression and Other Stories to error that used to run fine. For example, this stan_polr code from ROS now errors with 2.26 because it only has 1 predictor:

https://github.com/avehtari/ROS-Examples/blob/a049a1044aef17bb90664d3b4735fc7ad6ff5575/Storable/storable.Rmd#L54-L55

The unit vector array in polr.stan is declared with

array[K > 1] unit_vector[K] u;

so if there's only 1 predictor (K=1) it would be array[0] unit_vector[0] u. But I don't see why that should be a problem since it's only used in transformed parameters if K > 1 and it used to be fine in earlier versions. Also the error message says that the target distribution must be continuous, which doesn't seem relevant here:

Exception: Found dimension size one in unit vector declaration. 
One-dimensional unit vector is discrete but the target distribution 
must be continuous. variable=u; dimension size expression=K 

from rstanarm.

jgabry avatar jgabry commented on June 11, 2024

The solution may be

array[K > 1] unit_vector[K > 1 ? K : 2] u;

which makes it size 2 when K=1 (it won't even get used so we can just do this to avoid error when K=1)

from rstanarm.

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.