New Deterministic Formulation?
Hi Whit,
Just wondering, it the way to define deterministic node changed recently?
I used to be able to put a customized transformation in a lambda function "model", And then use, MCModelboost::minstd_rand m(model); to wrap it. But now this doesn't work any more.
I've noticed there are some hpp files under cppbugs/deterministic. And also one mcmc.lambda.hpp. So if that's the new way, could you tell me how to include it in the chain?
For instance, like this node (where x is a vector) z<-exp(-x/b)
Sorry for being a noob to cpp, and thank you for your help in advance.
Yes, unfortunately I've broken backwards compatibility w/ my changes.
The reason that I find the new way preferable is that in the old version of the code if you were to write a lambda function like:
std::function<void ()> model = & { y_hat = X * b; rsq = as_scalar(1 - var(y - y_hat) / var(y)) };
but you forgot to add rsq to the model as a deterministic: m.deterministic(rsq);
then you would have a model that would appear to work correctly, but during the simulation, when a jump is rejected, the value of rsq would not be reverted with the other variables, since it was not 'registered' with the model (even though it was being updated in the lambda function). Does that make sense?
In the new version, you are forced to explicitly link a node to an 'update' function and it's arguments. So, in addition to being safer, you also capture the full dependency graph from this approach, which should open the door to alternative sampling methods (HMC, NUTS, etc.).
So, the most common deterministic functions are now standard and they are in files in the 'deterministic' folder. I don't think all of them have been added to the <cppbugs.hpp> header, so you'll have to include the headers individually in your code.
You can still use lambdas. There is an example here: https://github.com/armstrtw/hle.simulation/blob/master/src/hle.simulation.cpp#L197
and one referring to a previously defined function here: https://github.com/armstrtw/hle.simulation/blob/master/src/hle.simulation.cpp#L182
Hope that is enough to get you started. If you want to post some code up or email it to me, I can help you get it running.
-Whit