Home>
I want to plot the autocorrelation and partial autocorrelation of the original series and its difference series for time series analysis.
import numpy as np
import statsmodels.api as sm
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
#Load data
marketcap = pd.read_csv ('stock_market_cap.csv', index_col = 0)
Check # a1 (original series).
a1 = marketcap ['Asset1']
plt.plot (a1)
fig = plt.figure (figsize = (12,8))
ax1 = fig.add_subplot (211)
fig = sm.graphics.tsa.plot_acf (a1, lags = 20, ax = ax1)
ax2 = fig.add_subplot (212)
fig = sm.graphics.tsa.plot_pacf (a1, lags = 20, ax = ax2)
Check # a2 (difference series).
a2 = a1-a1.shift ()
plt.plot (a2)
fig = plt.figure (figsize = (12,8))
ax1 = fig.add_subplot (211)
fig = sm.graphics.tsa.plot_acf (a2, lags = 20, ax = ax1)
ax2 = fig.add_subplot (212)
fig = sm.graphics.tsa.plot_pacf (a2, lags = 20, ax = ax2)
The original and difference series and their correlograms are as follows.
[Original Series]
]
[Difference series]
-
Answer # 1
Related articles
- python - causality in time series data analysis
- i want to change the default of python to python3 series
- python practical data analysis 100 knock chapter 1 knock 4
- python - even if the time series data is included in the arima model, the predicted value becomes almost 0
- python 3x - i want to make a scatter plot of the results of regression analysis
- python - i get an error when i try to do a simple regression analysis using sklearn
- logistic regression analysis in python
- python - regression analysis with statsmodels cannot resolve the error that it contains infinity or nan
- python 3x - i can't convert the date ("2018/12/31") string in series to datetime with python
- python - about data analysis in pandas
- python fourier series the expanded formula is output to the graph
- python multiple regression analysis statsmodelsformula
- analysis from python stock price data, maximum and minimum
- python - i want to do morphological analysis and create a word list (preprocessing for co-occurrence network creation) (janome)
- python - i want to make time series predictions using keras
- python 3x - python37 time series extracts second data every minute → i want to calculate the effective value
Trends
a1 [0] = Exclude NaN