I'm trying to use a function in order to read in different models. Using the code below without a function works. When I use the function and call it, I will get the error
Error: evaluation nested too deeply: infinite recursion / options(expressions=)?
Can anyone tell me why?
x=rnorm(1000)+sin(c(1:1000)/100)#random data+ sinus superimposed
plot <- function(model){
par(mfrow=c(2,2))# plot window settings
plot(model)
lines(filter(model,rep(1/30,30)),col='red')
plot(filter(model,rep(1/30,30)))
plot(model-filter(model,rep(1/30,30)))
# variances of variable, long term variability and short term variability
var(model)
var(filter(model, rep(1/30,30)),na.rm=T)
var(model-filter(model, rep(1/30,30)),na.rm=T)
}
plot(x)