Forms summaries for a Markov model from rainfall data (J.O. Ong’ala & D.B. Baird).
|Controls printed output (
||What plots to display (
||Day as a date or a day number within the year|
||Values to define the daily rainfall states; default 0.85|
||Defines the order of the Markov chain (0…5); default 1|
||Whether to use a high-order Markov chain; (
||The amounts of rainfall prior to the first day; default
||What to save in a spreadsheet (
||The daily rainfall amounts|
||Window to plot the graph; default 3 for
||The title for the plot; default uses an automatic description|
||Saves the counts by Markov state and day|
||Saves the mean rainfall by Markov wet states and day|
||Saves a pointer to variates of probabilities of a wet day by class|
||Saves the Markov class for each day|
||Saves a pointer to tables of counts for each state|
||File (with extension
RFSUMMARY creates summaries from rainfall data for a Markov chain model analysis. The Markov model splits the days into different classes based on the history of the preceding days. This is to allow for different probabilities and amounts of rainfall on a day according to what happened previously: for example, in most climates, it is more likely to rain on a day following previous rain.
The daily states, order and type of Markov model are specified by the
HIGHORDER options, respectively. If the
LIMITS option is set to a scalar or variate of length one, this defines the breakpoint between dry and wet days. A small positive value treats days with less than this amount of rainfall as dry days (these are also removed from the rainfall for wet days). If
LIMITS is set to a variate of length of two or more, the rainfall states are defined as the days with rainfall less than or equal to these limits, with an extra group for rainfall greater than the top limit. The
ORDER option specifies the number of previous days to use when forming the Markov classes.
The classes are the combination of the daily states over the history length defined by
ORDER. (So there will be
(NVALUES(LIMITS)+1)**(ORDER+1) classes.) If there are two rainfall states, these are labelled w and d for wet and dry on each day. Otherwise they are labelled by the integers from 0 upwards. When there are two states, the default
HIGHORDER=no gives all the unique combinations of wet and dry days over these days. Setting
HIGHORDER=yes collapses the states to just the number of dry days preceding a wet day. For example, with
HIGHORDER=no, the 8 states are ddd, ddw, dwd, dww, wdd, wdw, wwd and www (where d = dry day and w = wet day); with
HIGHORDER=yes, the 6 states are ddd, ddw, dw, wd, wdd, and ww, as dwd and dww are combined into dw and wwd and www are combined into ww.
ORDER must be at between 0 and 3 for
HIGHORDER=no and between 2 and 5 for
DAY option gives the dates or the day number within a year (1…366), and the
DATA parameter gives the amount of rainfall on these dates. The data should be sorted into chronological order with no missing days. (Missing values should be entered for any days with no observations.) The
INITIAL option can specify the amount of rain on the days preceding the first day in
DATA; this should have
ORDER values. If
INITIAL is not set, the first
ORDER days will not contribute to the counts and amounts.
You can save the summaries with the
COUNTS saves a table of counts classified by day number within the year (1…366) and Markov class (e.g. dd, wd, dw and ww);
AMOUNTS saves a table of the sum of rainfall amounts classified by day and Markov wet classes (e.g. wd and ww);
PROBABILITIES saves a pointer to a set of variates for each wet class giving probability of a wet day vs. a dry day for the days;
CATEGORIES saves a factor giving the Markov class for each date; and
STATECOUNTS saves a pointer to tables for each state defined by
LIMITS, giving the counts by Markov class and day.
Printed output is controlled by the
counts counts by day and Markov class;
amounts amounts by day and wet Markov class; and
probabilities probabilities by day and wet Markov class.
The summaries can be displayed in a spreadsheet by setting the
SPREADSHEET option to the following settings:
counts creates a sheet containing the counts for each day by the Markov classes;
amounts shows the amounts of rainfall in the wet classes; and
probabilities shows the probability of rainfall in the wet classes.
The spreadsheet can be saved to a file by setting the
OUTFILE parameter to a Genstat or Excel spreadsheet filename (
You can set option
probabilities to plot the probabilities. The
TITLE parameter can supply a title for the graph; if this not set, a descriptive title will be created from the Markov chain options. The
WINDOW parameter specifies the window to use for the graph.
The procedure calculates the class of each day, and then tabulates these to create summaries. If dates are provided in
DAY, these are converted to days in the year by the
NDAYINYEAR function. Note: the 29 of February (which is only present in leap years) is day 60. The 1st March is always day 61.
DAY variates can be restricted to analyse a subset of the data. If both
DAY are restricted, the restrictions must be consistent.
Ong’ala, J.O. (2011). Simplifying the Markov chain analysis of rainfall data using Genstat. MSc Thesis, Maseno University.
CAPTION 'RFSUMMARY example','41 years rainfall for Katumani, Kenya'; \ STYLE=meta,minor IMPORT [PRINT=summary] '%Data%/Rainfall Katumani 1961-2001.gsh' RFSUMMARY [PRINT=counts,amounts,probabilities; PLOT=probabilities; \ DAY=Date; ORDER=1; SPREADSHEET=counts,amounts,probabilities] Rainfall; \ COUNTS=RFCounts; AMOUNTS=RFAmounts; TITLE='Katumani rainfall 1961-2001' RFFPROBAB [PLOT=results] COUNTS=RFCounts; \ TITLE='Katumani rainfall probabilities 1961-2001' RFFAMOUNT [PLOT=results] COUNTS=RFCounts; \ AMOUNTS=RFAmounts; TITLE='Katumani rainfall amounts 1961-2001' RFSUMMARY [PRINT=*; PLOT=*; DAY=Date; ORDER=3; HIGHORDER=yes] Rainfall; \ COUNTS=RFCounts; AMOUNTS=RFAmounts RFFPROBAB [PLOT=results; SPREADSHEET=] COUNTS=RFCounts; \ TITLE='Katumani rainfall probabilities 1961-2001 (high order 3)' RFFAMOUNT [PLOT=results; SPREADSHEET=] COUNTS=RFCounts; AMOUNTS=RFAmounts; \ TITLE='Katumani rainfall amounts 1961-2001 (high order 3)'