RiskFreeRate = readmatrix('RiskFree.xlsx','Range',[3 3 6 121]);
Geo = readtable('Data.xlsx','range', [1 2 1112 2]);
Active_ETFS = readtable('Data.xlsx','range',[2 15 1112 133]);
Benchmark=readmatrix('Benchmarkss.xlsx', 'range', [1 2 5 120]);
famaFrenchFactorsUS = readmatrix('fama_french_5_factor.xlsx','range',[6 1 124 7]);
excessMarketReturn = famaFrenchFactorsUS(:,2)';
SMBUS = famaFrenchFactorsUS(:,3)';
HMLUS = famaFrenchFactorsUS(:,4)';
RMWUS = famaFrenchFactorsUS(:,5)';
CMAUS = famaFrenchFactorsUS(:,6)';
RFUS = famaFrenchFactorsUS(:,7)';
famaFrenchFactorsASIA = readmatrix("Asia_Pacific_ex_Japan_5_Factors.csv",'range',[6 1 124 7]);
excessMarketReturn = famaFrenchFactorsASIA(:,2)';
SMBASIA = famaFrenchFactorsASIA(:,3)';
HMLASIA = famaFrenchFactorsASIA(:,4)';
RMWASIA = famaFrenchFactorsASIA(:,5)';
CMAASIA = famaFrenchFactorsASIA(:,6)';
RFASIA = famaFrenchFactorsASIA(:,7)';
famaFrenchFactorsDev = readmatrix("Developed_5_Factors.csv",'range',[6 1 124 7]);
excessMarketReturn = famaFrenchFactorsDev(:,2)';
SMBDev = famaFrenchFactorsDev(:,3)';
HMLDev = famaFrenchFactorsDev(:,4)';
RMWDev = famaFrenchFactorsDev(:,5)';
CMADev = famaFrenchFactorsDev(:,6)';
RFDev = famaFrenchFactorsDev(:,7)';
famaFrenchFactorsEU = readmatrix("Europe_5_Factors.csv",'range',[6 1 124 7]);
excessMarketReturn = famaFrenchFactorsEU(:,2)';
SMBDev = famaFrenchFactorsEU(:,3)';
HMLDev = famaFrenchFactorsEU(:,4)';
RMWDev = famaFrenchFactorsEU(:,5)';
CMADev = famaFrenchFactorsEU(:,6)';
RFDev = famaFrenchFactorsEU(:,7)';
Euro = RiskFreeRate(2,:);
AsiaPasific = RiskFreeRate(3,:);
GeoETF=[Geo Active_ETFS];
GeoETF=table2cell(GeoETF);
etf_data = struct('AsiaPasific', [], 'Europe', [], 'Global', [], 'USA', []);
for i = 1:size(GeoETF, 1)
geo_focus = GeoETF{i, 1};
etf_returns = GeoETF(i, 2:end);
etf_data.(geo_focus) = [etf_data.(geo_focus); etf_returns];
USAmat = cell2mat(etf_data.USA);
APmat = cell2mat(etf_data.AsiaPasific);
Europemat = cell2mat(etf_data.Europe);
Globalmat = cell2mat(etf_data.Global);
USANetReturn = USAmat - US;
EuropeNetReturn = Europemat - Euro;
APNetReturn = APmat - AsiaPasific;
GlobalNetReturn = Globalmat - US;