Learn R Programming

s2dv (version 0.0.1)

Trend: Compute the trend

Description

Compute the linear trend or any degree of polynomial regression along the forecast time. It returns the regression coefficients (including the intercept) and the confidence intervals if needed. The detrended array is also provided. The confidence interval relies on the student-T distribution.

Usage

Trend(data, time_dim = "sdate", interval = 1, polydeg = 1, conf = TRUE,
  conf.lev = 0.95, ncores = NULL)

Arguments

data

An numeric array including the dimension along which the trend is computed.

time_dim

A character string indicating the dimension along which to compute the trend. The default value is 'sdate'.

interval

A positive numeric indicating the unit length between two points along 'time_dim' dimension. The default value is 1.

polydeg

A positive integer indicating the degree of polynomial regression. The default value is 1.

conf

A logical value indicating whether to retrieve the confidence intervals or not. The default value is TRUE.

conf.lev

A numeric indicating the confidence level for the regression computation. The default value is 0.95.

ncores

An integer indicating the number of cores to use for parallel computation. The default value is NULL.

Value

A list containing:

$trend

A numeric array with the first dimension 'stats', followed by the same dimensions as parameter 'data' except the 'time_dim' dimension. The length of the 'stats' dimension should be polydeg + 1, containing the regression coefficients from the lowest order (i.e., intercept) to the highest degree.

$conf.lower

A numeric array with the first dimension 'stats', followed by the same dimensions as parameter 'data' except the 'time_dim' dimension. The length of the 'stats' dimension should be polydeg + 1, containing the lower limit of the conf.lev% confidence interval for all the regression coefficients with the same order as $trend. Only present conf = TRUE.

$conf.upper

A numeric array with the first dimension 'stats', followed by the same dimensions as parameter 'data' except the 'time_dim' dimension. The length of the 'stats' dimension should be polydeg + 1, containing the upper limit of the conf.lev% confidence interval for all the regression coefficients with the same order as $trend. Only present conf = TRUE.

$detrended

A numeric array with the same dimensions as paramter 'data', containing the detrended values along the 'time_dim' dimension.

Examples

Run this code
# NOT RUN {
# Load sample data as in Load() example:
example(Load)
months_between_startdates <- 60
trend <- Trend(sampleData$obs, polydeg = 2)

# }

Run the code above in your browser using DataLab