BB algo and Hamilton MS-AR Outputs

For questions and discussion related to graphs, reports, and other output, including issues related to presenting or publishing results.
danon
Posts: 17
Joined: Thu Nov 10, 2016 2:05 pm

BB algo and Hamilton MS-AR Outputs

Unread post by danon »

Dear Tom,
Is there any possibility to:
1- get the outputs for the BB algorithm in graph as well ? we only get numbers .
2- get Hamilton's MS-AR graph in color rather than in Back and white only?

Please have a look on images attached

Best regards

D
Attachments
Hmilton's results - Any colored Graph version
Hmilton's results - Any colored Graph version
Screen Shot 2017-04-10 at 11.50.00.png (111.53 KiB) Viewed 20196 times
BB Results - Any colored Graph version ?
BB Results - Any colored Graph version ?
Screen Shot 2017-04-10 at 11.46.54.png (61.89 KiB) Viewed 20196 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: BB algo and Hamilton MS-AR Outputs

Unread post by TomDoan »

danon wrote:Dear Tom,
Is there any possibility to:
1- get the outputs for the BB algorithm in graph as well ? we only get numbers .
You can use the PEAK and TROUGH options to get dummy variables with the turning points. I'm not sure there's any obvious "graph" directly out of the procedure, but you can use those dummies in other graphs.
danon wrote: 2- get Hamilton's MS-AR graph in color rather than in Back and white only?
Color what? You can change the color on the data by overriding the default style number (1 = black).
danon
Posts: 17
Joined: Thu Nov 10, 2016 2:05 pm

Re: BB algo and Hamilton MS-AR Outputs

Unread post by danon »

Thanks again Dear Tom

I did change the quaterly to monthly in your hamilton's program.
I got the IP growth graph only.
Unfortunately I got an error message because of recession's dummy
variable to be create. but I do not know how?
**************************
The changes:

cal(m) 1999:1
open data ipci.prn
data(format=prn,org=columns) 1999:1 2016:12
*
set g = 100*log(IP/IP{1})
graph(header="IP growth")
# g
*
* Set up a mean-switching model with just the one variable and four lags.
*
@msvarsetup(lags=2,switch=m)
# g
compute gstart=1999:1,gend=2016:12
frml msvarf = log(%MSVARProb(t))

**************************
Error is:

## SX11. Identifier RECESSQ is Not Recognizable. Incorrect Option Field or Parameter Order?
>>>>ontract = recessq==<<<<
If the name isn't mistyped, it's possible that you have a poorly formatted instruction
Common errors are
* a space before the ( in an option field
* a missing space before = in a SET or FRML
* a missing $ at the end of a long line which continues to the next
**************************************
The data file used contains only the IP series ( no dates series, no recession series because I do not know how to create
the recession series)

Please can you help !?
Attachments
ipci.prn
IP series file
(2.32 KiB) Downloaded 938 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: BB algo and Hamilton MS-AR Outputs

Unread post by TomDoan »

You can use the @NBERCYCLES procedure to generate the recession dummy that was hard-coded into Hamilton's data set.
danon
Posts: 17
Joined: Thu Nov 10, 2016 2:05 pm

Re: BB algo and Hamilton MS-AR Outputs

Unread post by danon »

Dear Mr Tom,

Thanks for your help so far. I am nearly done !
Indeed I have two questions.
One on the result of the BB algorithm on the growth rate of monthly industrial production series and
One on the results of Hamilton 1989 on the the growth rate of Quarterly industrial production series.

For the BB algo on monthly growth rates i have this:

open data ipm.xls
cal(m) 1999
data(format=xls,org=columns) 1999:1 2916:12 ip
*
set ipg = 100*log(ip/ip{1})
*
log ipg
@BryBoschan(print=final) ipg 1999:2 2016:12

## MAT13. Store into out-of-range LPEAK(0)
## I2. Expected Instruction Here
>>>>#<<<<The Error Occurred At Location 133, Line 14 of BBENFORCEENDPOIN
/Applications/RATS 9.1/Procedures/bryboschan.src Line 230
Called From Location 2807, Line 155 of BRYBOSCHAN
/Applications/RATS 9.1/Procedures/bryboschan.src Line 505



On the Hamilton 1989 (quaterly growth rate) i have this:

MAXIMIZE - Estimation by BFGS
NO CONVERGENCE IN 31 ITERATIONS
LAST CRITERION WAS 0.0000000
ESTIMATION POSSIBLY HAS STALLED OR MACHINE ROUNDOFF IS MAKING FURTHER PROGRESS DIFFICULT
TRY HIGHER SUBITERATIONS LIMIT, TIGHTER CVCRIT, DIFFERENT SETTING FOR EXACTLINE OR ALPHA ON NLPAR
RESTARTING ESTIMATION FROM LAST ESTIMATES OR DIFFERENT INITIAL GUESSES MIGHT ALSO WORK


....with non significant probabilities.....


NB: FULL CODES ATTACHED (BB & HAMILTON) + GRAPHS OBTAINED ( for HAMILTON)

Thnaks
Attachments
Full Codes_BB_and_Hamilton.rpf
Codes and the error message.
(3.73 KiB) Downloaded 907 times
Quarterly growth rates.rgf
Used on hamilton
(760 Bytes) Downloaded 919 times
Probabilities.rgf
Hamilton probabilities
(1.63 KiB) Downloaded 926 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: BB algo and Hamilton MS-AR Outputs

Unread post by TomDoan »

Your DATA instruction has a typo: I don't think you actually mean 2916:12

data(format=xls,org=columns) 1999:1 2916:12 ip

Also, BB applies to the log of the series, not the growth rates.

The Hamilton model doesn't converge when applied to US GDP growth over a longer data span. The fact that there was only one (fairly minor) recession between 1982 and 2001 with fairly regular cycles before that causes the model to break down. So it's not shocking that you might have problems.
danon
Posts: 17
Joined: Thu Nov 10, 2016 2:05 pm

Re: BB algo and Hamilton MS-AR Outputs

Unread post by danon »

Dear Tom
Thanks a lot
yes it was a typo as it is 2016.

I wanted to remind you that I m using my own data (Idustrial production monthly series from a country in africa from 1999 to 2016) and not US GDP.
Should I consider that it makes sense that the hamilton algoritm gives such results as if it was US GDP !?

Please have a look on the data i used...

Best
ipq.xls
quarterly IP used
(25 KiB) Downloaded 692 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: BB algo and Hamilton MS-AR Outputs

Unread post by TomDoan »

I seriously doubt that you can get the Hamilton model to fit that. You have 20 and 30% quarter to quarter changes with almost immediate reversals rather than actual cycles. Do you know why the data are so variable? It looks almost like timing errors where some (substantial part) of production gets applied to the wrong quarter.
danon
Posts: 17
Joined: Thu Nov 10, 2016 2:05 pm

Re: BB algo and Hamilton MS-AR Outputs

Unread post by danon »

I did convert monthly data to quarterly series because the codes was not working on monthly data.
With qarterly data i could get those amazingly non reasonable estimates.
attached is the original data ...
may be you can help !?

Best
ip_monthly_series.xls
original monthly IP series
(38.5 KiB) Downloaded 732 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: BB algo and Hamilton MS-AR Outputs

Unread post by TomDoan »

Needless to say, that's even worse. (The quarterly averages smooth out some of that, but not much)
danon
Posts: 17
Joined: Thu Nov 10, 2016 2:05 pm

Re: BB algo and Hamilton MS-AR Outputs

Unread post by danon »

Do you mean that using monthly data is worse !?
Camacho (2006, attached) used monthly IP with Hamilton 1989 as well but using GAUSS.

Please, having looked at my data, what would you suggest ?

Danon
BCPQ.pdf
Camacho 2006
(331.7 KiB) Downloaded 754 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: BB algo and Hamilton MS-AR Outputs

Unread post by TomDoan »

Please read what I wrote above: https://estima.com/forum/viewtopic.php?p=14156#p14156. Compare the overall appearance of their monthly data (Figure 1) with yours. It has nothing to do with the software, or data being monthly or quarterly and everything to do with your data being far too noisy.

The point above about the problem with the Hamilton model and US GDP is cautionary. Hamilton's model fit spectacularly well to the data set to which it was applied. The results were reproducible, the transition probabilities made sense and it hit almost spot-on the NBER cycles. Same model, same data series, but extended for another 10 years---doesn't work. It tries to turn the 1981-2 recession into a one-off outlier.
danon
Posts: 17
Joined: Thu Nov 10, 2016 2:05 pm

Re: BB algo and Hamilton MS-AR Outputs

Unread post by danon »

If I do understand well, I should detrend as much as possible in first place until i get smoothed series.
Am I correct ?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: BB algo and Hamilton MS-AR Outputs

Unread post by TomDoan »

Detrending has nothing to do with it. It's the period-to-period whipsawing that's the problem.
danon
Posts: 17
Joined: Thu Nov 10, 2016 2:05 pm

Re: BB algo and Hamilton MS-AR Outputs

Unread post by danon »

This is too technical dear Tom.
Is there a process to follow for this ?

Best
Post Reply