------------------------------------------------------------------------------- help forcycleplot-------------------------------------------------------------------------------

Cycle plot (month plot or seasonal subseries plot)

cycleplotresponsevars month year[ifexp] [inrange] [,length(#)start(#)summary(egen_function)mylabels(labels_list)line_options]

Description

cycleplotproduces a graph of one or moreresponsevarsbymonthandyear.responsevarsmay be raw data or the seasonal components of such data. The descriptorsmonthandyearare used for concreteness. Formonthandyear, read strictlyshorter periodandlonger period. That is, the plot may be useful whenever periods (e.g. years) are divided into a fixed number of shorter periods (e.g. months, quarters).monthshould be a variable taking on values 1,...,length. The graph shows a fixed number of subseries, one for each distinctmonth. The data are also sorted so that there are no connections between subseries.Terminology for this plot is not stable. See notes with

References.

RemarksNote that you can get close to this kind of plot with no more than official Stata, as in

. twoway line air year, by(month, row(1))The advantages of

cycleplotinclude more space being used to show data on the plot; the flexibility of different starts to the cycle; and the possibility of comparison with a subseries summary.

Options

length(#)indicates that data are for#shorter periods within each longer period. The default is 12, for months within a year.

start(#)indicates the first value ofmonthplotted on thexaxis. Default 1. This option may be used whenever there is some better natural start to theyearthan (say) January. For example, rainfall in climates with a wet season either side of December is best plotted starting in (say) July.

summary(egen_function)calculates a summary function to be shown for eachmonth. The summary function may be any function acceptable to egen that has syntax likeegennewvar= mean(response), by(month).meanandmedianare the most obvious possibilities. Know that whenever summaries are plotted the order of variables on the graph is all the response variables followed by all the corresponding summary variables.

mylabels(labels_list)specifies text labels to use on the time axis, instead of default labels such as 1/12. The number of labels specified should be precisely the same as the argument oflength(), or by default 12. Labels consisting of two or more words should be bound in" ". Labels including"should be bound in`" "'. Note thatmylabels(`c(Mons)')specifiesJan Feb Mar Apr May Jun Jul AugSep Oct Nov Decand thatmylabels(`c(Months)')specifiesJanuaryFebruary...November December. Do not rotate the list to reflect astart()choice other than 1. This will be done automatically.

line_optionsrefers to options of graph twoway line.connect(L ..)is wired in. Note the possibility of using recast() to get a different twoway type.

Examples. cycleplot rainfall month year, xla(1/12). cycleplot rainfall month year, xla(1/12) start(7)

. cycleplot GDP quarter year, length(4)

. webuse air2, clear. egen month = seq(), to(12). gen year = floor(time). cycleplot air month year, xla(1/12) start(2) yscale(log) su(median). cycleplot air month year, xla(1/12) start(2) yscale(log) su(median)myla(`c(Mons)'). cycleplot air month year, xla(1/12) start(2) yscale(log) su(median)myla(J F M A M J J A S O N D)

. cycleplot males females month year, start(8) recast(connected) ysc(log)yla(3000 2000 1000 500 300) yla(, ang(h)) legend(col(1) pos(11)ring(0)) mylabels(`c(Mons)') subtitle("UK deaths from bronchitis,emphysema and asthma 1974-79") msize(*0.8 ..)

AcknowledgementsA question from Aurelio Tobias led to the

mylabels()option.

AuthorNicholas J. Cox, Durham University n.j.cox@durham.ac.uk

ReferencesOriginal references:

Becker, R.A., Chambers, J.M. and Wilks, A.R. 1988.

The new S language: aprogramming environment for data analysis and graphics.Pacific Grove, CA: Wadsworth & Brooks/Cole, pp.508-509. [month plot]Cleveland, R.B., Cleveland, W.S., McRae, J.E. and Terpenning, I. 1990. STL: a seasonal-trend decomposition procedure based on loess.

Journal ofOfficial Statistics6: 3-73. [cycle-subseries plot]Cleveland, W.S. 1993.

Visualizing data.Summit, NJ: Hobart Press, pp.164-165. [cycle plot]Cleveland, W.S. 1994.

The elements of graphing data.Summit, NJ: Hobart Press, pp.186-187. [cycle plot]Cleveland, W.S. and Devlin, S.J. 1980. Calendar effects in monthly time series: detection by spectrum analysis and graphical methods.

Journal,American Statistical Association75: 487-496. [seasonal-by-month plot]Cleveland, W.S., Freeny, A.E. and Graedel, T.E. 1983. The seasonal component of atmospheric CO2: information from new approaches to the decomposition of seasonal time series.

Journal of Geophysical Research88: 10934-10946. [seasonal subseries plot]Cleveland, W.S. and Terpenning, I.J. 1982. Graphical methods for seasonal adjustment.

Journal, American Statistical Association77: 52-62. [seasonal subseries plot]Robbins, N.M. 2005.

Creating more effective graphs.Hoboken, NJ: John Wiley. [month plot, cycle plot]More on

c()lists:Cox, N.J. 2004. Following special sequences.

Stata Journal4(2): 223.

Also seeOn-line: help for graph twoway line, egen, creturn