问题描述:

So here is the code to create an MA(q) model that takes in values 'thetas', 'sigsq', and 'T'.

masim <- function(thetas, sigsq, T)

{

q <- length(thetas)

noise <- rnorm(T+q, sd=sqrt(sigsq))

x <- c(noise[1:q], rep(0,T))

for( i in (q+1):(T+q)){

x[i] <- thetas %*% x[i-(1:q)] + noise[i]

}

x <- x[(q+1):(T+q)]

x

}

Now if I run an autocorrelation on masim like this for example:

acf(masim(0.5,1,10000))

It works fine, with a great ACF plot. However if I run this example:

acf(masim(2,1,10000))

Then I get this error.

Error in plot.window(...) : need finite 'ylim' values

In addition: Warning messages:

1: In min(x) : no non-missing arguments to min; returning Inf

2: In max(x) : no non-missing arguments to max; returning -Inf

My coding partner next to me got both of his to work.

相关阅读:
Top