running function (default median absolute deviation)

Share:

Description

running function (default median absolute deviation)

Usage

1
runFun(aref, k = 301, func = mad)

Arguments

aref

data array

k

window in data points, default 300

func

default med but can be any function taking a vector and returning a summary

See Also

runmed

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
x = rnorm(500)
x = c(x,rnorm(1000,3,2))
x = c(x,runif(1000,4,6))
y = runFun(x,k=51,func=mad)
hist(y)#[500:490]
y2 = runFun(x,k=51,func=median)
plot(x,pch="*")
lines(y2,col=2,lwd=3)
lines(y2+y,col=3,lwd=3)
lines(y2-y,col=3,lwd=3)
tic = runFun(x,k=51,func=function(x,...){mean(x)})
plot(x,pch=".")
abline(h=0,col=2)
lines(tic,col=3,lwd=3)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.