ma.vector {OLIN}R Documentation

Calculation of moving average for a vector

Description

This functions calculates the moving average for a vector.

Usage

ma.vector(A,M,av="median",delta=50)

Arguments

A vector of predictor to be used for sorting
M vector of variable to be averaged
av averaging by mean or median (default)
delta even integer determining the size of the sliding window (2*delta+1.)

Details

The function ma.vector first sorts M according to the corresponding values of A. Subsequently, a moving average is calculated with window size (2*delta+1). The values for the moving average are set to zero if the corresponding window extends over the boarder of the vector M.

Value

Vector with moving average values of M

Author(s)

Matthias E. Futschik,http://itb.biologie.hu-berlin.de/~futschik

See Also

ma.matrix

Examples

### LOADING DATA
data(sw)
A <- maA(sw[,1])
M <- maM(sw[,1])
  
# MA-PLOT 
plot(A,M)

# MOVING AVERAGE
Mav <- ma.vector(A,M,av="median",delta=100)
points(A,Mav,col="red")

[Package OLIN version 1.3.2 Index]