0

I'm running analysis on a certain dataset, and while looking over the data, I noticed that the PACF have no values (besides the first of course) that are significant, while the auto correlation function's (ACF's) values are all mostly significant. So, I decided on creating an MA model (since the ACF's values are the ones that are significant), but I'm not sure how to do this in R, and how to decide the size of the window.

Would this below suffice?

arima(time-series_object, order = c(0,0,1))

Again, given an ACF graph, how should we decide the what MA we should use (e.g. (0,0,1), (0,1,1), etc.)?

B--rian
  • 5,578
  • 10
  • 38
  • 89
Jaigus
  • 1,422
  • 1
  • 16
  • 31
  • That function you provide is exactly creating an ARIMA(0,0,1), i.e. moving average model of order 1. Is the question about "how to determine the right model" or "how to easily create various moving average models that I can later pick one"? – Nuclear03020704 May 13 '20 at 08:50

1 Answers1

0

There are many ways to create a moving average in R, I personally always did it in plain R using filter(), simply because I see what is happening. Assume that your data is stored in two vectors x <- 1:100 and y <- sin(x/10) + rnorm(100,sd=.1).

One way of moving average calculation would be to average the current value and its 9 previous values if the window length is 10:

f <- rep(1/10, 10)
z <- filter(y, f, sides=1)

Now, you have your smoothed value is z. You will see that z starts with 9 NA values because the first 9 steps you do not have enough values to average yet.

Having a minimal reproducible data set would help answer the 2nd part of your question:

[How do] we decide [...] what MA we should use (e.g. (0,0,1), (0,1,1), etc.)?

Related

B--rian
  • 5,578
  • 10
  • 38
  • 89