【问题标题】:Bootstrap sampling depending on portfolio (MATLAB)取决于投资组合的引导抽样 (MATLAB)
【发布时间】:2011-06-08 10:19:44
【问题描述】:

我在 Matlab 中编码时遇到了这个问题,我希望有人知道如何解决这个问题。

总结:问题是我有几个不同的金融投资组合(1070 个投资组合),我需要对每个投资组合进行回归。然后使用第一个回归的残差,我想引导这些残差(获取大约 1000 个引导残差样本),但每个个人投资组合。这是因为我不能混合来自不同投资组合的残差。

详细说明:我有一个向量告诉我投资组合编号,这是一个随机数,但对于该特定投资组合来说是唯一的。然后我将投资组合收益收集在一个长向量中(14k 观察),所以我需要做的是某种“滚动窗口”OLS 回归,并且只回归与单个投资组合相对应的数据,提取常数和 beta 和保存这些,然后对所有不同的投资组合执行此操作。

我会得到一个由常数和 beta 组成的矩阵,然后每一行对应一个特定的投资组合。

投资组合具有不同数量的数据点,因此一个投资组合可能有 60 个观察值,而另一个投资组合可能有 150 个观察值。因此,仅按固定间隔将其拆分为单独的投资组合是不可能的。

对于自举残差,如上所述,我需要从投资组合的残差而不是整个样本中进行替换。我需要这些引导样本来进行进一步的数据操作,但是我有 1000 个引导样本,其余的只是正常的加法和减法运算......

有人知道怎么做吗?在 Stata 中,对于回归部分,您只需使用“by()”选项,但对于引导,它并不那么容易......

非常感谢您的帮助!

最好的问候,菲利普

【问题讨论】:

    标签: matlab portfolio statistics-bootstrap


    【解决方案1】:

    我附上了几个使用 MATLAB 的残差引导程序的不同示例

    以下参考资料提供了一些很好的背景信息

    http://www.economics.uci.edu/~dbrownst/bootmi.pdf

    %% Generate a data set and perform your initial regression
    
    clear all
    clc
    
    X = linspace(1, 1000, 1000)';
    Y = 3*X + 5 + randn(1000,1);
    X = [ones(length(X),1), X];
    
    [b,bint,r,rint,stats] = regress(Y,X);
    
    %% Parametric residual bootstrap
    
    % This method assumes that your residuals are normally distributed and
    % homoskedastic.  A parametric residual bootstrap is more accurate and
    % converges faster than a nonparametric residual bootstrap.
    
    % Use a one sided kstest to verify that the residuals are normally
    % distributed.
    kstest(r)
    
    % Create a probability distribution object that models the residuals
    foo = fitdist(r, 'normal')
    
    % Create an array to store your new datasets
    Nboot = 500;
    My_Data = zeros(length(X), Nboot);
    
    % Create your data sets
    
    YHat = X*b;
    
    for i = 1:Nboot
    
        boot_noise = random(foo, 1000,1);
        My_Data(:,i) = YHat + boot_noise;
    
    end
    
    % Use your data to do something interesting
    
    %%  Nonparametric residual bootstrap
    
    % This method assumes that your errors are homoskedastic, however, there is
    % no assume that they are normally distributed.
    
    % This method also uses the bootstrp function from Statistics Toolbox and
    % assumes that we're using the bootstrp to estimate standard errors
    
    standard_errors = std(bootstrp(1000,@(bootr)regress(YHat+bootr, X),r))
    

    【讨论】:

      猜你喜欢
      • 2018-03-24
      • 2017-11-28
      • 2016-12-08
      • 2011-11-16
      • 1970-01-01
      • 2021-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多