bootstrap by firm and month

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 130
Accepted Solution

bootstrap by firm and month

[ Edited ]

I try to bootstrap using proc surveyselect or the following code

data bootstraps;
do replicate = 1 to 10;
do simorder = 1 to nobs;
p = ceil(nobs * ranuni(394747373));
set sample nobs=nobs point=p;
output;
end;
end;
stop;
run;

 

I want the bootstrap run by each id-month combination, rather than apply to the whole dataset. One way is to separate the dataset into small ones (e.g., for id=11, I have sub-dataset for month 1 and 2; and for id=22, also have subdatasets for month 1 and 2), then apply above code to each subdataset, finally merge. It works fine if I have only 2 firms.

 

Any options I can refer to, to bootstrap by firm and month? strata option looks like select different observations from different groups.

 

Thanks!

Attachment

Accepted Solutions
Solution
‎09-06-2016 11:20 PM
Respected Advisor
Posts: 4,932

Re: bootstrap by firm and month

Look at this example:

 

proc sort data=sashelp.class out=orderedClass; by sex; run;

proc surveyselect data=orderedClass method=urs samprate=100 rep=10 
    out=bootstraps outhits seed=9636365;
strata sex;
run;
PG

View solution in original post


All Replies
Solution
‎09-06-2016 11:20 PM
Respected Advisor
Posts: 4,932

Re: bootstrap by firm and month

Look at this example:

 

proc sort data=sashelp.class out=orderedClass; by sex; run;

proc surveyselect data=orderedClass method=urs samprate=100 rep=10 
    out=bootstraps outhits seed=9636365;
strata sex;
run;
PG
Frequent Contributor
Posts: 130

Re: bootstrap by firm and month

Thank you PG!

 

So the key point here is to set samprate=100, and if I want to sample by two variables, I just add another variable to the strata statement?

 

 e.g, if there is another variable named region, then the statement:

 

strata sex region;

 

will sample by each combination of sex-region, and the samprate=100 will make sure that the bootstrap works within each combination of sex-region.

 

Correct me if I am wrong. thanks!

 

 

Respected Advisor
Posts: 4,932

Re: bootstrap by firm and month

Right! The sort would also have to be by sex region;

PG
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 299 views
  • 0 likes
  • 2 in conversation