-1
我正在使用ecmmvnrmle(缺少數據的多元正態迴歸)計算大量matlab資產的軋製貝塔值,但這需要很多時間。有沒有辦法做到這一點,而不使用循環?在matlab中計算沒有for循環的軋製貝塔值
我正在使用ecmmvnrmle(缺少數據的多元正態迴歸)計算大量matlab資產的軋製貝塔值,但這需要很多時間。有沒有辦法做到這一點,而不使用循環?在matlab中計算沒有for循環的軋製貝塔值
以下是我使用
for i=1:numcol-2 % col have various assets
temp_component = regress_dataset(:,i); %calculating returns
if strcmp(type, 'Equity')
temp_component = price2ret(temp_component);
elseif strcmp(type , 'Corp')
temp_component = diff(temp_component);
end
for j=1:numrows - roll - 1 %calculating rolling betas
temp_index = indexset_ret(j:j+roll-1,:); %index return for last 22 days (roll=22)
temp_index(:,1) = 1;
temp_asset = temp_component(j:j+roll-1,:);
msr(j,:) = [size(temp_index),size(temp_asset) j];
if sum(isnan(temp_asset))> 0
ts_beta(j,k) = NaN;
else
[Param,Covar] = ecmmvnrmle(temp_asset,temp_index); %calculating beta
ts_beta(j,k) = Param(2); %storing beta
end
end
k=k+1;
end
請上所遇到的問題更具體的代碼。到目前爲止,你有什麼? – fuesika 2014-08-28 07:16:32
目前我有兩個嵌套for循環。外循環貫穿面板數據中的柱面。內部循環通過獲取最近22天的數據來計算滾動測試。由於我處理的資產數量巨大,接近2000年,需要花費大量的時間來運行循環。有沒有辦法提高效率 – user1679161 2014-08-28 07:22:31
請提供一個最小(非)工作示例。 – fuesika 2014-08-28 07:23:20