Bootraping the mean and test the equality
-
turkhanali
- Posts: 15
- Joined: Fri Jul 17, 2009 1:47 am
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.
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.
Re: Bootraping the mean and test the equality
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: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.
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: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
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+resB
end do i-
turkhanali
- Posts: 15
- Joined: Fri Jul 17, 2009 1:47 am
Re: Bootraping the mean and test the equality
Thank you very much for your suggestion, Tom.