Calculates the second derivative for the AR(1) process and places it into a matrix form. The matrix form in this case is for convenience of the calculation.
deriv_2nd_ar1(phi, sigma2, tau)
A double
corresponding to the phi coefficient of an AR(1) process.
A double
corresponding to the error term of an AR(1) process.
A vec
containing the scales e.g. \(2^{\tau}\)
A matrix
with the first column containing the
second partial derivative with respect to \(\phi\) and
the second column contains the second partial derivative with
respect to \(\sigma ^2\)
Taking the second derivative with respect to \(\phi\) yields: $$\frac{{{\partial ^2}}}{{\partial {\phi ^2}}}\nu _j^2\left( \phi, \sigma ^2 \right) = \frac{2 \sigma ^2 \left(\left(\phi ^2-1\right) \tau _j \left(2 (\phi (7 \phi +4)+1) \phi ^{\frac{\tau _j}{2}-1}-(\phi (7 \phi +4)+1) \phi ^{\tau _j-1}+3 (\phi +1)^2\right)+\left(\phi ^2-1\right)^2 \tau _j^2 \left(\phi ^{\frac{\tau _j}{2}}-1\right) \phi ^{\frac{\tau _j}{2}-1}+4 (3 \phi +1) \left(\phi ^2+\phi +1\right) \left(\phi ^{\tau _j}-4 \phi ^{\frac{\tau _j}{2}}+3\right)\right)}{(\phi -1)^5 (\phi +1)^3 \tau _j^2} $$
Taking the second derivative with respect to \(\sigma^2\) yields: $$\frac{{{\partial ^2}}}{{\partial {\sigma ^4}}}\nu _j^2\left( \sigma ^2 \right) = 0 $$
Taking the derivative with respect to \(\phi\) and \(\sigma ^2\) yields: $$\frac{{{\partial ^2}}}{{\partial {\phi } \partial {\sigma ^2}}}\nu _j^2\left( \phi, \sigma ^2 \right) = \frac{2 \left(\left(\phi ^2-1\right) \tau _j \left(\phi ^{\tau _j}-2 \phi ^{\frac{\tau _j}{2}}-\phi -1\right)-(\phi (3 \phi +2)+1) \left(\phi ^{\tau _j}-4 \phi ^{\frac{\tau _j}{2}}+3\right)\right)}{(\phi -1)^4 (\phi +1)^2 \tau _j^2} $$