
Borrow missing per-segment factors across segments (segment_bridged_borrowed)
Source:R/utils.R
dot-borrow_segment_factors.RdAugments a per-segment factor table so every segment carries a factor
for the full development range, borrowing the entries a segment cannot
estimate from a donor segment that can. Used only by the
"segment_bridged_borrowed" treatment: early-development factors stay
regime-specific (each segment's own estimate), while late-development
factors a segment never reaches are filled from another segment.
Donor rule (“recent”): for each (group, dev) the donor is the
segment with the largest segment_id that has a non-NA primary
factor at that dev – i.e. the most recent regime whose own cohorts
developed that far. The bridged band guarantees a donor exists at every
dev that any segment needs (the boundary factor gaps are closed by the
bridge), so no dev is left unfilled.
The borrow only adds rows for (segment, dev) combinations the
segment lacks; rows a segment owns are never overwritten.
Arguments
- sel
A
data.tableof per-segment factors with columnsgroups,dev_col,segment_id, andfactor_cols(plus optionalata_to/ata_linkcarried along).- groups
Character vector of group columns (may be empty).
- dev_col
Single column name holding the development index (
"dev"after the projection-time rename).- factor_cols
Character vector of factor columns to borrow. The first element is the primary factor (
"f_sel"/"g_sel") whose non-NApresence defines whether a segment owns a dev.