can deterministic nodes be data?

90 views
Skip to first unread message

Stephen Catterall

unread,
Mar 19, 2025, 10:33:57 AM3/19/25
to nimble-users
Hi, apologies if this is a silly question but I'm very new to NIMBLE. I'm looking at a model where the observations are a deterministic function of model parameters and something stochastic: observation x[i]=f(theta,y[i]) where theta is a model parameter, and y[i] is stochastic (normally distributed in fact). If, instead, I had x[i]=f(y[i]) then I could calculate f^{-1}(x[i]) and focus on modelling these as normally distributed, but it is not so straightforward because of the dependence on the model parameter theta. So, is it possible to have deterministic nodes as data? the manual says not. Or is it possible to work around this issue somehow?
Thanks,
Stephen

Perry de Valpine

unread,
Mar 19, 2025, 10:52:37 AM3/19/25
to Stephen Catterall, nimble-users
Hi Stephen,

No, it is not possible to have a deterministic node be data.

In most cases I have seen where people want to do this (but there are exceptions), a rearrangement of thinking results in seeing the actual observed datum as stochastic. For example, if y[i] follows a distribution, then the function f(theta, y[i]) follows a distribution that can be derived from y[i]'s distribution. If you can write that out, then you can code it in a nimbleFunction and use that as a user-defined distribution for x[i]. Of course, that assumes y[i] is unobserved.

If you really need to work around the system more, another trick is to provide a dummy data value that you declare to be a stochastic node with a user-defined distribution, and then calculate whatever log probability you want to contribute to the model.
Example:
dtricky <- nimbleFunction(...) # see user manual on writing a user-defined distribution
Model code:
dummy[i] ~ dtricky(x[i], theta, y[i])
This results in calls to dtricky as:
<contribution to log probability or likelihood> = dtricky(dummy[i], x[i], theta, y[i])

So dummy[i] can serve simply to place a log probability calculation in the DAG that will be seen as depending on x[i], theta, and y[i].

HTH
Perry


--
You received this message because you are subscribed to the Google Groups "nimble-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nimble-users...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/nimble-users/c4940579-feb1-4d29-9579-049307c80f55n%40googlegroups.com.

Stephen Catterall

unread,
Mar 19, 2025, 11:07:31 AM3/19/25
to nimble-users
Hi Perry,
Many thanks for your helpful and quick reply. It's a phenological model where x[i] is the observed time that a plant opens its buds in the spring, y[i] is the corresponding "thermal time" measured in growing degree days, and theta determines when the plant is released from dormancy over the winter. f is a kind of time transformation. So, from this point of view, x[i] follows a transformed normal distribution where some parts are stretched out and other bits squeezed according to the temperature profile at the growing site. I'll try defining a user-defined distribution and if that proves difficult will try something like your second suggestion.
Stephen
Reply all
Reply to author
Forward
0 new messages