Skip to contents

Computes the coefficients for Fisher's Linear Discriminant Function for each group (population/stock). This implementation assumes a common (pooled) covariance matrix across all groups, a standard assumption for LDA. The LDF is of the form: LDF_j(x) = C_j0 + C_j1x1 + ... + C_jpxp.

Usage

compute_ldf_coefficients(baseline)

Arguments

baseline

A list of numeric matrices, where each matrix represents the baseline (training) data for one population/stock. Each matrix should have observations as rows and variables as columns.

Value

A numeric matrix of LDF coefficients. Rows correspond to populations, and columns correspond to variables followed by the constant term. The dimensions are (np x (nv + 1)).

Examples

# Create dummy baseline data for 2 stocks with 2 variables
stock1_data <- matrix(rnorm(20, mean = 0), ncol = 2)
stock2_data <- matrix(rnorm(20, mean = 1), ncol = 2)
baseline_list <- list(StockA = stock1_data, StockB = stock2_data) # Named list
ldf_coeffs <- compute_ldf_coefficients(baseline_list)
print(ldf_coeffs)
#>              Var1       Var2    Constant
#> StockA -0.3372579 -0.1410113 -0.06554944
#> StockB  1.0428377  1.1710608 -1.10531500