lag_rain | R Documentation |
'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.
lag_rain(P)
P |
Daily Rainfall, in inches |
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 $$
A square matrix of lagged rainfall hyetographs
data(DF) lag_rain(DF$rain)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.