@(@\newcommand{\B}[1]{ {\bf #1} }
\newcommand{\R}[1]{ {\rm #1} }
\newcommand{\W}[1]{ \; #1 \; }@)@This is dismod_at-20221105 documentation: Here is a link to its
current documentation
.
The only fixed effect in this model is @(@
\theta
@)@
(sometimes written
theta
) the incidence level for the world.
The random effects are @(@
u_0
@)@ and @(@
u_1
@)@.
Implicit Function Definition
The optimal random effects @(@
\hat{u} ( \theta )
@)@
solve the equation
@[@
f_u [ \theta , \hat{u} ( \theta ) ] = 0
@]@
Derivatives of Optimal Random Effects
Using the implicit function theorem we have
@[@
\hat{u}^{(1)} ( \theta )= -
f_{u,u} [ \theta , \hat{u} ( \theta) ]^{-1}
f_{u,\theta} [ \theta , \hat{u} ( \theta) ]
@]@
Substituting in the formulas above for the Hessian terms on the
right hand side we obtain:
@[@
\hat{u}_i^{(1)} ( \theta ) = - \frac{
2 \theta \exp[ 2 \hat{u}_i ( \theta) ] -
y_i \exp[ \hat{u}_i ( \theta) ]
}{
2 \theta^2 \exp[ 2 \hat{u}_i ( \theta) ] -
y_i \theta \exp[ \hat{u}_i ( \theta) ] + 1
}
@]@
We can compute @(@
\hat{u}_i ( \theta )
@)@ by optimizing the
random effects corresponding to the fixed effects being @(@
\theta
@)@.
We define @(@
g_i ( \theta )
@)@ by the equation
@[@
g_i ( \theta ) = 2 \theta \exp[ 2 \hat{u}_i ( \theta) ]
- y_i \exp[ \hat{u}_i ( \theta ) ]
@]@
Give @(@
\hat{u}_i ( \theta )
@)@ we can compute @(@
g_i ( \theta )
@)@.
Given @(@
g_i ( \theta )
@)@, we can compute
the derivative @(@
\hat{u}_i^{(1)} ( \theta )
@)@ using
@[@
\hat{u}_i^{(1)} ( \theta ) = -
\frac{ g_i ( \theta ) }{ \theta g_i ( \theta ) + 1}
@]@
Given @(@
\hat{u}^{(1)} ( \theta )
@)@, we can compute
the derivative @(@
g_i^{(1)} ( \theta )
@)@ using
@[@
g_i^{(1)} ( \theta ) =
2 \exp[ 2 \hat{u}_i ( \theta) ] +
\left(
4 \theta \exp [ 2 \hat{u}_i ( \theta ) ] -
y_i \exp [ \hat{u}_i ( \theta ) ]
\right) \hat{u}_i^{(1)} ( \theta )
@]@
Given @(@
g_i^{(1)} ( \theta )
@)@, we can compute
the second derivative @(@
\hat{u}_i^{(2)} ( \theta )
@)@ using
@[@
\hat{u}_i^{(2)} ( \theta ) =
\frac{ g_i ( \theta ) [ g_i ( \theta ) + \theta g_i ^{(1)} ( \theta ) ] }
{ [ \theta g_i ( \theta ) + 1 ]^2 }
-
\frac{ g_i ^{(1)}( \theta ) }{ \theta g_i ( \theta ) + 1}
@]@
@[@
\hat{u}_i^{(2)} ( \theta ) =
\frac{ g_i ( \theta )^2 - g_i ^{(1)}( \theta )}
{ [ \theta g_i ( \theta ) + 1 ]^2 }
@]@
Given @(@
\hat{u}^{(2)} ( \theta )
@)@, we can compute
the second derivative @(@
g_i^{(2)} ( \theta )
@)@ using
@[@
\begin{array}{rcl}
g_i^{(2)} ( \theta ) & = &
8 \exp[ 2 \hat{u}_i ( \theta) ] \hat{u}_i^{(1)} ( \theta )
\\ & + &
\left(
8 \theta \exp [ 2 \hat{u}_i ( \theta ) ] -
y_i \exp [ \hat{u}_i ( \theta ) ]
\right) \hat{u}_i^{(1)} ( \theta )^2
\\ & + &
\left(
4 \theta \exp [ 2 \hat{u}_i ( \theta ) ] -
y_i \exp [ \hat{u}_i ( \theta ) ]
\right) \hat{u}_i^{(2)} ( \theta )
\end{array}
@]@
Laplace Approximation
Up to a constant, the Laplace approximation (fixed effects objective),
as a function of the fixed effects, is:
@[@
L ( \theta ) = F( \theta ) + G( \theta )
@]@
where @(@
F( \theta )
@)@ and @(@
G( \theta )
@)@ are defined by
@[@
F( \theta ) = f[ \theta , \hat{u} ( \theta ) ]
@]@
@[@
G( \theta ) =\frac{1}{2} \log \det f_{u,u} [ \theta , \hat{u} ( \theta ) ]
@]@
The derivative of @(@
F( \theta )
@)@ is given by
@[@
F^{(1)} ( \theta ) =
f_\theta [ \theta , \hat{u} ( \theta ) ] +
f_u [ \theta , \hat{u} ( \theta ) ] \hat{u}^{(1)} ( \theta )
@]@
It follows from the definition of @(@
\hat{u} ( \theta )
@)@ that
@(@
f_u [ \theta , \hat{u} ( \theta ) ] = 0
@)@ and
@[@
F^{(1)} ( \theta ) = f_\theta [ \theta , \hat{u} ( \theta ) ]
@]@
Taking the derivative of the equation above we obtain
@[@
F^{(2)} ( \theta ) =
f_{\theta,\theta} [ \theta , \hat{u} ( \theta ) ] +
f_{\theta,u} [ \theta , \hat{u} ( \theta ) ] \hat{u}^{(1)} ( \theta )
@]@
Combining the definition of @(@
G( \theta )
@)@, @(@
g_i ( \theta )
@)@
and the formula for @(@
f_{u,u} ( \theta , u )
@)@ we have
@[@
G( \theta )
=
\frac{1}{2} \log \det \left(
\begin{array}{cc}
[ \theta g_0 ( \theta ) + 1 ] / s^2 & 0
\\
0 & [ \theta g_1 ( \theta ) + 1 ] / s^2
\end{array}
\right)
@]@
Defining @(@
h_i ( \theta )
@)@ by
@[@
h_i ( \theta ) = \theta g_i ( \theta ) + 1
@]@
we obtain the representation
@[@
G ( \theta ) =
+ \frac{1}{2} \left(
\log [ h_0 ( \theta ) ] + \log [ h_1 ( \theta ) ] - \log ( s^4 )
\right)
@]@
The first and second derivative of @(@
h_i ( \theta )
@)@
and @(@
G( \theta )
@)@ are given by
@[@
h_i^{(1)} ( \theta ) = g_i ( \theta ) + \theta g_i^{(1)} ( \theta )
@]@
@[@
G^{(1)} ( \theta ) =
\frac{1}{2} \left(
\frac{ h_0^{(1)} ( \theta ) }{ h_0 ( \theta ) }
+
\frac{ h_1^{(1)} ( \theta ) }{ h_1 ( \theta ) }
\right)
@]@
@[@
h_i^{(2)} ( \theta ) = 2 g_i^{(1)} ( \theta ) + \theta g_i^{(2)} ( \theta )
@]@
@[@
G^{(2)} ( \theta ) =
\frac{1}{2} \left(
\frac{ h_0 ( \theta ) h_0^{(2)} ( \theta ) - h_0^{(1)} ( \theta )^2 }
{ h_0 ( \theta )^2 }
+
\frac{ h_1 ( \theta ) h_1^{(2)} ( \theta ) - h_1^{(1)} ( \theta )^2 }
{ h_1 ( \theta )^2 }
\right)
@]@
Asymptotic Statistics
The asymptotic posterior distribution for the optimal estimate of
@(@
\theta
@)@ give the data @(@
y
@)@
is a normal with variance equal to the inverse of
@[@
L^{(2)} ( \theta ) = F^{(2)} ( \theta ) + G^{(2)} ( \theta )
@]@
Scaling Fixed Effects
If eta
is not null,
the Hessian is with respect to @(@
\alpha = \log( \theta + \eta )
@)@.
Inverting this relation we define
@(@
\theta ( \alpha ) = \exp( \alpha ) - \eta
@)@.
The fixed effects objective as a function of @(@
\alpha
@)@ is
@[@
H( \alpha ) =
L[ \theta ( \alpha ) ] =
F[ \theta( \alpha ) ] + G[ \theta( \alpha ) ]
@]@
Taking the first and second derivatives, we have
@[@
H^{(1)}( \alpha ) = \left(
F^{(1)}[ \theta( \alpha ) ] + G^{(1)}[ \theta( \alpha ) ]
\right) \exp( \alpha )
@]@
@[@
\begin{array}{rcl}
H^{(2)}( \alpha ) & = & \left(
F^{(1)}[ \theta( \alpha ) ] + G^{(1)}[ \theta( \alpha ) ]
\right) \exp( \alpha )
\\ & + &
\left(
F^{(2)}[ \theta( \alpha ) ] + G^{(2)}[ \theta( \alpha ) ]
\right) \exp( 2 \alpha )
\end{array}
@]@
Optimal Fixed Effects
The first order necessary conditions for
@(@
\hat{\alpha}
@)@
to be a minimizer of the fixed effects object is
@(@
H^{(1)} ( \hat{\alpha} ) = 0
@)@.
In this case we can simplify the Hessian scaling as follows:
@[@
\begin{array}{rcl}
H^{(2)}( \hat{\alpha} ) & = & \left(
F^{(2 }( \hat{\theta} ) + G^{(2)}( \hat{\theta} )
\right) \exp( 2 \hat{\alpha} )
\\ & = &
L^{(2)} ( \hat{\theta} ) \exp( 2 \hat{\alpha} )
\end{array}
@]@
where @(@
\hat{\theta} = \theta( \hat{\alpha} )
@)@.