Monitor subset of parameters in cmdstanr?

I really hope this comes across as helpful and not argumentative or anything like that:

FWIW, I you can now pass vectors of bounds where the bounds are themselves parameter vectors :)

For example:

parameters {
  vector[2] bounds;
  vector<lower=bounds>[2] x;
}

model {
  bounds ~ std_normal(); // note that the interaction of this prior and the 
  // constraint means that this is not the realized prior margin

  x ~ std_normal(); // same comment applies here
}

This is new-ish functionality, and maybe not as widely known as it should be.

2 Likes

This is great! I definitely was not aware of this. I guess the documentation about varying upper/lower bounds can be updated.

2 Likes

Sorry if i’m being dense but does this solve the issue i discussed in my original thread (which is specifically regarding the nuisance parameters in the GHK parameterisaton of the multivariate probit model, (see e.g., post from @bgoodri here)? i’m pretty sure there’s no way to declare those ā€œu’sā€ there as local variables or to exclude them from the cmdstanr/rstan output (which, can sometimes be a really big deal, since these models can easily take up >100GB of disk space for every run on large datasets with many chains).

Anyway, for anyone else interested in MVP models, i’ve since implemented my own HMC-based sampler (using algorithms based on the very recently proposed adaptive MALT and RHMC algorithms - which are both much more efficient** than Stan’s current HMC-NUTS based algorithm - I wouldn’t be surprised if variations of these algorithms will be implemented in Stan within a few years!) which solves the issue which this thread is about. The sampler uses manual gradients (which is much faster than Stan’s C++ autodiff library, at least for latent class MVP models using the GHK parameterisation). It is a custom-coded algorithm (mostly in C++ and some R) which currently only works for 2-class latent class MVP models, so it is not a replacement to Stan at all, but specifically for MVP models for large-ish datasets (e.g., N = 8000 and 6 outcomes, giving 48,000 total observations) it is over 15-times more efficient than Stan - I am yet to test bigger datasets but the relative efficiency will likely be much higher than 15 for larger N. It also doesn’t monitor or save the nuisance parameters, so hardly takes up any disk space whereas Stan quickly becomes impractical for large N. Plan on releasing an R package for it soon.

**edit: at least for some models, such as those discussed in the 2 papers I linked and MVP-based models. There may well be some models for which the adaptive MALT and/or RHMC-based algorithms do worse than Stan’s NUTS-HMC sampler.

1 Like