Skip to contents

Door lookback window pooling across units

Usage

door_lookback(
  conn_counts,
  unit_row_indices,
  lookback_sizes,
  aggregate_mean = FALSE,
  weighting_linear = FALSE,
  segment_ids = integer()
)

Arguments

conn_counts

Numeric matrix of connection counts

unit_row_indices

List of integer vectors of row indices (0-indexed or 1-indexed R converted)

lookback_sizes

Integer vector of lookback sizes per unit

aggregate_mean

Logical: TRUE = mean, FALSE = sum

weighting_linear

Logical: TRUE = linear weights, FALSE = equal

segment_ids

Optional integer vector of segment IDs

Examples

counts <- matrix(c(1, 0,
                   2, 1,
                   5, 5,
                   6, 5), nrow = 4, byrow = TRUE)
# two units, rows given 0-based; each unit pools within its own rows
door_lookback(counts, list(c(0L, 1L), c(2L, 3L)), lookback_sizes = c(2L, 2L))
#>      [,1] [,2]
#> [1,]    1    0
#> [2,]    3    1
#> [3,]    5    5
#> [4,]   11   10