16.1 相关概念
时间序列数据存在的意义即是通过过去预测未, 以下数据都属于时间序列数据:
(1)遥感数据;
(2)气象数据;
(3)金融数据(股票,期货,外汇)
(4)经济数据(GDP)
时间序列模型即为趋势模型(Trend Model)主要包括以下两类:
(1)线性模型(Linear Trend Model)
(2)Log-Linear Trend Model
那么能否在建模过程中直接带入时间数据呢?显然是不能的。
16.2 案列分析
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
import tushare as ts
if __name__ == '__main__':
token = "e2aad62befd01005a6bce9947c12055478bd1906cd48f850f7c5d5a0"
pro = ts.pro_api(token)
df = pro.daily(ts_code="002758.SZ", start_date="20220401", end_date="20220501")
# 将日期设置为dataframe的行索引
df.index=pd.to_datetime(df.trade_date)
# 获取每日的收盘价
our_df = df.close
(1)AF(Autocovariace Function)时间序列与其滞后项的协方差:假设X为随机变量,E为数学期望,u为均值,即有: