@(@\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
.
Purpose
This example shows how to fit one function of two variables given
direct measurements of the function.
For our example, we are give measurements of prevalence,
as a function of age and time, and fit a function to the measurements.
rho
We use
rho
as a surrogate for prevalence because our model for prevalence
does not use
rho
(we could have used any other rate
and its corresponding integrand).
Random Effects
To keep this example simple, there is only one node world
in the node_table
, and the
subgroup_smooth_id
is null in the mulcov_table.
Hence, there are not random effects in this example.
Covariates
Income is the only covariate for this example and it has been normalized
to be between zero and one. The income reference value corresponds to
no effect. The income multiplier is the true value used to simulate the
data.
The
income_mulcov_type
can be either "meas_value" or
"rate_value".
It should not make a difference in the results which
mulcov_type
is used because
there is only one rate (one function) being fit, and the
ode
is not needed to compute
the integrand.
You can test this by changing
income_mulcov_type
to
"rate_value"
and uses the same random_seed
.
Data Density
A direct measurement of
rho
(which we are using to represent prevalence) corresponds to the
remission integrand
.
We use a log_gaussian
model with the following parameters:
prevalence_sigma = 0.1
prevalence_eta = 1e-6
True Prevalence
For simulating our prevalence data we consider the case where
all the rates are constant and
rho
,
chi
are zero; i.e.,
the differential equation is
@[@
\begin{array}{rcl}
S'(a) = -( \iota + \omega ) S(a)
\\
C'(a) = + \iota S(a) - \omega C(a)
\end{array}
@]@
where @(@
S(0) = 1
@)@ and @(@
C(0) = 0
@)@.
It follows that
@[@
S(a) = \exp[ - ( \iota + \omega ) a ]
@]@
@[@
C(a)
= \int_0^a \exp[ \omega (s - a) ] \iota S(s) ds
@]@
You can check the formula for @(@
C(a)
@)@ as follows:
differentiating w.r.t. @(@
a
@)@ inside the integral yields
@(@
- \omega C(a)
@)@ and differentiating the upper limit
w.r.t. @(@
a
@)@ yields @(@
\iota S(a)
@)@.
It follows that
@[@
C(a) = \iota \int_0^a \exp[ \omega (s - a) - ( \iota + \omega) s ] ds
@]@
@[@
C(a) = \iota \exp( - \omega a) \int_0^a \exp( - \iota s ) ds
@]@
@[@
C(a) = \exp( - \omega a) - \exp[ - ( \iota + \omega) a ]
@]@
defPrevalence(age) :
# rho and chi are zero for this simulation of prevalence data
iota = 1e-4 # incidence used to simulate prevalence data
omega = 1e-2 # other cause mortality used to simulate prevalence data
exp_omega = exp(-omega * age)
exp_sum = exp(-(iota + omega) * age)
S = exp_sum
C = exp_omega - exp_sum
return C / (S + C)
Computing Delta
Once we have simulated a measurement value,
we can solve for @(@
\Delta
@)@ are follows; see
sigma
:
@[@
\sigma = \log( y + \eta + \Delta ) - \log(y + \eta )
@]@
@[@
\exp ( \sigma ) = \frac{ y + \eta + \Delta }{ y + \eta }
@]@
@[@
\exp ( \sigma ) ( y + \eta ) = y + \eta + \Delta
@]@
@[@
\Delta = [ \exp ( \sigma ) - 1 ] ( y + \eta )
@]@
For this case there are no measurement noise covariates so
@(@
\sigma
@)@ is the standard deviation for the simulated data.
Furthermore, the
minimum_meas_cv
is zero,
so @(@
\Delta
@)@ is the
meas_std
.
Prevalence Prior
Prevalence must always be between zero and one so this limits are used
in the prior for prevalence.
Some functions might allow for negative values and the lower limit
for the rate would be negative in that case.
random_seed
We use the clock to choose a seed for the random number generator.
If an error occurs, the seed will be printed so that the error can be
reproduced. You can also use a fixed value for the random seed to see
how changing other parameters changes the results.