You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We calibrate this model data simulated from it, but start away from the true parameter values by specifying that the default `lambda0 = 0.2` and `n = 0.5`. We assume a Poisson likelihood to match the Poisson noise that we used to produce the simulated data. For numerical stability, we optimize `lambda0` and `n` on the log and logit scales respectively.
172
+
We calibrate this model data simulated from it, but start away from the true parameter values by specifying that the default `lambda0 = 0.2` and `alpha = 0.5`. We assume a Poisson likelihood to match the Poisson noise that we used to produce the simulated data. For numerical stability, we optimize `lambda0` and `alpha` on log scales.
173
173
```{r calibration}
174
174
calibrator = (spec_for_cal
175
-
|> mp_tmb_update(default = list(lambda0 = 0.2, n = 0.5))
@@ -190,13 +190,30 @@ The convergence code is `0`, which is good.
190
190
mp_optimizer_output(calibrator)$convergence
191
191
```
192
192
193
-
The true parameters, `lambda0 = 0.38` and `n = 0.2`, are in the confidence intervals, although the confidence interval for `n` is quite wide.
193
+
But the covariance matrix of the parameter estimates indicate that `lambda0` and `alpha` are highly correlated, indicating that there is little information in the data allowing us to disintangle baseline transmission, `lambda0`, from heterogeneity and mixing, `alpha`.
194
+
```{r correlation}
195
+
covmat = mp_tmb_fixef_cov(calibrator)
196
+
print(covmat)
197
+
cov2cor(covmat)
198
+
```
199
+
200
+
Nevertheless, the true parameters, `lambda0 = 0.36` and `alpha = 0.2`, are in the confidence intervals, although the confidence interval for `alpha` is quite wide.
194
201
```{r estimates}
195
-
(mp_tmb_coef(calibrator, conf.int = TRUE)
196
-
|> select(-term, -row, -col, -type)
202
+
true_coefs = (spec_for_cal
203
+
|> mp_default()
204
+
|> filter(matrix %in% c("alpha", "lambda0"))
205
+
|> select(-row, -col)
206
+
|> rename(mat = matrix, true = value)
197
207
)
208
+
estimated_coefs = (calibrator
209
+
|> mp_tmb_coef(, conf.int = TRUE)
210
+
|> select(-term, -row, -col, -type)
211
+
)
212
+
left_join(estimated_coefs, true_coefs)
198
213
```
199
214
215
+
(note that `default` gives the starting values for the optimizer, `estimate` the estimated value, and `true` the value used in simulation.)
216
+
200
217
The simulated data (black) that we fit to matches the predictions of the fitted model (red) with 95% confidence intervals for the point prediction).
0 commit comments