So what we do first, we'll have to transform, right?

We talked about this before.

The transformation is going to, basically, the logarithm.

So we take the logarithm of the data to stabilize the variance.

And to remove the trend, we take the difference.

So difference of the logarithm of the dataset.

This is also effectively called log-return in specifically financial time series.

So rt is difference of the logarithms, in other words logarithm of the division.

This is a side note, we are not modelling rt.

We are basically modelling the logarithm of the transformation.

This is basically time series of the log returns, and

we Help to see a stationary time series here.

We can see that variance is different in the middle part of the data rather than

the end point, but if you're going to ignore that, and

you're going to say okay maybe restabilize by taking a lower [INAUDIBLE].

And I look at ACF and PACF, as you can see we do have a strong auto correlation with

lag four, lag eight and that is because of the seasonality.

So what we want to do we would like to take the seasonal differencing in this

case the capital D is going to be 1.

In R this is basically the transformed and difference data,

we take the difference with lag 4.

This becomes seasonal differencing, and if we plot the data set,

now our data set jj is differenced seasonally and non-seasonally.

Actually, the lower item of the jj is differenced seasonally and non-seasonally.

And we have some stationary, Time series here.

So what we're going to do.

We're going to look at, as we said, the Ljung-Box test.

So Ljung-Box test is basically a Box.test in R.

And we're going to take the lag as the logarithm of the data.

This is the common adoption.

And then we'll look at the p value and p value is very, very small.

So if the P value is small then we reject the null hypothesis that there is no

auto correlation between previous lags so there is some auto correlation

between previous lags and we're going to find them using ACF and PACF.

So let's look at ACF.

This is the ACF of the resulted data and this is the PACF of the resulted data.

ACF if I look at the closer spikes here, I have a spike at Lag 1 and

then it dies off, so this suggest MA1 models.

So the order of moving average terms would be one, but

if I look at lags, the seasonal lags, which is four.

In this case, it's period one, but the lag is four.

It is almost significant.

Not really significant because it's below.

It does not cross this dashed line.

But it's almost significant, so we're going to assume that.

So we might have some seasonal correlation, and

so this will tell us that maybe we have Order 1,

seasonal moving average term.

If I look at PACF, I see that PACF, there's a significant lag at 1,

again, then this dies off.

This will tell me, suggest me that maybe order of auto-regressive term is one,

and I see the other significant other correlation at lag four,

that it will tell me maybe the order of the seasonal auto-regressive term is one.

And then the other correlation dies off.

Okay, so ACF told us that q is either 1 or maybe it's 0,

we get to look at both of them, and capital Q is 0, 1.

Partial auto-correlation told us that p is maybe 0 and 1, and capital P is 0 and 1.

So we'll look at this SARIMA model's p, 1, q, capital P, 1, Q, 4.

4 is my span of the seasonality.

And these are the models for logarithm of the data,

and immediately just determine that PQ,

capital P capital Q, is going to be either zero or one.

We're going to use ARIMA routine from R, basically, we have the order.

This is the order for non-seasonal part.

And then we have a seasonal part including the period.