Qu and Perron Test. Error G0058.


I am Adrián from Valencia (Spain). I am doing an empirical study through the structural breaks test involved by Bai & Perron. Right now, I am having so many problems related with the Qu and Perron test.
The error appeared is:

C:\Users\Adrian\Desktop\TFG ROMAN\bai_and_perron\mbreak2 QPERRON2(36) : error G0058 : Index out of range

I would like to send you my database and then you could see where I have the error.

My GAUSS file is:

library pgraph;
format /ld 6,3;

@select your output file@

output file = mbr-out.out reset;

@load the data@
@import excel file@
filename= "Q&Perron.xlsx";
range= "B3:Z1060";
xlsmat= SpreadsheetReadM(filename, range, 1);
@do matrix variables in vector variables@

@Set your T by n matrix of dependent variables@


@Set your T by q matrix of regressors@


@Specify the number of observations@


@Specify the matrix _S (here the first and second regressors are used in the
first equation and the first and third regressors are used in the second equation)@

_S={1 0 0 0 0,
    0 1 0 0 0,
    0 0 1 0 0,
    0 0 0 1 0,
    0 0 0 1 0,
    0 0 0 0 0,
    0 0 0 0 1};

@set the maximum number of breaks allowed. If use the WDmax test set m=5, since the critical values reported
correspond to this case@


@If you have restrictions, specify the matrix R (here only the constants (first
regressor) is allowed to change in each equation).
if you do not have restrictions, set R=eye(cols(_S)*(m+1))@

@set the trimming parameter that specifies the minimal length of a segment as a proportion of the sample size.@

@set brv=1 when allowing breaks in the covariance matrix of the errors; otherwise, set brv=0@


@set brbeta=1 when allowing breaks in regression coefficients; otherwise, set brbeta=0.@


@set vauto=1 when applying a correction for serial correlation in the errors
(in which case Andrews' (1991) method is used to construct the robust
covariance matrix.@


@set to prewhit=1 if you want to apply an AR(1) pre-whitening when estimating the
robust covariance matrix (see Andrews and Monahan (1992).@


@Set hetq=1 if you want to allow the distribution of the regressors to change across
regimes (this is used only when constructing confidence intervals for the estimates
of the break dates. For the construction of the test hetq=1 always.@


/*Call the main procedure*/

call mainp(m,cols(_S),z,y,cols(y),trm,T,brv,brbeta,vauto,hetq,prewhit);

#include mbreak.src;

Tags: asked June 24, 2014

5 Answers


Your error message is telling us that the error is on line 36 of the file mbreak2 QPERRON2. Can you post the contents of that line?



Line 36 refers to this one:



Do you want me to send you my database? Or with line 36 specified is enough?


Thank you.


The problem is that xlsmat is a 1057 row by 25 column matrix. We know this, because you assign xlsmat by loading data from B3:Z1060 of the XLS file.

On the line with the error:


you are trying to assign z to be equal to all the rows of xlsmat in the 14th through 26th columns. However, as we said above, xlsmat only has 25 columns.

To fix this problem, you either need to load an extra column from the spreadsheet (if one exists) or you need to assign fewer columns to z. For example this should not cause an error:


Which you want to do will depend upon your data and model.



Ok, thank you, I see my mistake. However, the problem is not solved yet, as new errors appear, so that I'm going to try to explain all the possible mistakes:

My database starts from column A (which refers to dates... Do I have to include dates on GAUSS within the range?). If so, the range would be from A3 to Z1060.


After that, my dependent variables go from column B to column M (in total, 12 columns). Would it be y=xlsmat[.,2:13], because column 1 is related with dates.

And regressors go from N to Z (in total, 13 columns), so that we have:



With this, there are two new errors which are this ones:

The basic specifications for testing and estimation:
(1) M= 4.000
(2) Trimming= 0.200
(3) T= 1058.000
(4) The covariance matrix of errors is not allowed to change
(5) The number of coefficients (beta) in each regime is: 5.000
other specificiations:
(1) the code reports results for an unrestricted model (apart
from the basic specifications and for a restricted model
with restrictions specified by the user)
(2) the error is serially uncorrelated
(3) the distribution of the regressors is allowed to change
(4) No pre-whittening when constructing confidence intervals

C:\Users\Adrian\Desktop\TFG ROMAN\bai_and_perron\mbreak.src(530) : error G0036 : Matrices are not conformable
Currently active call: transf [530] C:\Users\Adrian\Desktop\TFG ROMAN\bai_and_perron\mbreak.src
Stack trace:
transf called from C:\Users\Adrian\Desktop\TFG ROMAN\bai_and_perron\mbreak.src, line 68
mainp called from C:\Users\Adrian\Desktop\TFG ROMAN\bai_and_perron\mbreak2 QPERRON2, line 98


Thank you for your attention.


The first error you are getting is:

C:\Users\Adrian\Desktop\TFG ROMAN\bai_and_perron\mbreak.src(530) : error G0036 : Matrices are not conformable

This means that on line 530 of the file mbreak.src some operation matrix operation is being attempted in which the dimensions of the two matrices are not conformable.

You need to trace the code and see where these variables come from and what is wrong with them. The GAUSS debugger is very helpful for this.