Dear Statalist,
I need to use the reshape command inside a bootstrap program.
My question is: how can I run the reshape command inside the program?
WORKING EXAMPLE
NOT WORKING EXAMPLE (I add the reshape command)
The purpose of this code is solely to demonstrate the current issue I am facing in using the reshape command inside a program with a similar (not identical) structure. I cannot post the original because of its length.
So, I answer two obvious objections preemptively.
Q1) Do you know that, by reshaping and then sorting by random_id, each individual's observations will be sorted randomly, and so the 'working example' and the 'non working example' are two inherently different approaches? A1) Yes I know it, this is just a demo code.
Q2) Why don't you run the reshape command outside of the program? A2) I cannot, because what I am doing requires this to happen inside the bootstrap program (take my word on this).
So, my question is simply how can I run the reshape command inside the bootstrap program above, without getting this error message that I get:
Thanks
I need to use the reshape command inside a bootstrap program.
My question is: how can I run the reshape command inside the program?
WORKING EXAMPLE
Code:
sysuse auto, clear gen bene_id = _n capture program drop myboot program define myboot, eclass capture keep price weight length bene_id __000000 mpg gen random_id = runiform() sort random_id replace length = length * 1.1 if random_id < 0.5 areg price weight length, absorb(mpg) matrix temp = e(b) ereturn post temp end bootstrap, reps(100) seed(200): myboot
Code:
sysuse auto, clear gen bene_id = _n capture program drop myboot program define myboot, eclass capture keep price weight length bene_id __000000 mpg gen month_1 = 1 gen month_2 = 2 gen month_3 = 3 gen month_4 = 4 gen month_5 = 5 gen month_6 = 6 reshape long month_, i(bene_id) j(months) gen random_id = runiform() sort random_id replace length = length * 1.1 if random_id < 0.5 & month_ <= 3 areg price weight length, absorb(mpg) matrix temp = e(b) ereturn post temp end bootstrap, reps(100) seed(200): myboot
The purpose of this code is solely to demonstrate the current issue I am facing in using the reshape command inside a program with a similar (not identical) structure. I cannot post the original because of its length.
So, I answer two obvious objections preemptively.
Q1) Do you know that, by reshaping and then sorting by random_id, each individual's observations will be sorted randomly, and so the 'working example' and the 'non working example' are two inherently different approaches? A1) Yes I know it, this is just a demo code.
Q2) Why don't you run the reshape command outside of the program? A2) I cannot, because what I am doing requires this to happen inside the bootstrap program (take my word on this).
So, my question is simply how can I run the reshape command inside the bootstrap program above, without getting this error message that I get:
Code:
Bootstrap replications (100) ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 50 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 100 insufficient observations to compute bootstrap standard errors no results will be saved
Comment