datasample/bootstrap procedure
이전 댓글 표시
Basically I need to ensure for all rows in the variable t1, that they are resampled in the same way.
That means that if the first draw is observation 2, then for all t1, I need observation 2 to be the first draw. This continues, such that I will have b resamples that resamples so that the samples are reordered, but for all t1 they has to be re-ordered the same way. By using rng I achieve this. I also need the variable "carhartt" to follow the same procedure.
However, I am questioning whether there is a better method for doing this? It is very important that i resample all t1 in the same way.
It is also important that each bootstrap/datasample is random.
Do any of you experts have a better solution, or do you approve of the one I use here?
I am trying to bootstrap/resample the best appropriate way:
y=+aDanmark()-bDanmark(:,5);
t1=y(1:t,:);
nans = any(isnan(t1),1);
t1(:,nans)=[];
for i =1:size(t1,2)
resultst1=ols(t1(1:12,i),carhart(1:12,:));
estimatest1(:,i)=resultst1.beta(1);
residuals=resultst1.resid;
carhartt=carhart(1:12,:);
b=99;
for B=1:b
rng(B);
bootresiduals=datasample(residuals,size(residuals,1));
rng(B);
bootcarhart=datasample(carhartt,size(residuals,1));
B
end
end
댓글 수: 3
Guillaume
2020년 3월 14일
There's a lack of context and a complete lack of comment in the code that makes it hard to understand your question.
"Basically I need to ensure for all rows in the variable t1 [...]" What does t1 represent?
"[...]that they are resampled in the same way" What sort of resampling are you talking about
"That means that if the first draw is observation 2[...]" What draw? What observation?
Anton Sørensen
2020년 3월 14일
편집: Anton Sørensen
2020년 3월 14일
Anton Sørensen
2020년 3월 14일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!