ism: Apply the Index Sequential Method

View source: R/ism.R

ismR Documentation

Apply the Index Sequential Method

Description

ism() applies the Index Sequential Method to a single trace of data to create multiple traces. ism() will work on matrices, xts, nfd, crss_nf, and crssi objects. ism_get_site_matrix() is a deprecated precursor to this function that only works on xts objects.

Usage

ism(x, n_years_keep = NA, ...)

## S3 method for class 'crssi'
ism(x, n_years_keep = NA, ...)

## S3 method for class 'crss_nf'
ism(x, n_years_keep = NA, ...)

## S3 method for class 'nfd'
ism(x, n_years_keep = NA, ...)

## S3 method for class 'xts'
ism(x, n_years_keep = NA, ...)

## S3 method for class 'matrix'
ism(x, n_years_keep = NA, is_monthly, ...)

ism_get_site_matrix(xtsData, startMonth, nYrs = NA, monthly = TRUE)

Arguments

x

An R object. ism() is implemented for matrices, xts, nfd, crss_nf, and crssi objects.

n_years_keep

The number of years of data to keep. This must be <= the number of years of data that exists in x.

...

Further arguments passed to subsequent methods.

is_monthly

Boolean. TRUE if data are monthly. FALSE if data are annual. See Details.

xtsData

An xts vector.

startMonth

The start month and year of the return matrix. Should be able to be cast to a zoo::yearmon.

nYrs

The number of years to create the data for. Defaults to the number of years in xtsData, but can be less.

monthly

Boolean that should be set to TRUE if the data are monthly; should set to FALSE if annual data.

Details

ism() will determine if the data are annual or monthly (or contain both for objects inheriting from nfd), and will act accordingly. The time step can be forced by using is_monthly, but that is only necessary for matrices. If is_monthly is used with an nfd type object that contains annual and monthly data, an error will occur.

ism_get_site_matrix() is a deprecated version of ism() that only works on xts objects. It takes in 1 column of historical data for a single site and applies (ISM) to it. This function allows you to change the start date of the returned data in it, while ism() does not. When using ⁠ism(), [reindex()] should be used after it to change the start date. ⁠ism_get_site_matrix()⁠can be used on monthly or annual data. If applying it to monthly data, then⁠xtsData⁠needs to be monthly data, and⁠monthly⁠should be set to⁠TRUE⁠. If using annual data, then ⁠xtsData⁠should be annual, i.e., all with a December time stamp, and⁠monthly⁠should be set to⁠FALSE⁠. If ⁠monthlyisFALSEandxtsData' is monthly data, an error will occur.

Value

ism() returns an object of the same class as x, but with more traces, and potentially trimmed to the number of years specified by n_years_keep.

ism_get_site_matrix() returns an xts matrix with the number of years/months specified by nYrs and the number of columns equal to the number of years in xtsData

Examples

# monthly data, that will create a 48x4 xts matrix
t1 <- xts::xts(1:48, zoo::as.yearmon("Jan 2000") + seq(0,47)/12)
ism(t1)

# annual data that will create a 5 x 6 matrix
t2 <- xts::xts(1:6, zoo::as.yearmon("Dec 2000") + 0:5)
ism(t2, n_years_keep = 5)


BoulderCodeHub/CRSSIO documentation built on July 2, 2023, 5:15 p.m.