I want to estimated the parameters $\ \hat{\theta} $ of a model using an iterative search for the minimum of a cost function. The cost function is defined as follows:
$$ V_N(\hat{\theta}) = \frac{1}{N}\sum_{i=1}^N(y(t_k)-\hat{y}(t_k|\theta))^2 $$
where $\ y $ is the output of the system and $\ \hat{y} $ is the estimated output of the system. The system is described by the following differential equations:
$$ \dot{h}(t) = -\theta\sqrt{2g}\sqrt{h(t)}+u(t) $$
$$ \hat{y}(t|\theta) = \theta\sqrt{2g}\sqrt{h(t)} $$
where $\ u $ is the input to the system. Suppose that data for both input and output of the system are collected and available. The equation for updating the estimate for the unknown parameters $\ \theta $ is:
$$ \hat{\theta}_{i+1} = \hat{\theta}_i-μ_i[\frac{d^2}{d\theta^2}(V_N(\hat{\theta}))]^{-1}\frac{d}{d\theta}(V_N(\hat{\theta})) $$ where $\ μ_i $ is a step length determined so that: $\ V_N(\hat{\theta}_{i+1}) < V_N(\hat{\theta}_i) $. The derivatives of the cost function are:
$$ \frac{d^2}{d\theta^2}(V_N(\hat{\theta})) = \frac{1}{N}\sum_{i=1}^N(\frac{d}{d\hat{\theta}}\hat{y}(t_i|\hat{\theta}))((\frac{d}{d\hat{\theta}}\hat{y}(t_i|\hat{\theta}))^T-\frac{1}{N}\sum_{i=1}^N\frac{d^2}{d\hat{\theta}^2}(\hat{y}(t_i|\hat{\theta}))(y(t_i)-\hat{y}(t_i|\hat{\theta})) $$
which by neglecting the second sum comes down to the Gauss-Newton Method. Considering this the whole problem is solved by finding the way to compute:
$$ ψ(t,\hat{\theta})=\frac{d}{d\hat{\theta}}\hat{y}(t|\hat{\theta}) $$
By working out the math, the following differential equations are obtained:
$$ z(t,\hat{\theta}) = \frac{d}{d\hat{\theta}}x(t,\hat{\theta}) $$ $$ \frac{d}{dt}z(t,\hat{\theta}) = -\frac{\hat{\theta}\sqrt{2g}}{2\sqrt{x(t,\hat{\theta})}}z(t,\hat{\theta})-\sqrt{2gx(t,\hat{\theta})} $$
$$ ψ^T(t,\hat{\theta}) = \frac{d}{d\hat{\theta}}\hat{y}(t,\hat{\theta}) = \frac{\hat{\theta}\sqrt{2g}}{2\sqrt{x(t,\hat{\theta})}}z(t,\hat{\theta})+\sqrt{2gx(t,\hat{\theta})} $$
In order to calculate $\ \frac{d}{d\hat{\theta}}{\hat{y}(t,\hat{\theta})} $ we need to first compute $\ x(t,\hat{\theta}) $ and $\ z(t,\hat{\theta}) $ since $\ g $ is the gravity constant. Suppose that we have an initial guess for the value of $\ \hat{\theta} $, now $\ x(t,\hat{\theta}) $ is obtained by the differential equation $\ \dot{x}(t,\hat{\theta}) $ since we also have the value of the input data $\ u $ and some initial condition for $\ x(t,\hat{\theta}) $. My question is how to compute $\ z(t,\hat{\theta}) $ since there are two equations which give as output $\ z(t,\hat{\theta}) $ ?
Is the sequence in which the equations should be computed the following:
- Compute $\ x(t,\theta) $
- Compute $\ z(t,\theta) $
- Compute $\ \frac{d}{d\theta}\hat{y}(t,\theta) $
- Compute $\ \frac{d^2}{d\theta^2}V_N(\theta $
- Compute $\ \frac{d}{d\theta}V_N(\theta) $
- Update estimation of $\ \hat{\theta} $
Would an ODE solver of MATLAB do the work in one bunch ?