lag_rain: Get rainfall matrix

View source: R/util.R

lag_rainR Documentation

Get rainfall matrix

Description

'P <- lagmatrix(R)' creates a lagged (shifted) version of a vector. The _lagmatrix_ function is useful for creating a regression matrix of explanatory variables for rainfall over time.

Usage

lag_rain(P)

Arguments

P

Daily Rainfall, in inches

Details

Given a vector of time series data, such as daily rainfall: $$ \left[ P_1, P_2, P_3, \cdots , P_m \right]$$ A lagged transform of the time series is found by shifting the first lag, then the second lag, and so on, until the end of the vector. The _lagmatrix_ result will be the following:

$$ \beginbmatrix P_1 & 0 & 0 & \cdots & 0 & 0 & \cdots & 0 & 0 \ P_2 & P_1 & 0 & \cdots & 0 & 0 & \cdots & 0 & 0 \ P_3 & P_2 & P_1 & \cdots & 0 & 0 & \cdots & 0 & 0 \ \vdots & &&& \vdots &&& \vdots \ P_m & P_m-1 & P_m-2 & \cdots & P_1 & 0 & \cdots & 0 & 0 \ 0 & P_m & P_m-1 & \cdots & P_2 & P_1 & \cdots & 0 & 0 \ \vdots & &&& \vdots &&& \vdots \ 0 & 0 & 0 & \cdots & 0 & 0 & \cdots & P_m & P_m-1 \ 0 & 0 & 0 & \cdots & 0 & 0 & \cdots & 0 & P_m \ \endbmatrix $$

Value

A square matrix of lagged rainfall hyetographs

Examples

data(DF)
lag_rain(DF$rain)

dCraigJones/rSSOAP documentation built on Aug. 12, 2022, 10:11 p.m.