How can I repeat the following text 5000 times and save the solutions for the 5000 different betas in a 1x 5000 matrix ?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello, I make some wild bootstrap here and I now want to repeat the following text(formulas)as a whole 5000 times and save the different resulting beta values in a matrix:
% 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 rd Rademacher distribution
resrd1=res(:,1).*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
beta=regress(rt,x3);
How can I make this in matlab. Thanks for help.
0 commentaires
Réponses (1)
David Young
le 22 Déc 2015
betas = zeros(1, 5000); % make array to store results
for k = 1:5000
% ... your code ...
betas(k) = beta; % store current value in k'th element
end
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!