## Bootraping the mean and test the equality

Use this forum to post questions about syntax problems or general programming issues. Questions on implementing a particular aspect of econometrics should go in "Econometrics Issues" below.

### Bootraping the mean and test the equality

Dear Friends on the forum,

I am trying to run a regression as follows:

ret=B0+B1*X1+B2*X2+B3*X3+B4*X4*+error

where ret is return series and X's are dependent variables.

I want run the equation get the coefficients and using the bootstrapping to generate the return series and to test whether the mean of the generated returns and actual returns are equal statistically. However, I do not know does it make sense.

My code as follows:

All 18
open dat f:/tur/return.xls
data(format=xls,org=obs) / ret x1 x2 x3 x4
stats ret
linreg ret
# x1 x2 x3 x4 constant
set res = %resids
compute B1 = %beta(1)
compute B2 = %beta(2)
compute B3 = %beta(3)
compute B4 = %beta(4)
compute B0 = %beta(5)

*Make Bootraping
com ndraws = 5000
All 18
set meanhat 1 ndraws = 0
do i=1,ndraws
set x1B= x1(fix(%uniform(1,19)))
set x2B= x2(fix(%uniform(1,19)))
set x3B= x3(fix(%uniform(1,19)))
set x4B= x4(fix(%uniform(1,19)))
set resB=res(fix(%uniform(1,19)))

set yhat = B0+B1*x1B+B2*x2B+B3*x3B+B4*x4B+resB
stats yhat
com meanhat(i)=@mean

end do i

The problem I am facing is now how to statistically compare the equality of mean of actual (ret) o and mean of the generated returns meanhat.

I mean how to code so that I could have the p-value of the test.

Your suggestion and kind assistance on this matter is highly appreciated.
turkhanali

Posts: 16
Joined: Fri Jul 17, 2009 1:47 am

### Re: Bootraping the mean and test the equality

turkhanali wrote:Dear Friends on the forum,

I am trying to run a regression as follows:

ret=B0+B1*X1+B2*X2+B3*X3+B4*X4*+error

where ret is return series and X's are dependent variables.

I want run the equation get the coefficients and using the bootstrapping to generate the return series and to test whether the mean of the generated returns and actual returns are equal statistically. However, I do not know does it make sense.

Not really. You can test whether the bootstrapped returns have a fixed mean, but not whether they have the same sample mean. By construction, they are drawn from the empirical density for the data; the whole point is that their population mean matches the sample mean.

turkhanali wrote:My code as follows:

All 18
open dat f:/tur/return.xls
data(format=xls,org=obs) / ret x1 x2 x3 x4
stats ret
linreg ret
# x1 x2 x3 x4 constant
set res = %resids
compute B1 = %beta(1)
compute B2 = %beta(2)
compute B3 = %beta(3)
compute B4 = %beta(4)
compute B0 = %beta(5)

*Make Bootraping
com ndraws = 5000
All 18
set meanhat 1 ndraws = 0
do i=1,ndraws
set x1B= x1(fix(%uniform(1,19)))
set x2B= x2(fix(%uniform(1,19)))
set x3B= x3(fix(%uniform(1,19)))
set x4B= x4(fix(%uniform(1,19)))
set resB=res(fix(%uniform(1,19)))

set yhat = B0+B1*x1B+B2*x2B+B3*x3B+B4*x4B+resB
stats yhat
com meanhat(i)=@mean

end do i

Your bootstrapping code isn't correct. Your x's are being drawn independently of each other rather than as a group. This is a correct way to do it:

Code: Select all
`do i=1,ndraws   boot entries   set x1b = x1(entries)   set x2B = x2(entries)   set x3B = x3(entries)   set x4B = x4(entries)   set resB =res(entries)   set yhat = B0+B1*x1B+B2*x2B+B3*x3B+B4*x4B+resBend do i`
TomDoan

Posts: 2727
Joined: Wed Nov 01, 2006 5:36 pm

### Re: Bootraping the mean and test the equality

Thank you very much for your suggestion, Tom.
turkhanali

Posts: 16
Joined: Fri Jul 17, 2009 1:47 am