Fits harmonic models to mean rainfall amounts for a Markov model (J.O. Ong’ala & D.B. Baird).

### Options

`PRINT` = string tokens |
Controls printed output for each fitted model (`model` , `deviance` , `summary` , `estimates` , `correlations` , `fittedvalues` , `accumulated` , `monitoring` , `confidence` ); default `mode` , `summ` , `esti` , `accu` |

`PLOT` = string token |
What plots to display (`results` ); default `resu` |

`NHARMONICS` = scalar |
Defines the number of harmonics to fit (1…4); default 2 |

`SPREADSHEET` = string tokens |
What to save in a spreadsheet (`results` ); default `*` |

### Parameters

`COUNTS` = table |
Supplies the table of counts by Markov class and day number within the year (1…366) |

`AMOUNTS` = tables |
Supplies the table of mean rainfall by wet Markov class and day |

`WINDOW` = scalars |
Window for the graph; default 3 for a single class and 1 otherwise |

`TITLE` = texts |
Title for the graph; default forms an automatic description |

`RESULTS` = pointers |
Saves a pointer to the variates of fitted rainfall means by day for each wet class |

`OUTFILE` = texts |
File(with extension `.gwb` , or `.xlsx` ) to save the spreadsheet of results |

### Description

`RFFAMOUNT`

fits harmonic (Fourier) models with a period of 366 days to rainfall summaries produced by `RFSUMMARY`

. The Markov model fitted by `RFSUMMARY`

splits the days into different classes based on the history of the preceding days. The daily states, order and type of the Markov model can be formed by `RFSUMMARY`

, but only models with two states are handled. The harmonic model is a linear combination of sine and cosine terms with periods of 366/*n*.. The number of harmonic terms (*n*) is specified by the `NHARMONICS`

option and can be 1, 2, 3 or 4.

The `COUNTS`

and `AMOUNTS`

parameters give the table of rainfall counts and mean amounts for each Markov state by day within the year (1…366). The `RESULTS`

parameter can save variates of fitted amounts for the wet (e.g. ww and wd) Markov classes for each day within a year.

Printed output of the summaries is controlled by the `PRINT`

option, with the same settings as the `FIT`

directive. The fitted amounts can be displayed in a spreadsheet using by setting option `SPREADSHEET`

=`results`

. This creates a sheet containing the variates giving the fitted amounts of rainfall for each day in the year by the wet Markov classes. The spreadsheet can be saved to a file by setting the `OUTFILE`

parameter to a Genstat or Excel spreadsheet filename (`.gwb`

or `.xlsx`

).

You can set option `PLOT=results`

to plot the fitted amounts. 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.

Options: `PRINT`

, `PLOT`

, `NHARMONICS`

, `SPREADSHEET`

.

Parameters: `COUNTS`

, `AMOUNTS`

, `WINDOW`

, `TITLE`

, `RESULTS`

, `OUTFILE`

.

### Method

The procedure calculates sine and cosine terms for the number of harmonics and fits a gamma generalized linear model to the rainfall means weighted by the counts of the number of wet days.

### Reference

Ong’ala, J.O. (2011). Simplifying the Markov chain analysis of rainfall data using Genstat. *MSc Thesis*, Maseno University.

### See also

Directive: `FIT`

.

Procedures: `RFFPROBABILITY`

, `RFSUMMARY`

.

Commands for: Basic and nonparametric statistics.

### Example

CAPTION 'RFFAMOUNT example','41 years data for Katumani, Kenya'; \ STYLE=meta,minor IMPORT [PRINT=summary] '%Data%/Rainfall Katumani 1961-2001.gsh' RFSUMMARY [PRINT=*; PLOT=*; DAY=Date; ORDER=1] Rainfall; \ COUNTS=RFCounts; AMOUNTS=RFAmounts RFFAMOUNT [PLOT=results; SPREADSHEET=results] COUNTS=RFCounts; \ AMOUNTS=RFAmounts; TITLE='Katumani rainfall amounts 1961-2001'