フィルターのクリア

How can I repeat the following text 5000 times ?

2 ビュー (過去 30 日間)
Fox
Fox 2015 年 12 月 22 日
編集済み: goerk 2015 年 12 月 23 日
Hello, I make some wild bootstrap here and I know want to repeat the following text(formulas)as a whole 5000 times:
% Estimate the p-values by bootstrapping the residuals.
e=[e1,e2];
% resample the residuals with replacement in pairs
res=datasample(e,743,'Replace',true);
% create a Random Variable which follows the Rademacher distribution
rd = ((rand(1,743)<.5)*2 - 1)'; %
% multiply the res with a random variable of v Rademacher distribution
resrd1=res(:,1).*rd;
resrd2=res(:,2).*rd;
% Time Series of Predictors x(t)and r(t)
% computing unconditional mean a2/(1-b), a2=b(1), b=b(2)and build
% time series x(t)* = x2
b(1)/(1-b(2))
x2=b(1)+ b(2)*(b(1)/(1-b(2)))+resrd2;
% build time series for r(t)*=rt
rt=a+resrd1;
% make regressions with the before constructed x2 and rt
% getting with OLS ß*=beta
x3=[ones(size(rt)),x2]; % to have an intercept in the regression
betas=regress(rt,x3);
How can I do this in Matlab ?
  1 件のコメント
Fox
Fox 2015 年 12 月 22 日
How can I save the 5000 different betas ?

サインインしてコメントする。

採用された回答

goerk
goerk 2015 年 12 月 22 日
Put the code in a scriptfile (e.g. doThisCode.m) and call it from anotherone with.
for i=1:5000;
doThisCode
end
This will lead to the same result as if you press F5 5000 times.
  2 件のコメント
Fox
Fox 2015 年 12 月 22 日
Thanks. Do you know how I can save my 5000 solutions for the betas in a matrix ?
goerk
goerk 2015 年 12 月 23 日
編集済み: goerk 2015 年 12 月 23 日
for a scalar value of beta without preallocation:
beta_vec = [];
for i = 1:5000
doThisCode
beta_vec = [beta_vec beta];
end

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeHypothesis Tests についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by