| reestimate | R Documentation |
Estimates every transition rate of the model from the life courses it
produced and compares each estimate with the rate that was supplied.
simulate() does this automatically and stores
the result as result$reestimation. You can call reestimate() to redo it
with other settings. plot() supplies comparison plots.
reestimate(x, ...)
## S3 method for class 'micsim_result'
reestimate(x, width = NULL, groups = 3L, axis = NULL, ...)
x |
A |
... |
Not used. |
width |
Width of the bands, in years. |
groups |
Maximum number of periods of a second time scale, from 1 to 3. Fewer are used when there are few events (each period needs at least 150 events) or when the rate changes by less than 25% along the second scale. |
axis |
The main time scale for rates that depend on more
than one: |
For each transition declared with transition():
the risk set is the time spent in any of a transition's origin states, and an event is a move into its destination;
the rate is shown along its main time scale: age, or
duration in the state if the rate does not use age, or calendar time if
it uses neither (axis chooses another);
the main time scale is cut into bands (1 year unless the observed range is short), and in each band the occurrence/exposure rate (events divided by person-years) is computed, with an exact 95% Poisson confidence interval. Although the bands lie along one scale, the supplied rate is always evaluated at every time scale it takes;
a smooth curve is fitted to the bands by Poisson regression with a natural cubic spline, knots at quantiles of the event times and their number chosen by AIC, over the range in which events occurred, with a pointwise 95% confidence interval;
the expected number of events in each band is each person's
exposure there times the supplied rate at their own age, calendar time
and duration, summed over everyone at risk. observed / expected near 1
means the simulated population reproduces the supplied rate.
Rates with more than one time scale. Suppose a mortality rate depends on age and calendar time, and age is its main time scale. The band estimate at age 60 then reflects everyone who was 60 during the run, in whatever calendar years that happened. So it is compared with the supplied rate averaged over those people, not with the rate in one particular year. The plot also shows the 10th to 90th percentile of the supplied rate among them, so you can see how much it varies with calendar time.
If that variation is large (more than 25%), the whole comparison is also done separately for up to three periods of calendar time, each with the same number of person-years, so the plot shows how the rate changes over time.
Rates that are Inf somewhere (forced transitions, such as school
enrolment at a set age) have no finite rate to estimate. They are reported
with their bands, but without a smooth curve or an expected count.
The band estimates treat the rate as constant within each band. They therefore differ from the supplied rate by Monte Carlo error, which the confidence intervals show, and by however much the rate changes within a band.
An object of class micsim_reestimation. This is a named list with
one element per declared transition. Each element holds
label, titlethe transition as text and as a plot title.
axis, group_by, groupsthe main time scale, the second
time scale the bands are grouped by (or NA), and a data frame
with one row per period of the second scale: its limits (lo,
hi), its person-year-weighted average (at)
and the label used in the plot.
Without a second scale there is a single row.
bandsone row per band and group: group, lower,
upper, mid, events, exposure, rate, ci_lower,
ci_upper, expected.
smooththe fitted curve: group, x, rate, lower,
upper.
truththe supplied rate on a fine grid: group, x,
rate, and, for a rate that also depends on another time scale,
lower and upper, the 10th and 90th percentile over the people at
risk (rate is then their mean).
events, exposure, expected, ratio, ratio_citotals, observed / expected, and its exact 95% Poisson interval. If the simulation reproduces the supplied rate, the interval covers 1 in at least 95% of runs.
forced, noteswhether the rate is Inf somewhere, and
anything the plot should say.
as.data.frame() stacks the bands of all transitions.
plot.micsim_reestimation(), simulate.micsim_model()
mort <- function(age) 0.0005 * exp(0.07 * age)
model <- micsim_model(
state_space(sex = c("m", "f")),
transitions(transition(NA, "dead", mort)),
data.frame(ID = 1:300, birthDate = "19500101", initState = "f"),
horizon = c(20000101, 20291231)
)
result <- simulate(model, seed = 1)
result$reestimation
head(as.data.frame(result$reestimation))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.