Skip to content

Seasonalisation of income #8

Description

@Brent-Morrison

The current seasonalisation applies equally to volume tariffs and service charges.

Service charges are not subject to usage seasonality and should experience linear growth.

Reference code per:

# Income 
tot_rev_nmnl <- tot_rev_real * infltn_factor * 1e3
incm2 <- t( apply( tot_rev_nmnl, 1, function(x) round( as.vector( sapply(X = x, FUN = add_trend_season, s=0, a=1, p=1.5) ), 3 ) ) )

Replacement (per GPT)

add_trend_season_vec <- function(y, s, a, p) {

  n <- length(y)

  # base monthly allocation
  base <- matrix(y / 12, nrow = n, ncol = 12)

  # trend (1 × 12)
  trend <- scale((1:12) * s, center = TRUE, scale = FALSE)

  # seasonality (1 × 12)
  seas <- scale(a * sin(seq(0, 2*pi, length.out = 12) + p),
                center = TRUE, scale = FALSE)

  # broadcast across rows
  base + matrix(trend + seas, nrow = n, ncol = 12, byrow = TRUE)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions