how to decide p of ACF and q of PACF in AR, MA, ARMA and ARIMA?
<p>I am confused about how to calculate p of ACF and q of PACF in AR, MA, ARMA and ARIMA. For example, in R, we use acf or pacf to get the best p and q.</p>

<p>However, based on the information I have read, p is the order of AR and q is the order of MA. Let's say p=2, then AR(2) is supposed to be <code>y_t=a*y_t-1+b*y_t-2+c</code>. We can calculate acf function (in R) when lag=1,2,3.... to find which lag brings the biggest acf function value. The same thing happens to MA for deciding q. But, does this mean that p and q have already been set up?</p>

<p>I guess here is the steps. But I am not sure if I am right.
So, let's say in R's functions acf and pacf, is this the real process:
1. For p=1, set lag=1,2,3,...max to see which lag has the biggest autocorrelation value.
2. For p=2,3,4..., do the same thing to find the lags.
3. Compare those values with each other. Let's say the biggest autocorrelation value comes when p=2 and lag=4, when we say the order of AR, ie. p, is 2?</p>

<p>Cloud anyone please give me an example showing exactly how to estimate p and q?</p>