Please help. I try to re-produce R-script by plotting a set of functionWhen i
running code: plot(Vectorize(running.acf.max))it gets the error message like
this: Error in curve(expr = x, from = from, to = to, xlim = xlim, ylab = ylab,
: 'expr' did not evaluate to an object of length 'n'
Even though i have vectorized the function argument.
data = read.csv("EURJPY.m14401.csv", header=T)
returns = diff(log(data$C))
running.acf.max<-function(data=returns, window=100, nlags=5, plot=T, main=''){
clevel<-qnorm(0.5+0.95/2)/sqrt(window)
series<-rollapply(data=returns, window, align='right',by=1,function(w)
{
acfs<-pacf(coredata(w),lag.max=nlags,plot=F)$acf
cum<-cumsum(acfs)
low<-min(cum)
high<-max(cum)
if(abs(low)>abs(high))
low
else
high
})
if(plot)
{
plot(series,main=main,cex.axis=0.65,xlab='',ylab='acf(cum max)')
abline(h=0,col='blue')
abline(h=-clevel,col='red', lty=2)
abline(h=clevel,col='red', lty=2)
}
invisible(series)
}
plot(running.acf.max)
plot(Vectorize(running.acf.max))
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.