-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