Resampling Columns of a Matrix

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

uchuk
Posts: 7
Joined: Wed Mar 02, 2011 8:33 am

Resampling Columns of a Matrix

Postby uchuk » Mon Apr 01, 2013 3:06 pm

Hi,

I want to bootstrap not rows of a matrix, but cols. Since to the my knowledge Eviews does not have a command for this situation, first I transposed the matrix, then resampled. But Eviews does not exactly resample the rows of the new matrix. The code is below

matrix bootkal1 = @transpose(bootkal)
matrix bootkal2 = @resample(bootkal1)

The result is

37.78425311004244 42.12208576778759 44.65110673041997
3.487714269148301 3.544167370822096 3.741550594033354
34.85880001852675 36.60544090217692 43.9921886220723
3.573937242919356 3.490016999370026 3.471114415859684
37.78425311004244 42.12208576778759 44.65110673041997

(I summarized the results).

As it can be seen in the results, always the first and last rows of the matrix is same, so it does not exaclty resample. Although I determine the number of the bootstrap as 10000. When I do not transpose the matrix "bootkal", the code is really resampling. How I can solve this problem? Any suggestions? :eviews6:

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: Resampling Columns of a Matrix

Postby EViews Gareth » Mon Apr 01, 2013 3:22 pm

Are you sure?

I just ran an example, and it worked fine.

Code: Select all

create u 10 'create random matrix matrix(3,40) bootkal rnd(bootkal) matrix bootkal1 = @transpose(bootkal) matrix bootkal2 = @resample(bootkal1) show bootkal1 show bootkal2

uchuk
Posts: 7
Joined: Wed Mar 02, 2011 8:33 am

Re: Resampling Columns of a Matrix

Postby uchuk » Tue Apr 02, 2013 12:06 am

Hi again,

Again I got the same wrong results when I modify the code as follows. The resample code works fine when using "transpose" but it does not work fine in the cases of cols>rows matrices. There are same rows in the resulting matrix.


create u 10

'create random matrix
matrix(3,40) bootkal
rnd(bootkal)

matrix bootkal2 = @resample(bootkal)

show bootkal2

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: Resampling Columns of a Matrix

Postby EViews Gareth » Tue Apr 02, 2013 8:15 am

Pretty difficult to tell if there is anything going wrong (or right) with only 3 rows. You need a larger sample than that. Try this:

Code: Select all

create u 10 'create random matrix matrix(40,3) bootkal rnd(bootkal) matrix bootkal2 = @resample(bootkal)

uchuk
Posts: 7
Joined: Wed Mar 02, 2011 8:33 am

Re: Resampling Columns of a Matrix

Postby uchuk » Tue Apr 02, 2013 10:34 am

Hi again,

I just increased the row of the matrix and I got the similar results:

Code: Select all

create u 10 'create random matrix matrix(20,40) bootkal rnd(bootkal) matrix bootkal2 = @resample(bootkal)
In this sample, there are about 10 rows are same exactly.

Does this problem arise since the number of cols > number of rows?

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: Resampling Columns of a Matrix

Postby EViews Gareth » Tue Apr 02, 2013 10:39 am

You realise that you're doing resampling with replacement, right?

uchuk
Posts: 7
Joined: Wed Mar 02, 2011 8:33 am

Re: Resampling Columns of a Matrix

Postby uchuk » Tue Apr 02, 2013 10:42 am

of course. This is a just a part of my code. I try to estimate bootstrap critical values of the panel-granger causality test of dumitrescu and hurlin (2012), but this part of the code produce these results.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: Resampling Columns of a Matrix

Postby EViews Gareth » Tue Apr 02, 2013 10:48 am

Then I'm not sure what you think is going wrong?

uchuk
Posts: 7
Joined: Wed Mar 02, 2011 8:33 am

Re: Resampling Columns of a Matrix

Postby uchuk » Tue Apr 02, 2013 10:57 am

when the number of the rows of the matrix is short according to columns, "resample" produces new matrixes which have exactly same rows (for examle just now I resampled the matrices againg and there are 4 rows are the same). Therefore the wald statistics are nearly same and the critical values for the panel granger causality equals to the individual wald statistic.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: Resampling Columns of a Matrix

Postby EViews Gareth » Tue Apr 02, 2013 11:00 am

Yes, but with replacement, you expect some of the rows to be the same. That's the point.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests