I am trying fit a Bayesian time series model that is derived by discretizing an ordinary differential equation. Here’s a description of a simplified version of the model.
Consider an insulated box at a (time-dependent) temperature T_c in an ambient environment at a (time-dependent) temperature T_h. Assume a simple heat conduction model where the thermal resistance of the box is R and the heat capacity of the air in the box is C. Then the differential equation describing the box temperature is the following:
After doing a first-order discretization of the derivative, we arrive at the following difference equation:
Or, after collecting the T_c^{(k-1)} terms:
Now if we turn this into a Bayesian model, it looks something like the following:
From perusing similar threads on Discourse, it sounds like creating the T_c^{(k)} variables in a for
loop is not recommended. And it appears that pm.AR
cannot be used here, because the \frac{\Delta t}{RC} T_h^{(k-1)} term is not constant—it changes at each time step since T_h is time-dependent. So, is there a way to represent this model in pymc?