Learn R Programming

PortfolioTesteR (version 0.1.4)

combine_scores: Combine multiple score panels (mean / weighted / rank-average / trimmed)

Description

Combine several wide score panels (Date + symbols) into a single panel by applying one of several aggregation methods.

Usage

combine_scores(
  scores_list,
  method = c("mean", "weighted", "rank_avg", "trimmed_mean"),
  weights = NULL,
  trim = 0.1
)

Value

A data.table with columns Date + symbols, containing the combined scores.

Arguments

scores_list

List of wide score panels to combine (each has columns Date + symbols).

method

Character, one of "mean", "weighted", "rank_avg", "trimmed_mean".

weights

Optional numeric vector of length equal to length(scores_list); used only when method = "weighted".

trim

Numeric in [0, 0.5); fraction to trim from each tail for method = "trimmed_mean".

Details

  • method = "mean": simple column-wise mean across panels.

  • method = "weighted": weighted mean; see weights.

  • method = "rank_avg": average of within-date normalized ranks.

  • method = "trimmed_mean": mean with trim fraction removed at both tails.