# 从数据自动判断时间序列过程模型和阶数

TimeSeriesModelFit 可完全的自动识别最佳描述给定时间序列的时间序列模型.

 In[1]:= Xev = EntityValue[Entity["Country", "UnitedStates"], EntityProperty["Country", "RetailSales", {"Adjustment" -> "Nominal", "Date" -> All, "Frequency" -> "Monthly", "SeasonalAdjustment" -> "NotSeasonallyAdjusted"}]]
 Out[1]=

 In[2]:= Xts = TimeSeriesResample[ev, "Month"];
 In[3]:= Xev["Dates"] === ts["Dates"]
 Out[3]=
 In[4]:= XDateListPlot[ts, PlotTheme -> "Detailed", AspectRatio -> 1/3, ImageSize -> Medium]
 Out[4]=

 In[5]:= Xtmf = TimeSeriesModelFit[ts]
 Out[5]=

 In[6]:= Xforecast = TimeSeriesForecast[tmf, {7 12}]
 Out[6]=

 In[7]:= X\[Alpha] = .95; q = Quantile[NormalDistribution[], (1 + \[Alpha])/2]; err = TimeSeriesMap[Sqrt, forecast["MeanSquaredErrors"]]; bands = TimeSeriesThread[{{1, -q}.#, {1, q}.#} &, {forecast, err}]
 Out[7]=
 In[8]:= XDateListPlot[{ts, forecast, bands["PathComponent", 1], bands["PathComponent", 2]}, PlotTheme -> {"Detailed", "VibrantColors"}, AspectRatio -> 1/3, ImageSize -> Medium, Filling -> {3 -> {4}}, PlotStyle -> {Automatic, Automatic, Directive[Gray, Thickness[Tiny]], Directive[Gray, Thickness[Tiny]]}]
 Out[8]=

## Mathematica

Questions? Comments? Contact a Wolfram expert »