We started by downloading Google's stock prices from the given years and resampling them to weekly frequency by taking the last (adjusted) close price in every week. In Step 3, we applied the first difference in order to make the series stationary.
Step 4 is very important because, because we determined the order of the ARIMA model based on these results. We tested for stationarity using a custom function called test_autocorrelation. First, the series turned out to be stationary, so we knew that the order of integration was d=1. We determined the suggested lag order (p) by looking at the last lag after the PACF function crossed the confidence interval. In this case, it was p=2. Analogically, for the moving average order, we looked at the ACF plot to determine q=1. This way, we specified the model as ARIMA(2,1,1) in Step 5. We printed a summary using the summary method of the fitted model.
In Step 6 and Step 7, we investigated the goodness of fit by looking at the model's residuals. If the fit is good, the residuals should be similar to the white noise. That is why we used four different types of plots to investigate how closely the residuals resemble the white noise.
Finally, we employed the Ljung-Box test (the acorr_ljungbox function from statsmodels) for no significant correlation and plotted the results.