Passing a custom mass matrix to RStan to continue stopped chains

I noticed in RStan you can now specify the Leapfrog stepsize and whether you want a diagonal or dense mass matrix. Is there a way to also specify the mass matrix or is that only possible in cmdstan?

The reason I’m asking is because sometimes I run a chain for a predetermined number of samples but the n_{eff} ends up being too low. In these cases I’d like to continue the chain at the same point so that I don’t have to warmup again, but this requires also specifying the stepsize and mass matrix.

If your parameters are all unconstrained, then you can use the multiplier facility and run with a unit mass matrix, I think.

We haven’t implemented this in rstan yet, but in 2.19 you can specify the offset and multiplier keywords, which as Sebastian said you can use to accomplish the same thing.

@Matthijs as you coded up the offset+multiplier thing… I know that these do support transformations. So is my statement above correct that one has to have parameters on the unconstrained space or could you even use the offset+multiplier thing to let the sampler work on the unconstrained space, but give the user a constrained parameter? If yes, can we use this feature to also pass in the mass matrix for constrained parameters as a net result?

I believe that’s right. You should, to some extent, be able to use offset to control the initial position of the sampler and multiplier to control the mass matrix. However, note that offset and multiplier are currently still constrained to scalars (cannot be vectors), which means that we do not have full control over shifting and rescaling vector-parameters. We can only shift or rescale those with a scalar factor. Hopefully, though, someone will come along and will also implement offset and multiplier for vector offsets and Cholesky factor multipliers.