About this question

Factor Model Residual Decomposition

Medium · machine_learning · Quant Researcher interview question · factor_model, ols_regression, idiosyncratic_variance, r_squared, residual_decomposition, machine_learning

Linear factor models decompose asset returns into a systematic component explained by common factors and an idiosyncratic, asset-specific residual. Calculating the idiosyncratic variance and R-squared per asset is essential for portfolio construction, risk management, and alpha decay analysis. This process is performed by running an Ordinary Least Squares (OLS) regression for each asset against the set of common factors. Task Implement the function factor_residual_decomp(returns, factors) that