MRM (Multilevel Reconciliation Methodology) applied to person-days: the same confinement appears at three strata in the OTIS release and they do not automatically agree.
Usage
mrm_otis_stock_flow(
person_days,
placements = NULL,
totals = NULL,
year_col = "EndFiscalYear",
id_col = "UniqueIndividual_ID",
days_col = "TotalAggregatedDays_Segregation",
consecutive_col = "NumberConsecutiveDays_Segregation",
placement_col = "Number_Of_Placements",
totals_col = "NumberIndividuals_Segregation",
t = 365,
exposure = NULL,
per = 1e+05
)Arguments
- person_days
Data frame at the PERSON stratum: one row per individual per period, with a period column, an identifier column and a column of days served.
- placements
Optional data frame at the PLACEMENT stratum, used only for reconciliation: rows per individual per spell, with the consecutive-days and placement-count columns.
- totals
Optional data frame at the AGGREGATE stratum, one or more rows per period carrying a stated total of individuals.
- year_col
Period column name, present in every stratum given.
- id_col
Identifier column in
person_daysandplacements.- days_col
Days column in
person_days.- consecutive_col
Consecutive-days column in
placements.- placement_col
Placement-count column in
placements.- totals_col
Stated-total column in
totals.- t
Length of each period in days. Default 365.
- exposure
Optional population to express rates against, one value or one per period.
- per
Rate denominator when
exposureis given. Default 100000.
Value
A list with:
stock_flow: the measures per period, fromrmoriebricklayer::stock_flow().reconciliation: one row per period comparing the strata – people at the person and placement strata, the stated aggregate total, whether they agree, and the ratio of summed consecutive days to person-days.strata_agree:TRUEwhen every stratum given agrees on the number of people in every period.decomposition_exact:TRUEwhen the change in days is recovered by the changes in people and stay.
Details
PERSON stratum (b02): one row per individual per year, carrying the days that person served across the year. This is the additive quantity, and the one Lakner's measures need.
PLACEMENT stratum (b01): several rows per individual, carrying the consecutive days of a spell and the count of placements. Spell lengths are NOT an additive share of the year.
AGGREGATE stratum (c01): the yearly totals stated directly.
Reconciling them is the point. Summing the placement stratum's consecutive days as though they were person-days understates the total by about a third on the published release, and the two strata can disagree about how many people there even were. Both are reported rather than assumed away.
The measures themselves come from rmoriebricklayer: the average
daily population is days per day, the average length of stay is days
per person, and a change in days decomposes exactly into a change in
people and a change in stay. After Lakner, A Manual of Statistical
Sampling Methods for Corrections Planners (University of Illinois at
Urbana-Champaign, 1976), p.15-18.
References
Lakner, E. (1976) A Manual of Statistical Sampling Methods for Corrections Planners. University of Illinois at Urbana-Champaign.
Examples
# needs rmoriebricklayer (>= 0.4.8) for adp()/alos()/stock_flow()
if (utils::packageVersion("rmoriebricklayer") >= "0.4.8") {
person <- data.frame(
EndFiscalYear = c(rep(2023, 3), rep(2025, 2)),
UniqueIndividual_ID = c("a", "b", "c", "a", "d"),
TotalAggregatedDays_Segregation = c(10, 20, 30, 40, 50))
mrm_otis_stock_flow(person)$stock_flow
}
#> ── Stock and flow over 2 periods ─────────────────────────────────
#> period people days alos adp
#> 2023 3 60 20 0.1643836
#> 2025 2 90 45 0.2465753
#>
#> 2023 to 2025: people -33.3%, stay +125.0%, days +50.0%
#> ──────────────────────────────────────────────────────────────────
