Giter VIP home page Giter VIP logo

Comments (2)

nhuurre avatar nhuurre commented on June 2, 2024 1

Yes, this is a good idea.

When a, b are vectors they have to be ordered vectors themselves.

That requirement is not mathematically necessary, failing it just makes the constraint partially redundant.
Regardless, it is rather difficult to construct a smooth constraining function for vector bounds. Consider this:

data {
  real<lower=0, upper=0.99> x;
}
transformed data {
  ordered[2] a = [0,1-x]';
  ordered[2] b = [x,1]';
}
parameters {
  ordered<lower=a,upper=b>[2] y;
}

For x=0 it's just ordered<lower=0,upper=1>[2] y but for x > 0.5 the vector behaves like two independent parameters

parameters { // x=0.9
  real<lower=0, upper=0.1> y1;
  real<lower=0.9, upper=1> y2;

So I think the lower and upper bounds should always be scalars.


That example ordered_ub_lp is reverse-ordered. Ordered would be

  vector ordered_ub_lp (vector y, real ub) {
    int N = rows(y);
    vector[N] x;
    
    x[N] = ub - exp(y[N]);
    target += exp(y[N]);
    for (i in 1:N-1) {
      x[N-i] = x[N-i-1] - exp(y[N-i]);
      target += exp(y[N-i]);
    }
    
    return x;
  }

And I think ordered_lb_ub_lp should offset the unconstrained parameter so that zero-initialized value corresponds to an evenly spaced vector in the constrained space. (This makes it identical to cumulative sum of simplex constraint)

    for (i in 2:N) {
      x[i] = x[i - 1] + (ub - x[i - 1]) * inv_logit(y[i] - log(N+1-i));
      target += log(ub - x[i - 1]) + log_inv_logit(y[i] - log(N+1-i)) + log1m_inv_logit(y[i] - log(N+1-i));
    }

from math.

WardBrian avatar WardBrian commented on June 2, 2024

I think this would be no problem at the language level

from math.

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.