I have a random effects-only linear model as follows:
$$\mathbf{y_i = Z_ib_i + \epsilon_i,\quad i=1,...,N}$$ $$\mathbf{\epsilon_i \sim N(0,\sigma^2I)},\quad \mathbf{b_i \sim N(0,\sigma^2D)}$$
where $\mathbf{I}$ is an identity matrix and $\mathbf{D}$ a covariance matrix of size $n_i \times n_i$.
I am trying to find the MLE for $\mathbf{D}$ using the profile likelihood. For a sample $\mathbf{y_{i= 1,...,N}}$, the full likelihood function up to a constant term should be:
$$\ell(\theta) = -\frac{1}{2}\{(\sum_{i=1}^N n_i)\ln\sigma^2+\sum_{i=1}^N\left(\ln\det\left[\mathbf{I+Z_iDZ_i^T}\right] + \sigma^{-2}\mathbf{y_i^T\left[I+Z_iDZ_i^T\right]^{-1}y_i}\right)\}$$
Taking the profile with respect to $\sigma^2$ we end up with
$$\ell_p(\theta) = -\frac{1}{2}\{(\sum_{i=1}^N n_i)\ln\left[\sum_{i=1}^N y_i^T\left[\mathbf{I+Z_iDZ_i^T}\right]^{-1}y_i\right]+\sum_{i=1}^N\ln\det\left[\mathbf{I+Z_iDZ_i^T}\right]\}$$
Then the task at hand is to find the $\hat\theta=\mathbf{\hat D}$ which maximizes the expression.
My knowledge of matrix calculus is really basic. So far I've been able to find these potentially useful formulas:
$d\mathbf{_Ax^TAx} = \mathbf{x^Tx}$
$d_p\mathbf{A^{-1}} = \mathbf{-A^{-1}(}d_p\mathbf{A)A^{-1}}$
I assume some form of chain rule can then be applied using the above but I'm having a hard time parsing the whole thing.
Just in case someone's wondering, we were told to find the expression for $\ell_p(\theta)$ as homework but this part is an extra step I wanted to do.