SHAZAM Community
Ask Your Question

Organizing and analyzing selected seasons in time series

asked 2012-07-11 06:04:06 +0000

Pantera gravatar image

updated 2012-07-13 04:24:18 +0000

Hi all,

Background: Let's say you want to analyze seasonal time series data - for example monthly data. The data are stored in one column - first observation is the past. Let's say you want to look closer on how one specific month has developed over time - for example August. Assume that the time series start in February (the first observation). Question: How can Shazam (11.0.9) select one specific month (in this case August) for all years?

Best regards,P.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2012-07-13 07:16:02 +0000

updated 2012-07-13 15:59:39 +0000

This can be accomplished in a number of ways.

1) Use of the Expanded Form of the SAMPLE command to select only the ranges (months) needed.

e.g. to select each August, assuming the series begins with February

sample 7 7 19 19 31 31 43 43 55 55

and so on for as many observations as you need.

2) Via a SKIPIF command using a supplied month index

Read monthly observations along with a month index from a free format text file, skip all but the 8th month indicated by the index, produce summary statistics for the subset and finally graph the variable.

read (testdata.txt) month variable 
stat variable
graph variable

3) Via a SKIPIF command using an index we generate

Read monthly observations from a free format text file, create a month index, skip all but the 8th month indicated by the index, produce summary statistics for the subset and finally graph the variable formatting the x axis to show the month counter.

* Assuming we have monthly observations stored in a free format text file 
* where the 1st observation is a February. Counter is from 1...N.
read (testdata1.txt) variable 

* Generate month index noting the data starts from February
*   TIME(1) creates an index by adding 1 to each value.
*   MOD(12,12) = 0 so replace all 0s with 12
genr month_ind=mod(time(1),12)
if(month_ind.eq.0) month_ind = 12

* Create a time index for the graph axis and adjust for start of February
time 2007 12 months
genr month = lag(months,-1)

* Skip any observations we do not want to use in estimation or graphing
set nowarnskip

* Check basic statistics of the variable for just the 8th month
stat variable

* Draw a Graph
*  Use the TIMEFMT and AXISFMT commands to customise the X axis
*  Plot against the corrected month index
timefmt %Y.%m
axisfmt %m/%Y 
graph variable month / timefmt axisfmt line

The output from this is:

 |_stat variable
 NAME        N    MEAN        ST. DEV      VARIANCE     MINIMUM      MAXIMUM
 VARIABLE      4  0.16307E+08 0.15739E+08 0.24772E+15  0.11308E+06  0.36045E+08

The graph produced was:


The data file used in this was: testdata1.txt

edit flag offensive delete link more
Login/Signup to Answer

Question Tools


Asked: 2012-07-11 06:04:06 +0000

Seen: 606 times

Last updated: Jul 13 '12