plot quarterly data, dttostr

Dear all,

I would like to plot my quarterly data, so I used the following command lines:

1 new;
2 load x[272,6]=data.txt;
3 frq=x[.,1];
4 gdp=x[.,2];
5 period = dttostr(frq, "YYYY-QQ");
6 plotScatter(period,gdp);

the column frq contains quarterly dates (194701, 194704, .... 201410). I can print "period" (1947-Q1, ... , 2014-Q4), but I cannot plot "period" and "gdp".

Following error output appears: error G0644: Input 1 of wrong type.

If I plot "frq" and "gdp" then it works  but on the x-axis i get values 194700, 195500, .... 201000.

Can someone give me an advice for the settings of the x-axis?

Many Thanks in advance. I appreciate your time and consideration.

Benjamin

6 Answers



1



Have you tried 'plotTS'?

new;
load x[272,6]=data.txt;
first_date=x[1,1];
gdp=x[.,2];
freq = 4; //number of periods per year
plotTS(first_date, freq, gdp);


1



You can use the function plotSetXTicInterval to set the first date to be labelled and how often you would like a label to show up. For example, we could modify the program above like this:

new;
load x[272,6]=data.txt;
first_date=x[1,1];
gdp=x[.,2];
freq = 4; //number of periods per year

//declare plotControl structure
//and fill it with default settings
struct plotControl myPlot;
myPlot = plotGetDefaults("xy");

//first date to label
first_labeled = 1950;

//how often to set a label
//4 quarters per year * 10 years = 40
tic_interval = 40;

//apply tic label settings to structure
plotSetXTicLabel(&myPlot, first_labeled, tic_interval);

//Call plotting function using plotControl structure
plotTS(myPlot, first_date, freq, gdp);

aptech

1,323


0



thank you very much for this hint! It works!

On the x-axis I have the follwing dates: 1947-Q1, 1953-Q4, 1960-Q3, 1967-Q2, ...

Does a command exist to get the dates -  for example in a ten year intervall - on the x-axis like 1950-Q1, 1960-Q1, 1970-Q1, ... 2014-Q1?

Thank you



0



thank you for your advice. I used this modified code, but it didn't work. Alternatively I used the following program to get what I wanted:

new;
load x[272,6]=data.txt;
gc=x[.,6];

//gc in logarithm
ln_gc=ln(gc);

//declare plotControl structure and fill it with default settings
struct plotControl myPlot;
myPlot = plotGetDefaults("xy");

//x-axis (time-axis): 1947-Q1 - 2014-Q4
t=seqa(1947,0.25,272);

//Set the x-axis label
plotsetxlabel(&myplot,"Period");

//Set the y-axis label
plotsetylabel(&myplot,"gc");

//Set legend
plotSetLegend(&myPlot, "gc");

//plot of data
plotXY(myPlot,t,ln_gc);

The program worked in GAUSS V13 fine. The older Version GAUSS V12 generated the same graph, but on the x-axis (time axis) I get the yearly data 1.950 1.960 1.970 ... instead of 1950 1960 1970 (without a dot as in V13) and on the y-axis percentage values with "comma" instead of points (e.g. 6,7 instead of 6.7 as in V13). Can someone give me a hint, how to get the same label setting in V12 as in V13? Thank you very much.



0



Which version of GAUSS 12 are you using? With version 12.1.12 for Windows 64-bit, I get this graph:

 

user_forum_ts04222015
Since I don't have your data, I made a slight modification. The exact code I used is below for reference:

gc=seqm(1,2,272);

//gc in logarithm
ln_gc=ln(gc);

//declare plotControl structure and fill it with default settings
struct plotControl myPlot;
myPlot = plotGetDefaults("xy");

//x-axis (time-axis): 1947-Q1 - 2014-Q4
t=seqa(1947,0.25,272);

//Set the x-axis label
plotsetxlabel(&myplot,"Period");

//Set the y-axis label
plotsetylabel(&myplot,"gc");

//Set legend
plotSetLegend(&myPlot, "gc");

//plot of data
plotXY(myPlot,t,ln_gc);

aptech

1,323


0



Thank you for this answer! I am using the  version 12.1.6 for Windows 32-bit. I couldn't find the source of this problem with my version. I appreciate yor time and consideration!

Your Answer


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

Try GAUSS for 30 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy