SPB Git

Repository Public

job_pca.json 40.6 KB 2 lines json

1{"job":{"id":"6880f177-40f8-458e-a83b-b662647feee5","tool":"pca","params":{"symbols":["AAPL","MSFT","NVDA","GOOGL","AMZN","JPM"],"basis":"correlation","return_type":"log","frequency":"daily","data_period":756,"n_components":5,"rolling_window":126,"absorption_fraction":0.2},"status":"done","startedAt":1795211368533,"finishedAt":1795211379493,"error":null,"progress":1,"engineVersion":"1.0.0","durationMs":10960,"projectId":null,"sessionId":null,"cancellable":false,"code":"import numpy as np, pandas as pd\n# px: adjusted closes, one column per symbol (AAPL, MSFT, NVDA, GOOGL, AMZN, JPM), common sessions, daily\npx = pd.read_csv(\"closes.csv\", index_col=0, parse_dates=True).dropna()\nr = np.log(px / px.shift(1)).dropna().loc[\"2023-11-11\":]\nC = r.corr().to_numpy()\nlam, V = np.linalg.eigh(C); lam, V = lam[::-1], V[:, ::-1]\nprint(\"explained:\", lam / lam.sum())\nT, N = r.shape\nprint(\"Marchenko-Pastur upper bound:\", 1.0 * (1 + np.sqrt(N / T)) ** 2)","result":{"success":true,"schema":"lab/1","engine":"pca","engineVersion":"1.0.0","title":"Principal components","headline":"PCA of 6 assets over 759 daily returns (2023-11-13 → 2026-11-20, correlation basis): PC1 explains 46.9% of the variance with loadings all of the same sign (a market mode); 1 component above the Marchenko-Pastur noise bound.","summary":[{"label":"Assets","value":6,"unit":"count","kind":"observed"},{"label":"Observations","value":759,"unit":"count","kind":"observed"},{"label":"PC1 explained variance","value":0.46877537105148503,"unit":"percent","kind":"calculated","decimals":1},{"label":"Cumulative, first 5","value":0.9384217700738691,"unit":"percent","kind":"calculated","decimals":1},{"label":"Components above MP bound","value":1,"unit":"count","kind":"calculated","note":"heuristic"},{"label":"Kaiser rule","value":1,"unit":"count","kind":"calculated","note":"heuristic"},{"label":"Bai-Ng IC_p2","value":5,"unit":"count","kind":"calculated","note":"heuristic; at the upper limit of the search (5), not informative"},{"label":"Absorption ratio (top 1)","value":0.46877537105148503,"unit":"percent","kind":"calculated","decimals":1},{"label":"First-component share, latest window","value":0.37051466928190796,"unit":"percent","kind":"calculated","decimals":1,"note":"126-period window; full sample 46.9%; range over the windows 32.4% – 71.9%"},{"label":"Effective number of components","value":4.615826270469835,"unit":"count","kind":"calculated","decimals":2,"note":"exp of the entropy of the explained-variance shares"}],"tables":[{"id":"eigenvalues","title":"Spectrum","columns":[{"key":"component","label":"Component"},{"key":"eigenvalue","label":"Eigenvalue","decimals":4},{"key":"explained","label":"Explained variance","unit":"percent","decimals":2},{"key":"cumulative","label":"Cumulative","unit":"percent","decimals":2},{"key":"above_noise_bound","label":"Above MP bound"},{"key":"reconstruction_rmse","label":"Reconstruction RMSE with k components","decimals":5}],"rows":[{"component":"PC1","eigenvalue":2.81265222630891,"explained":0.46877537105148503,"cumulative":0.46877537105148503,"above_noise_bound":true,"reconstruction_rmse":0.7283712846149367},{"component":"PC2","eigenvalue":0.8297659910509618,"explained":0.13829433184182696,"cumulative":0.607069702893312,"above_noise_bound":false,"reconstruction_rmse":0.626428449530026},{"component":"PC3","eigenvalue":0.7107488997032639,"explained":0.11845814995054399,"cumulative":0.725527852843856,"above_noise_bound":false,"reconstruction_rmse":0.5235556548962647},{"component":"PC4","eigenvalue":0.6829388730209556,"explained":0.1138231455034926,"cumulative":0.8393509983473486,"above_noise_bound":false,"reconstruction_rmse":0.4005463055489909},{"component":"PC5","eigenvalue":0.5944246303591225,"explained":0.09907077172652042,"cumulative":0.9384217700738691,"above_noise_bound":false,"reconstruction_rmse":0.24798608668313502},{"component":"PC6","eigenvalue":0.36946937955678566,"explained":0.06157822992613094,"cumulative":1,"above_noise_bound":false,"reconstruction_rmse":0}],"note":"Marchenko-Pastur upper bound λ₊ = 1.1857 (N/T = 0.008). Reconstruction RMSE is in units of the decomposed data (standardised returns); the unexplained share with k components is 1 − cumulative."},{"id":"loadings","title":"Loadings (eigenvectors)","columns":[{"key":"symbol","label":"Symbol"},{"key":"pc1","label":"PC1","decimals":4},{"key":"pc2","label":"PC2","decimals":4},{"key":"pc3","label":"PC3","decimals":4},{"key":"pc4","label":"PC4","decimals":4},{"key":"pc5","label":"PC5","decimals":4},{"key":"communality","label":"Variance explained by PC1-5","unit":"percent","decimals":1}],"rows":[{"symbol":"AAPL","pc1":0.3676328122220901,"pc2":0.3581755167418405,"pc3":-0.7188671798082292,"pc4":0.4349957348601061,"pc5":0.157714784176997,"communality":0.9978972943832176},{"symbol":"MSFT","pc1":0.4338230358918561,"pc2":-0.25494494852987964,"pc3":0.08390602170097722,"pc4":0.30432593086756776,"pc5":-0.6972553769529811,"communality":0.9405224153075102},{"symbol":"NVDA","pc1":0.3947819964348674,"pc2":-0.2451272179718429,"pc3":0.4852109439709317,"pc4":0.4557436782223365,"pc5":0.583686585744019,"communality":0.9999121285306984},{"symbol":"GOOGL","pc1":0.42559368465059794,"pc2":-0.22868907107172223,"pc3":-0.2497009057898505,"pc4":-0.6181731294789053,"pc5":0.3187546024944186,"communality":0.9185400313436975},{"symbol":"AMZN","pc1":0.4864319013667392,"pc2":-0.18104891428340938,"pc3":0.014575134337762545,"pc4":-0.2979051567551601,"pc5":-0.20500737067690658,"communality":0.7784597471468199},{"symbol":"JPM","pc1":0.3210060515261629,"pc2":0.8133563910392227,"pc3":0.42213400748397345,"pc4":-0.1989387789859479,"pc5":-0.06810607272054105,"communality":0.9951990037312706}],"note":"Each column is a unit-length eigenvector; signs are normalised so that each column sums to a positive number (the sign of a component is arbitrary)."},{"id":"selection","title":"Number of components: heuristics","columns":[{"key":"rule","label":"Rule"},{"key":"components","label":"Components"},{"key":"detail","label":"Detail"}],"rows":[{"rule":"Marchenko-Pastur","components":1,"detail":"eigenvalues above λ₊ = σ²(1+√(N/T))² = 1.186"},{"rule":"Marchenko-Pastur, dominant mode removed","components":4,"detail":"σ² reduced to the variance left after PC1: bound 0.630"},{"rule":"Kaiser","components":1,"detail":"eigenvalues above the average eigenvalue (1 for a correlation matrix)"},{"rule":"Bai-Ng IC_p2","components":5,"detail":"minimum of the criterion over k = 0…5 (at the upper limit: not informative)"}],"note":"Heuristics, not tests: they rest on asymptotics in both N and T and on idealised noise (independent, identically distributed, finite fourth moments). They often disagree."}],"charts":[{"id":"rolling_share","title":"Market-mode strength (126-period window)","type":"line","x":{"label":"Window end","type":"time"},"y":{"label":"Share of total variance","unit":"percent"},"series":[{"name":"First component share","kind":"calculated","x":["2024-05-14","2024-05-21","2024-05-24","2024-06-03","2024-06-06","2024-06-13","2024-06-18","2024-06-26","2024-07-01","2024-07-08","2024-07-12","2024-07-18","2024-07-24","2024-07-30","2024-08-05","2024-08-09","2024-08-14","2024-08-21","2024-08-26","2024-09-03","2024-09-06","2024-09-13","2024-09-18","2024-09-25","2024-09-30","2024-10-07","2024-10-10","2024-10-17","2024-10-22","2024-10-29","2024-11-01","2024-11-08","2024-11-13","2024-11-20","2024-11-25","2024-12-03","2024-12-06","2024-12-13","2024-12-18","2024-12-24","2024-12-31","2025-01-07","2025-01-14","2025-01-21","2025-01-27","2025-01-31","2025-02-05","2025-02-12","2025-02-18","2025-02-25","2025-02-28","2025-03-07","2025-03-12","2025-03-19","2025-03-26","2025-03-31","2025-04-07","2025-04-10","2025-04-17","2025-04-23","2025-04-30","2025-05-05","2025-05-09","2025-05-15","2025-05-21","2025-05-28","2025-06-03","2025-06-09","2025-06-13","2025-06-18","2025-06-26","2025-07-01","2025-07-09","2025-07-14","2025-07-21","2025-07-24","2025-07-31","2025-08-05","2025-08-12","2025-08-15","2025-08-22","2025-08-27","2025-09-04","2025-09-09","2025-09-16","2025-09-19","2025-09-26","2025-10-01","2025-10-08","2025-10-13","2025-10-20","2025-10-23","2025-10-29","2025-11-04","2025-11-10","2025-11-14","2025-11-20","2025-11-26","2025-12-03","2025-12-08","2025-12-15","2025-12-18","2025-12-26","2025-12-31","2026-01-08","2026-01-13","2026-01-21","2026-01-28","2026-02-02","2026-02-09","2026-02-12","2026-02-20","2026-02-25","2026-03-04","2026-03-09","2026-03-13","2026-03-19","2026-03-25","2026-03-31","2026-04-07","2026-04-13","2026-04-17","2026-04-22","2026-04-29","2026-05-04","2026-05-11","2026-05-14","2026-05-21","2026-05-27","2026-06-03","2026-06-08","2026-06-15","2026-06-18","2026-06-26","2026-07-01","2026-07-09","2026-07-14","2026-07-21","2026-07-24","2026-07-31","2026-08-05","2026-08-12","2026-08-17","2026-08-24","2026-08-27","2026-09-02","2026-09-09","2026-09-15","2026-09-21","2026-09-25","2026-10-01","2026-10-07","2026-10-12","2026-10-19","2026-10-22","2026-10-29","2026-11-03","2026-11-10","2026-11-13","2026-11-20"],"y":[0.47282129383725624,0.47100832418115757,0.4657216868660478,0.4641346925579268,0.45989182338787415,0.446832804643414,0.44681712570495075,0.4405760276748276,0.44264110322705186,0.43464070683656014,0.43716972142463084,0.4450906974881688,0.4560044839017419,0.45568494936807585,0.4653524563161757,0.4699070632545836,0.466597985712907,0.4671538034412106,0.46650894293176853,0.47634649389422273,0.4831376425560594,0.4871208217840262,0.4872198478202668,0.49223900318549946,0.4938238840464426,0.4918723409166801,0.4892427853631432,0.4833589315876809,0.4768909425461541,0.49035860673647774,0.4862731745041869,0.49905911150545385,0.4958410549917848,0.5003078768417409,0.4978467283069818,0.49979742295719176,0.4995987312021572,0.5035672654096897,0.5172880288956283,0.5249066998392754,0.5277645282572897,0.532720837618687,0.5294966627282194,0.5300390482172034,0.49897246452279537,0.4929387784377796,0.4620753579823112,0.46140217588335625,0.4567062854544499,0.45888892134407816,0.46552934673017893,0.46392577875249147,0.47343439344586563,0.49004852741141186,0.4956039720226931,0.5048088690472876,0.557662013042727,0.6431537406442767,0.6525539828172648,0.6627182951652069,0.6658543171752317,0.6581011890850758,0.6534515623912969,0.6687118581567009,0.6701667888247471,0.6780853938534387,0.6805327409697122,0.682225007041846,0.6898610428220933,0.6916951483447278,0.6867199137909655,0.6823723097125499,0.6805782747737333,0.680893328155515,0.6768116774819022,0.6789959722615111,0.6931520846505327,0.7047397414898069,0.7121830893574724,0.7113834392850301,0.7170472093082485,0.7192442166503915,0.7138818903701253,0.7044901694860276,0.6990611238162399,0.6953161786904605,0.6895318943632918,0.684347324558763,0.6468732230731699,0.5057971224976044,0.47589688658831314,0.44182395710111905,0.44855659119029057,0.4342283074259531,0.41232691506470803,0.41689544009586627,0.42516195338246554,0.4072633697357543,0.40452643393843407,0.39611456782990795,0.37617442893621417,0.38139790400785595,0.38276518103219975,0.3872072469684609,0.3702213689570784,0.3710933269168477,0.38776443445779846,0.3861473691164352,0.3582625758246883,0.34296732051485646,0.35135299142510806,0.35192646165968106,0.3511045094554958,0.3448590104005971,0.3470101904079013,0.3583576417677659,0.3632156597559108,0.37232398280332474,0.4120802439938376,0.41392748765843085,0.42524317728231553,0.4071644282962031,0.40795898031414773,0.39659956443438077,0.38135286573929805,0.3925820538365944,0.3866817679715999,0.381841648383452,0.3741246493600388,0.3624465465550785,0.3723280811582384,0.38669368605836485,0.38578072870009367,0.37860654690660683,0.37795457505402585,0.37876591030525164,0.3779555440334288,0.3820845252656478,0.3752695689252097,0.35967451260286315,0.3622593573027776,0.36748474714944335,0.3622778600825902,0.3584114649341406,0.35175214014767386,0.3532186879457581,0.35647364399372,0.34954629134504345,0.3483253461605285,0.34485789120639876,0.32661764357624934,0.323635704627334,0.32735738301942785,0.32601564662048516,0.3306251409383908,0.34109399659855705,0.34300115968672884,0.35237330804907063,0.3525299336420799,0.37051466928190796]},{"name":"Absorption ratio (top 1 of 6)","kind":"calculated","x":["2024-05-14","2024-05-21","2024-05-24","2024-06-03","2024-06-06","2024-06-13","2024-06-18","2024-06-26","2024-07-01","2024-07-08","2024-07-12","2024-07-18","2024-07-24","2024-07-30","2024-08-05","2024-08-09","2024-08-14","2024-08-21","2024-08-26","2024-09-03","2024-09-06","2024-09-13","2024-09-18","2024-09-25","2024-09-30","2024-10-07","2024-10-10","2024-10-17","2024-10-22","2024-10-29","2024-11-01","2024-11-08","2024-11-13","2024-11-20","2024-11-25","2024-12-03","2024-12-06","2024-12-13","2024-12-18","2024-12-24","2024-12-31","2025-01-07","2025-01-14","2025-01-21","2025-01-27","2025-01-31","2025-02-05","2025-02-12","2025-02-18","2025-02-25","2025-02-28","2025-03-07","2025-03-12","2025-03-19","2025-03-26","2025-03-31","2025-04-07","2025-04-10","2025-04-17","2025-04-23","2025-04-30","2025-05-05","2025-05-09","2025-05-15","2025-05-21","2025-05-28","2025-06-03","2025-06-09","2025-06-13","2025-06-18","2025-06-26","2025-07-01","2025-07-09","2025-07-14","2025-07-21","2025-07-24","2025-07-31","2025-08-05","2025-08-12","2025-08-15","2025-08-22","2025-08-27","2025-09-04","2025-09-09","2025-09-16","2025-09-19","2025-09-26","2025-10-01","2025-10-08","2025-10-13","2025-10-20","2025-10-23","2025-10-29","2025-11-04","2025-11-10","2025-11-14","2025-11-20","2025-11-26","2025-12-03","2025-12-08","2025-12-15","2025-12-18","2025-12-26","2025-12-31","2026-01-08","2026-01-13","2026-01-21","2026-01-28","2026-02-02","2026-02-09","2026-02-12","2026-02-20","2026-02-25","2026-03-04","2026-03-09","2026-03-13","2026-03-19","2026-03-25","2026-03-31","2026-04-07","2026-04-13","2026-04-17","2026-04-22","2026-04-29","2026-05-04","2026-05-11","2026-05-14","2026-05-21","2026-05-27","2026-06-03","2026-06-08","2026-06-15","2026-06-18","2026-06-26","2026-07-01","2026-07-09","2026-07-14","2026-07-21","2026-07-24","2026-07-31","2026-08-05","2026-08-12","2026-08-17","2026-08-24","2026-08-27","2026-09-02","2026-09-09","2026-09-15","2026-09-21","2026-09-25","2026-10-01","2026-10-07","2026-10-12","2026-10-19","2026-10-22","2026-10-29","2026-11-03","2026-11-10","2026-11-13","2026-11-20"],"y":[0.47282129383725624,0.47100832418115757,0.4657216868660478,0.4641346925579268,0.45989182338787415,0.446832804643414,0.44681712570495075,0.4405760276748276,0.44264110322705186,0.43464070683656014,0.43716972142463084,0.4450906974881688,0.4560044839017419,0.45568494936807585,0.4653524563161757,0.4699070632545836,0.466597985712907,0.4671538034412106,0.46650894293176853,0.47634649389422273,0.4831376425560594,0.4871208217840262,0.4872198478202668,0.49223900318549946,0.4938238840464426,0.4918723409166801,0.4892427853631432,0.4833589315876809,0.4768909425461541,0.49035860673647774,0.4862731745041869,0.49905911150545385,0.4958410549917848,0.5003078768417409,0.4978467283069818,0.49979742295719176,0.4995987312021572,0.5035672654096897,0.5172880288956283,0.5249066998392754,0.5277645282572897,0.532720837618687,0.5294966627282194,0.5300390482172034,0.49897246452279537,0.4929387784377796,0.4620753579823112,0.46140217588335625,0.4567062854544499,0.45888892134407816,0.46552934673017893,0.46392577875249147,0.47343439344586563,0.49004852741141186,0.4956039720226931,0.5048088690472876,0.557662013042727,0.6431537406442767,0.6525539828172648,0.6627182951652069,0.6658543171752317,0.6581011890850758,0.6534515623912969,0.6687118581567009,0.6701667888247471,0.6780853938534387,0.6805327409697122,0.682225007041846,0.6898610428220933,0.6916951483447278,0.6867199137909655,0.6823723097125499,0.6805782747737333,0.680893328155515,0.6768116774819022,0.6789959722615111,0.6931520846505327,0.7047397414898069,0.7121830893574724,0.7113834392850301,0.7170472093082485,0.7192442166503915,0.7138818903701253,0.7044901694860276,0.6990611238162399,0.6953161786904605,0.6895318943632918,0.684347324558763,0.6468732230731699,0.5057971224976044,0.47589688658831314,0.44182395710111905,0.44855659119029057,0.4342283074259531,0.41232691506470803,0.41689544009586627,0.42516195338246554,0.4072633697357543,0.40452643393843407,0.39611456782990795,0.37617442893621417,0.38139790400785595,0.38276518103219975,0.3872072469684609,0.3702213689570784,0.3710933269168477,0.38776443445779846,0.3861473691164352,0.3582625758246883,0.34296732051485646,0.35135299142510806,0.35192646165968106,0.3511045094554958,0.3448590104005971,0.3470101904079013,0.3583576417677659,0.3632156597559108,0.37232398280332474,0.4120802439938376,0.41392748765843085,0.42524317728231553,0.4071644282962031,0.40795898031414773,0.39659956443438077,0.38135286573929805,0.3925820538365944,0.3866817679715999,0.381841648383452,0.3741246493600388,0.3624465465550785,0.3723280811582384,0.38669368605836485,0.38578072870009367,0.37860654690660683,0.37795457505402585,0.37876591030525164,0.3779555440334288,0.3820845252656478,0.3752695689252097,0.35967451260286315,0.3622593573027776,0.36748474714944335,0.3622778600825902,0.3584114649341406,0.35175214014767386,0.3532186879457581,0.35647364399372,0.34954629134504345,0.3483253461605285,0.34485789120639876,0.32661764357624934,0.323635704627334,0.32735738301942785,0.32601564662048516,0.3306251409383908,0.34109399659855705,0.34300115968672884,0.35237330804907063,0.3525299336420799,0.37051466928190796],"style":"dashed"}],"note":"Each point uses the 126 periods ending at that date (past data only). With a short window the first share is biased upwards: under pure noise its expectation is about (1+√(N/w))²/N = 24.7%."},{"id":"scree","title":"Scree: explained variance","type":"bar","x":{"label":"Component","type":"category"},"y":{"label":"Share of total variance","unit":"percent"},"series":[{"name":"Explained variance","kind":"calculated","x":["PC1","PC2","PC3","PC4","PC5","PC6"],"y":[0.46877537105148503,0.13829433184182696,0.11845814995054399,0.1138231455034926,0.09907077172652042,0.06157822992613094],"style":"bar"},{"name":"Cumulative","kind":"calculated","x":["PC1","PC2","PC3","PC4","PC5","PC6"],"y":[0.46877537105148503,0.607069702893312,0.725527852843856,0.8393509983473486,0.9384217700738691,1],"style":"line"}]},{"id":"eigenvalues","title":"Eigenvalues and the noise bound","type":"bar","x":{"label":"Component","type":"category"},"y":{"label":"Eigenvalue","log":false},"series":[{"name":"Eigenvalue","kind":"calculated","x":["PC1","PC2","PC3","PC4","PC5","PC6"],"y":[2.81265222630891,0.8297659910509618,0.7107488997032639,0.6829388730209556,0.5944246303591225,0.36946937955678566],"style":"bar"},{"name":"Marchenko-Pastur upper bound","kind":"calculated","x":["PC1","PC2","PC3","PC4","PC5","PC6"],"y":[1.1857268281296758,1.1857268281296758,1.1857268281296758,1.1857268281296758,1.1857268281296758,1.1857268281296758],"style":"dashed"}],"note":"Eigenvalues below the dashed line are not distinguishable from those of uncorrelated noise of the same dimensions."},{"id":"loadings_pc1","title":"Loadings of the leading components","type":"bar","x":{"label":"Symbol","type":"category"},"y":{"label":"Loading"},"series":[{"name":"PC1","kind":"calculated","x":["AAPL","MSFT","NVDA","GOOGL","AMZN","JPM"],"y":[0.3676328122220901,0.4338230358918561,0.3947819964348674,0.42559368465059794,0.4864319013667392,0.3210060515261629],"style":"bar"},{"name":"PC2","kind":"calculated","x":["AAPL","MSFT","NVDA","GOOGL","AMZN","JPM"],"y":[0.3581755167418405,-0.25494494852987964,-0.2451272179718429,-0.22868907107172223,-0.18104891428340938,0.8133563910392227],"style":"bar"},{"name":"PC3","kind":"calculated","x":["AAPL","MSFT","NVDA","GOOGL","AMZN","JPM"],"y":[-0.7188671798082292,0.08390602170097722,0.4852109439709317,-0.2497009057898505,0.014575134337762545,0.42213400748397345],"style":"bar"}]},{"id":"loadings_map","title":"Loadings map","type":"heatmap","x":{"label":"Component","type":"category"},"y":{"label":"Symbol"},"series":[],"matrix":{"x":["PC1","PC2","PC3","PC4","PC5"],"y":["AAPL","MSFT","NVDA","GOOGL","AMZN","JPM"],"z":[[0.3676328122220901,0.3581755167418405,-0.7188671798082292,0.4349957348601061,0.157714784176997],[0.4338230358918561,-0.25494494852987964,0.08390602170097722,0.30432593086756776,-0.6972553769529811],[0.3947819964348674,-0.2451272179718429,0.4852109439709317,0.4557436782223365,0.583686585744019],[0.42559368465059794,-0.22868907107172223,-0.2497009057898505,-0.6181731294789053,0.3187546024944186],[0.4864319013667392,-0.18104891428340938,0.014575134337762545,-0.2979051567551601,-0.20500737067690658],[0.3210060515261629,0.8133563910392227,0.42213400748397345,-0.1989387789859479,-0.06810607272054105]]}},{"id":"components","title":"Component series (cumulated scores)","type":"line","x":{"label":"Date","type":"time"},"y":{"label":"Cumulated score (standardised units)"},"series":[{"name":"PC1","kind":"calculated","x":["2023-11-13","2023-11-20","2023-11-28","2023-12-04","2023-12-11","2023-12-18","2023-12-26","2024-01-02","2024-01-09","2024-01-17","2024-01-24","2024-01-30","2024-02-06","2024-02-13","2024-02-21","2024-02-28","2024-03-05","2024-03-12","2024-03-19","2024-03-26","2024-04-02","2024-04-09","2024-04-16","2024-04-23","2024-04-29","2024-05-06","2024-05-13","2024-05-20","2024-05-24","2024-06-03","2024-06-10","2024-06-17","2024-06-25","2024-07-01","2024-07-09","2024-07-16","2024-07-23","2024-07-29","2024-08-05","2024-08-12","2024-08-19","2024-08-23","2024-08-30","2024-09-09","2024-09-16","2024-09-23","2024-09-27","2024-10-04","2024-10-11","2024-10-18","2024-10-24","2024-10-31","2024-11-07","2024-11-14","2024-11-20","2024-11-27","2024-12-05","2024-12-12","2024-12-19","2024-12-26","2025-01-03","2025-01-13","2025-01-21","2025-01-27","2025-02-03","2025-02-10","2025-02-18","2025-02-24","2025-03-03","2025-03-10","2025-03-17","2025-03-21","2025-03-28","2025-04-04","2025-04-11","2025-04-21","2025-04-25","2025-05-02","2025-05-09","2025-05-16","2025-05-22","2025-05-30","2025-06-06","2025-06-13","2025-06-20","2025-06-27","2025-07-07","2025-07-14","2025-07-21","2025-07-25","2025-08-01","2025-08-08","2025-08-15","2025-08-21","2025-08-28","2025-09-05","2025-09-12","2025-09-18","2025-09-25","2025-10-02","2025-10-09","2025-10-15","2025-10-22","2025-10-29","2025-11-05","2025-11-12","2025-11-18","2025-11-25","2025-12-03","2025-12-10","2025-12-16","2025-12-23","2025-12-31","2026-01-08","2026-01-14","2026-01-22","2026-01-29","2026-02-05","2026-02-12","2026-02-19","2026-02-26","2026-03-05","2026-03-12","2026-03-18","2026-03-25","2026-04-01","2026-04-09","2026-04-15","2026-04-22","2026-04-29","2026-05-06","2026-05-13","2026-05-19","2026-05-27","2026-06-03","2026-06-10","2026-06-16","2026-06-24","2026-07-01","2026-07-09","2026-07-15","2026-07-22","2026-07-29","2026-08-05","2026-08-11","2026-08-18","2026-08-25","2026-09-01","2026-09-09","2026-09-15","2026-09-22","2026-09-29","2026-10-06","2026-10-12","2026-10-19","2026-10-26","2026-11-02","2026-11-06","2026-11-13","2026-11-20"],"y":[-0.7697870773218546,3.112004568736436,2.469684672807034,-0.6788240475214243,0.6838747497744924,4.160388877336901,4.317972786678264,1.8806569711254417,3.5423940395081255,4.0267266712791105,9.239309868121088,10.21376014477854,10.99239466548912,10.759799569105272,9.235089040177115,10.89799704324066,10.101191218333962,12.906252817715949,14.569556188593282,14.78098367182765,15.00737545453015,15.149341077866652,11.677032119330109,10.970876069502847,13.247172633054081,16.201370442518897,16.620167100270407,18.26497991218856,19.494422656203557,18.977916478010727,21.15315514626397,24.680040280183103,24.482624301791663,27.030697509068716,29.865492408353134,28.08793449332413,24.5338485766251,19.25734364643195,8.26030469223214,12.917857632163125,19.618311949436613,18.92224881264326,18.112032980083733,11.363412346250444,14.859275128119569,17.434494430838832,16.81005722880565,16.24910341186475,17.716702941820905,18.659316729470813,17.99048505345513,15.927766852563924,23.68658836573966,23.19112874777701,21.012837003725718,20.872158368260894,24.90319595654213,27.374168163835705,23.835528016478513,27.29864538798221,24.219176489689207,20.917921389762682,24.409911811419313,22.812745398894574,21.772968860141745,21.344812355259464,22.474856796237397,17.527099341082383,10.949030115812151,4.132193309626735,4.405693431225863,5.110255298934346,1.1412670049687001,-13.01274400633103,-2.256222252846552,-11.57628337712669,0.07737693344113428,3.4736476436887136,1.5548448912236943,9.868667717126614,7.92541787684932,8.493300193125691,10.854468370149892,9.712089824981819,9.61205745675917,15.241013891758294,16.065692991787362,16.720306581807804,19.075194883969232,20.28111069624359,16.14388530022445,21.09095031742591,21.8262931670109,18.258628964153864,22.105265045274425,22.339879589468723,23.908746233764628,25.40230076593477,24.655680071776413,25.438915994037608,25.39886573295162,22.747774604336893,22.875794215390815,30.160725571737647,30.37444546213137,30.445753705633027,23.874867652018562,26.8122242624368,27.68567226600591,26.94172035127693,24.09545381031856,27.037559381297406,25.629957383747293,26.659844520131177,23.360592604326687,20.60565904298871,21.870618550249098,16.622542615522804,11.92690131528596,11.892982296664073,12.9216544715048,11.692662974150776,8.547783866836864,7.4701823820647375,5.202138650136519,4.942966482523109,10.855392279125628,16.892838989807167,19.785423204184063,20.0521388706072,24.38870327983046,24.038292664417522,21.959012878062957,23.01803547151856,19.86254756958705,14.460564124813718,18.11503050392917,11.933810849515176,14.488219450695158,16.442247874704645,20.356083923872276,16.69960577868529,13.135215389213874,25.37994856781419,24.297205087417254,22.030120751747674,21.605109141813443,21.442763041829327,19.603836322102854,20.273837688911772,21.55712533476957,19.068062026106734,21.73007938013692,22.44674463445033,20.819744836424054,17.225076610979873,11.52406270953758,12.861948589600559,13.34595076500952,-7.105427357601002e-14]},{"name":"PC2","kind":"calculated","x":["2023-11-13","2023-11-20","2023-11-28","2023-12-04","2023-12-11","2023-12-18","2023-12-26","2024-01-02","2024-01-09","2024-01-17","2024-01-24","2024-01-30","2024-02-06","2024-02-13","2024-02-21","2024-02-28","2024-03-05","2024-03-12","2024-03-19","2024-03-26","2024-04-02","2024-04-09","2024-04-16","2024-04-23","2024-04-29","2024-05-06","2024-05-13","2024-05-20","2024-05-24","2024-06-03","2024-06-10","2024-06-17","2024-06-25","2024-07-01","2024-07-09","2024-07-16","2024-07-23","2024-07-29","2024-08-05","2024-08-12","2024-08-19","2024-08-23","2024-08-30","2024-09-09","2024-09-16","2024-09-23","2024-09-27","2024-10-04","2024-10-11","2024-10-18","2024-10-24","2024-10-31","2024-11-07","2024-11-14","2024-11-20","2024-11-27","2024-12-05","2024-12-12","2024-12-19","2024-12-26","2025-01-03","2025-01-13","2025-01-21","2025-01-27","2025-02-03","2025-02-10","2025-02-18","2025-02-24","2025-03-03","2025-03-10","2025-03-17","2025-03-21","2025-03-28","2025-04-04","2025-04-11","2025-04-21","2025-04-25","2025-05-02","2025-05-09","2025-05-16","2025-05-22","2025-05-30","2025-06-06","2025-06-13","2025-06-20","2025-06-27","2025-07-07","2025-07-14","2025-07-21","2025-07-25","2025-08-01","2025-08-08","2025-08-15","2025-08-21","2025-08-28","2025-09-05","2025-09-12","2025-09-18","2025-09-25","2025-10-02","2025-10-09","2025-10-15","2025-10-22","2025-10-29","2025-11-05","2025-11-12","2025-11-18","2025-11-25","2025-12-03","2025-12-10","2025-12-16","2025-12-23","2025-12-31","2026-01-08","2026-01-14","2026-01-22","2026-01-29","2026-02-05","2026-02-12","2026-02-19","2026-02-26","2026-03-05","2026-03-12","2026-03-18","2026-03-25","2026-04-01","2026-04-09","2026-04-15","2026-04-22","2026-04-29","2026-05-06","2026-05-13","2026-05-19","2026-05-27","2026-06-03","2026-06-10","2026-06-16","2026-06-24","2026-07-01","2026-07-09","2026-07-15","2026-07-22","2026-07-29","2026-08-05","2026-08-11","2026-08-18","2026-08-25","2026-09-01","2026-09-09","2026-09-15","2026-09-22","2026-09-29","2026-10-06","2026-10-12","2026-10-19","2026-10-26","2026-11-02","2026-11-06","2026-11-13","2026-11-20"],"y":[-0.29045572047539703,1.666979280301444,1.506896594151343,4.58289410266411,4.458842099676371,5.616126231308279,5.410538056731191,6.427147199064154,4.7192274325721195,2.0089316374232626,2.1160686508703295,2.3128864548192363,1.3377450486405662,-0.13956730137510487,2.277461026287022,1.9288827476718322,1.2642891732227557,0.22582733743906236,0.7712662601049406,-0.37468756082331345,0.08545145729177277,-0.3732007882871578,-4.890587468731829,-1.4240863449334866,-1.3933859140821196,-2.3272831424765,0.09111551599880041,-1.6850005729604152,-1.3995890870945922,-0.641066918556639,-3.118400727383268,-3.499477990975887,-3.9311701702591413,-1.8400913542292678,-1.0486214600641253,2.1264223416935764,1.0022827403586876,2.683672239943215,1.1524486711483886,3.2420268466240016,3.3484190702058285,4.336622630332333,6.661842936405894,6.274838019053726,0.41563641546217417,1.3729067563392334,1.0484513048506368,1.3183898488262162,3.522340163944058,4.470290239351928,3.59146397962706,2.733112904520487,2.8063406269061386,4.289001427682305,4.747529124432277,7.7356542255184895,5.165751964828717,3.10056016026204,2.320415168565881,4.104976802949952,3.2059194132041817,3.848272544577061,4.867214051855492,7.353696687483813,7.500284503139009,8.041694861328386,11.296670548399451,9.141730262534088,10.81398976525621,4.655350126918213,2.3615190979935377,4.419519052208458,6.382657537277298,-0.7714049145043314,2.4235383947584426,3.870901287318308,4.1951581238769755,3.514055539221061,3.117190098959972,4.000354963499572,1.2922723350617265,1.2544248867050478,0.50623972847179,-0.8450667875449551,1.9852653425138098,1.457335031372527,3.3761132414147426,1.5471210555622796,0.9086218759354647,1.827676538067894,-0.6989750560971348,0.21602309537508557,0.24365660282264923,0.9350387064135888,1.7629535507774543,0.7633440622791361,1.2470376293365923,2.006763890623094,4.250149956719967,2.0803589956960287,1.1444369970229813,1.4672543009733348,-0.47895002268598474,-0.9282977762254121,0.3284922602906016,1.9766711802892953,-0.4135574019292677,-0.3509345785753072,1.5431952436522325,0.34390023359559074,2.0234802738932385,1.90639020531756,1.340149686758484,0.8330343104144831,-2.3714350641210147,-3.8482143043857984,-2.9932602767785284,2.2369361936540977,0.35942345933593733,1.1237580378549081,1.2476198518350063,-2.777271421307967,-4.782980071937868,-4.167204870694373,-1.217807692745794,-1.1945376648700985,-0.25694701500306893,-4.080174456134135,-3.757050146055619,-5.461810063745895,-4.8192808283598,-7.143164128317238,-7.611711927978089,-6.350867204731715,-5.257865480324825,-3.105355549829386,0.08984322771536801,2.6417006245219086,1.104354402251292,2.55069713122623,3.4833122635062823,4.895031559576594,6.668317125329802,-0.12047866531097717,-0.08314867962034178,1.2642171778720452,-0.21116342792867515,0.4887182434290571,-0.11992230386472946,0.30956439089679455,-2.449199424932649,-3.775859773186346,-5.6512213082175204,-5.030721627805851,-4.511285985255179,-3.083467591133806,0.3194243650984321,-1.3708851838857197,1.7825775031718778,-2.1094237467877974e-15]},{"name":"PC3","kind":"calculated","x":["2023-11-13","2023-11-20","2023-11-28","2023-12-04","2023-12-11","2023-12-18","2023-12-26","2024-01-02","2024-01-09","2024-01-17","2024-01-24","2024-01-30","2024-02-06","2024-02-13","2024-02-21","2024-02-28","2024-03-05","2024-03-12","2024-03-19","2024-03-26","2024-04-02","2024-04-09","2024-04-16","2024-04-23","2024-04-29","2024-05-06","2024-05-13","2024-05-20","2024-05-24","2024-06-03","2024-06-10","2024-06-17","2024-06-25","2024-07-01","2024-07-09","2024-07-16","2024-07-23","2024-07-29","2024-08-05","2024-08-12","2024-08-19","2024-08-23","2024-08-30","2024-09-09","2024-09-16","2024-09-23","2024-09-27","2024-10-04","2024-10-11","2024-10-18","2024-10-24","2024-10-31","2024-11-07","2024-11-14","2024-11-20","2024-11-27","2024-12-05","2024-12-12","2024-12-19","2024-12-26","2025-01-03","2025-01-13","2025-01-21","2025-01-27","2025-02-03","2025-02-10","2025-02-18","2025-02-24","2025-03-03","2025-03-10","2025-03-17","2025-03-21","2025-03-28","2025-04-04","2025-04-11","2025-04-21","2025-04-25","2025-05-02","2025-05-09","2025-05-16","2025-05-22","2025-05-30","2025-06-06","2025-06-13","2025-06-20","2025-06-27","2025-07-07","2025-07-14","2025-07-21","2025-07-25","2025-08-01","2025-08-08","2025-08-15","2025-08-21","2025-08-28","2025-09-05","2025-09-12","2025-09-18","2025-09-25","2025-10-02","2025-10-09","2025-10-15","2025-10-22","2025-10-29","2025-11-05","2025-11-12","2025-11-18","2025-11-25","2025-12-03","2025-12-10","2025-12-16","2025-12-23","2025-12-31","2026-01-08","2026-01-14","2026-01-22","2026-01-29","2026-02-05","2026-02-12","2026-02-19","2026-02-26","2026-03-05","2026-03-12","2026-03-18","2026-03-25","2026-04-01","2026-04-09","2026-04-15","2026-04-22","2026-04-29","2026-05-06","2026-05-13","2026-05-19","2026-05-27","2026-06-03","2026-06-10","2026-06-16","2026-06-24","2026-07-01","2026-07-09","2026-07-15","2026-07-22","2026-07-29","2026-08-05","2026-08-11","2026-08-18","2026-08-25","2026-09-01","2026-09-09","2026-09-15","2026-09-22","2026-09-29","2026-10-06","2026-10-12","2026-10-19","2026-10-26","2026-11-02","2026-11-06","2026-11-13","2026-11-20"],"y":[0.3278222058924841,0.590706214633737,-0.025146912896173435,0.7496324010484543,0.11747059519225705,1.714858693064686,1.912000905779687,4.042835991509349,5.461586654552799,6.38397927865407,5.271283534686918,7.84946310375639,9.317789055765227,10.873723915352349,11.654005466018983,15.286240924347457,20.564169317867723,20.644148499903537,19.37588113496002,21.45765951656764,21.236290611193525,20.068285492132535,18.04267772536627,19.019480818835703,17.83811251013097,16.447434690386416,15.89315025615773,14.653057655723769,17.65735768689361,18.046802244048223,18.876754399584012,14.50132636146322,15.386450612364422,14.818965087771328,13.481111042660384,12.715755790600118,13.6386622527654,14.134903923918694,12.259018479724133,13.388021411477903,15.732324712879798,15.845163672409743,15.134028436410167,14.784327432448942,15.496735417477074,13.686140767000605,13.726303839011411,14.222134226091592,17.041418132489092,16.41487255670516,17.54923860917689,16.22773431829476,19.172372164738697,19.771355344170843,19.176078951593258,18.506525773561126,17.668521161682605,14.179583200395676,12.06817513779447,12.374475532697314,15.596205006945791,16.073196074572166,20.96360592178247,17.59448919447194,16.874425538940738,20.457340437968615,19.133732987013705,15.803014878681564,15.819051939118346,13.30613987756656,18.106586328258782,17.97566785815474,17.618129128615525,17.801786598691244,21.0262691762573,19.341651526681115,19.201859963235833,21.879867593055632,24.604320359849396,25.015972951181343,25.623236206005856,26.338311071791036,26.60481951571862,28.06269839794907,28.95279831690172,30.98095800029102,29.919652109853246,30.1349018991233,29.742807646492416,30.214976139817537,31.971717260857822,26.563138713015437,25.890694288294693,26.79832517936395,26.08318032787309,21.42585313377487,24.419517352969184,23.560957549070633,20.66849781124895,21.13388257514959,22.17427539856622,21.239582521918045,18.654362031946825,19.253620286730406,18.060933056512674,18.05415287241365,15.834690330415606,12.550433659703854,12.60247333934725,13.542331361821654,14.616455808856607,16.68902530742286,16.189038812442796,18.374605553786864,15.429232074412623,17.196449448940097,15.936542846579904,11.333701490073535,15.061039143793456,16.054547708677312,13.469066308229069,14.540083284407414,13.916167029545873,14.814083135603955,15.369314300805817,14.255634870132308,14.962100283992218,14.63732115106551,14.680355028270736,14.819256439262867,10.82132265098713,8.800885814624847,8.546607314410704,6.552078310125668,8.039548917951366,10.021318107515434,10.799639276309616,11.76191351882795,11.180907639764238,8.860994378975338,8.804067244627788,9.984148208393595,6.46604237706439,13.798852750978805,15.509130934935083,14.749575594038204,13.730849546282125,12.363200312112912,14.121321803625232,10.479899617530084,9.364601928297581,10.56711463602869,10.617986753552152,8.969363681353412,8.201665631440155,9.016324643610718,10.520734151202605,8.199581199526499,4.705022441477072,-2.0872192862952943e-14]}],"note":"Score of component j at date t: the period's (standardised) returns projected on eigenvector j. In-sample: the eigenvectors use the whole period, so this is a description, not a tradable index."}],"diagnostics":[{"name":"Bartlett sphericity test","statistic":1050.526263371795,"pvalue":1.980773817678053e-214,"conclusion":"Rejects uncorrelated returns at the 5% level: there is common variation for components to capture.","passed":true,"df":15},{"name":"Kaiser-Meyer-Olkin sampling adequacy","statistic":0.8085425985015705,"pvalue":null,"conclusion":"KMO = 0.81: correlations are largely shared (above 0.6, suitable for a factor description).","passed":true},{"name":"Largest eigenvalue vs Marchenko-Pastur bound","statistic":2.81265222630891,"pvalue":null,"conclusion":"λ₁ = 2.813 against a noise bound of 1.186: the first component is clearly not noise.","passed":true},{"name":"Observations per asset T/N","statistic":126.5,"pvalue":null,"conclusion":"T/N = 126.5. Enough for the leading eigenvalues; the small ones remain noisy.","passed":true}],"assumptions":["Returns are log returns on adjusted closes over the 759 sessions common to all 6 symbols; the correlation matrix is the sample estimate over the whole period.","Components are statistical constructs, orthogonal in sample by construction; they need not correspond to economic factors, and their signs are arbitrary.","The Marchenko-Pastur bound assumes independent, identically distributed noise with finite fourth moments and large N and T; fat tails and volatility clustering push sample eigenvalues above it without any common factor."],"warnings":["Only 6 assets: Marchenko-Pastur and Bai-Ng are large-N results and are weak guides here."],"methodology":"**Decomposition.** With $X$ the $T\\times N$ matrix of demeaned and standardised returns, $C = X'X/(T-1) = V\\Lambda V'$, eigenvalues $\\lambda_1\\ge\\dots\\ge\\lambda_N\\ge 0$, eigenvectors (loadings) in the columns of $V$. Explained variance of component $j$: $\\lambda_j/\\sum_i\\lambda_i$. Scores: $F = XV$.\n\n**Noise bound.** For $N$ uncorrelated series of variance $\\sigma^2$ observed $T$ times, the eigenvalues of the sample covariance fall (as $N,T\\to\\infty$, $N/T\\to q$) in $[\\sigma^2(1-\\sqrt q)^2,\\ \\sigma^2(1+\\sqrt q)^2]$ (Marchenko-Pastur). Eigenvalues above $\\lambda_+$ are candidates for genuine common components. The second line of the table recomputes the bound with $\\sigma^2 = 1-\\lambda_1/N$ (Laloux et al.).\n\n**Kaiser.** Keep $\\lambda_j$ above the average eigenvalue. **Bai-Ng.** $IC_{p2}(k) = \\ln V(k) + k\\,\\frac{N+T}{NT}\\ln\\min(N,T)$ with $V(k) = \\frac{1}{NT}\\sum_{i,t}\\hat e_{it}^2$ the mean squared residual after $k$ components; the estimate minimises it.\n\n**Reconstruction.** $\\hat X_k = F_kV_k'$, RMSE$(k) = \\sqrt{V(k)}$, unexplained share $= \\sum_{j>k}\\lambda_j/\\sum_j\\lambda_j$.\n\n**Absorption ratio.** $AR = \\sum_{j\\le n}\\lambda_j/\\sum_j\\lambda_j$ with $n$ a fixed share of $N$ (Kritzman et al., 2011): a high value means returns are tightly coupled. **Rolling.** The same quantities on trailing windows.\n\n**Bartlett.** $-(T-1-\\frac{2N+5}{6})\\ln|R| \\sim \\chi^2_{N(N-1)/2}$ under $R=I$ and normality.","provenance":{"data":[{"symbol":"AAPL","provider":"FMP","retrievedAt":"2026-11-20T21:49:32+00:00","start":"2023-10-30","end":"2026-11-20","observations":769,"frequency":"1d","adjusted":"split_div","currency":null},{"symbol":"MSFT","provider":"FMP","retrievedAt":"2026-11-20T21:49:32+00:00","start":"2023-10-30","end":"2026-11-20","observations":769,"frequency":"1d","adjusted":"split_div","currency":null},{"symbol":"NVDA","provider":"FMP","retrievedAt":"2026-11-20T21:49:33+00:00","start":"2023-10-30","end":"2026-11-20","observations":769,"frequency":"1d","adjusted":"split_div","currency":null},{"symbol":"GOOGL","provider":"FMP","retrievedAt":"2026-11-20T21:49:35+00:00","start":"2023-10-30","end":"2026-11-20","observations":769,"frequency":"1d","adjusted":"split_div","currency":null},{"symbol":"AMZN","provider":"FMP","retrievedAt":"2026-11-20T21:49:38+00:00","start":"2023-10-30","end":"2026-11-20","observations":769,"frequency":"1d","adjusted":"split_div","currency":null},{"symbol":"JPM","provider":"FMP","retrievedAt":"2026-11-20T21:49:39+00:00","start":"2023-10-30","end":"2026-11-20","observations":769,"frequency":"1d","adjusted":"split_div","currency":null}],"spec":{"symbols":["AAPL","MSFT","NVDA","GOOGL","AMZN","JPM"],"basis":"correlation","return_type":"log","frequency":"daily","data_period":756,"start":null,"end":null,"n_components":5,"rolling_window":126,"absorption_fraction":0.2},"seed":null,"software":{"python":"3.14.4","numpy":"2.4.6","pandas":"3.0.3","scipy":"1.17.1","statsmodels":"0.14.6","arch":"8.0.0","scikit-learn":"1.8.0"},"computedAt":"2026-11-20T21:49:39+00:00","durationMs":9761,"reproduce":"import numpy as np, pandas as pd\n# px: adjusted closes, one column per symbol (AAPL, MSFT, NVDA, GOOGL, AMZN, JPM), common sessions, daily\npx = pd.read_csv(\"closes.csv\", index_col=0, parse_dates=True).dropna()\nr = np.log(px / px.shift(1)).dropna().loc[\"2023-11-11\":]\nC = r.corr().to_numpy()\nlam, V = np.linalg.eigh(C); lam, V = lam[::-1], V[:, ::-1]\nprint(\"explained:\", lam / lam.sum())\nT, N = r.shape\nprint(\"Marchenko-Pastur upper bound:\", 1.0 * (1 + np.sqrt(N / T)) ** 2)"}}}}2
Files main
Menu

Theme