CUMSUM {bimets}R Documentation

Cumulative Sum

Description

This function returns the cumulative sum of the elements of the input array or time series. The result is an object of the same class of the input, and its elements are the cumulative sum of the current and the previous elements of the input.
If the input is a time series, users can provide the argument TSRANGE in order to project the input time series before the cumulative sum.
CUMULO is an alias form CUMSUM with the argument MODE='YEARLY'.

Usage

CUMSUM(x=NULL, TSRANGE=NULL, MODE=NULL, avoidCompliance=FALSE,...)
CUMULO(x=NULL, TSRANGE=NULL, avoidCompliance=FALSE,...)

Arguments

x

Input numerical array or time series that must satisfy the compliance control check defined in is.bimets.

TSRANGE

Optional date range of operations that process time series. TSRANGE must be specified as an array composed by starting year, starting period, ending year and ending period,
i.e. TSRANGE=c(START_YEAR,START_PERIOD,END_YEAR,END_PERIOD). The projection into the time interval specified in TSRANGE takes place before the cumulative sum.

MODE

When selecting MODE='YEARLY' or MODE='MONTHLY' the sum is reset to zero when a new year or a new month starts.

avoidCompliance

If TRUE, compliance control check of input time series will be skipped. See is.bimets

...

Backward compatibility.

Value

This function returns an object of the same class of the input, i.e. an array or a BIMETS time series.

See Also

TSPROJECT
MOVAVG
TSDELTA
TSLAG
TSPROJECT
TSEXTEND
TSLEAD
INDEXNUM
CUMPROD

Examples

	
	#create ts
	ts1=TSERIES(INTS(1,30),START=c(2000,1),FREQ='M')
	out_CUMSUM=CUMSUM(ts1)
	TABIT(out_CUMSUM)
	
	    
	out_CUMSUM=CUMSUM(ts1,TSRANGE=c(2000,4,2001,7))	
	out_CUMSUM_Y=CUMSUM(ts1,TSRANGE=c(2000,4,2001,7),MODE='YEARLY')
	TABIT(ts1,out_CUMSUM,out_CUMSUM_Y)
	
	
  
	#define an array
	arr1=c(INTS(1,10),INTS(-1,-10))
	out_CUMSUM=CUMSUM(arr1)
	print(out_CUMSUM)
	
	#print...1  3  6 10 15 21 ... 27 19 10  0
  
	

[Package bimets version 1.5.3 Index]