在 Python 中实现时间序列分解通常涉及使用库和函数来分析趋势、季节性和残差等组成部分。我们已经讨论了时间序列分解的原理以及加法模型和乘法模型之间的区别。现在,让我们在 Python 中实际操作。statsmodels 库提供了统计分析工具,包括时间序列分解功能。我们将使用的主要函数是 statsmodels.tsa.seasonal.seasonal_decompose。这个函数实现了经典的分解方法,通常基于移动平均线,将时间序列分为趋势、季节和残差成分。使用 seasonal_decomposeseasonal_decompose 函数需要时间序列本身,以及关于模型类型和季节周期的信息。import pandas as pd from statsmodels.tsa.seasonal import seasonal_decompose import matplotlib.pyplot as plt # 使用 matplotlib 进行基本绘图示例 # 假设 'series' 是一个带有 DatetimeIndex 的 pandas Series。 # 它应包含你想要分解的时间序列值。 # 示例: # series = pd.read_csv('your_data.csv', # index_col='Date', # parse_dates=True)['Value'] # --- 执行分解 --- # model: 指定 'additive' (加法) 或 'multiplicative' (乘法)。 # period: 每个季节周期内的观测数量 # (例如,月度数据具有年度季节性时为 12, # 日度数据具有每周季节性时为 7)。 # 针对月度数据(周期=12)的加法模型示例 decomposition_result = seasonal_decompose(series, model='additive', period=12) # 该函数返回一个 DecomposeResult 对象。你可以通过 # 属性访问各个成分: trend_component = decomposition_result.trend seasonal_component = decomposition_result.seasonal residual_component = decomposition_result.resid observed_data = decomposition_result.observed # 原始数据 # --- 可视化成分 --- # 一种常见的可视化方式是堆叠图表: fig, axes = plt.subplots(4, 1, figsize=(10, 8), sharex=True) observed_data.plot(ax=axes[0], legend=False, color='#1c7ed6') axes[0].set_ylabel('观测值') trend_component.plot(ax=axes[1], legend=False, color='#f76707') axes[1].set_ylabel('趋势') seasonal_component.plot(ax=axes[2], legend=False, color='#37b24d') axes[2].set_ylabel('季节') residual_component.plot(ax=axes[3], legend=False, color='#adb5bd') axes[3].set_ylabel('残差') plt.xlabel('日期') plt.suptitle('时间序列分解', y=0.92) # 在图表上方稍加标题 plt.tight_layout(rect=[0, 0, 1, 0.9]) # 调整布局以避免标题重叠 plt.show() 选择模型类型:当季节性波动随时间推移显得相对稳定,无论序列的数值水平如何时,设置 model='additive'。季节模式中峰值和谷值的幅度大致保持相同。这对应于 $y_t = T_t + S_t + R_t$ 模型。当季节性波动似乎与序列的水平成比例变化时,设置 model='multiplicative'。随着趋势的增加,季节模式的振幅也随之增大。这符合 $y_t = T_t \times S_t \times R_t$ 模型。如果你怀疑存在乘法效应,有时分析序列的对数可以使模式变为加法形式 ($log(y_t) \approx log(T_t) + log(S_t) + log(R_t)$),这可以简化建模过程。指定 period:这个参数对于正确识别季节模式很重要。它表示一个完整季节周期中的时间步长数量。常见值包括:月度数据具有年度周期时,period=12。季度数据具有年度周期时,period=4。日度数据具有每周周期时,period=7。周度数据具有年度周期时,period=52 (近似值)。根据数据已知频率选择正确的 period 对于进行有意义的分解是必需的。示例:航空旅客数据分解让我们将此应用于经典的“AirPassengers”数据集,该数据集以其强劲的上升趋势和递增的年度季节性著称。这种递增的季节性表明乘法模型可能更合适。我们将进行两种分解以作比较。(假设 air_passengers 是一个包含月度旅客数量并按日期索引的 pandas Series。)# 假设 'air_passengers' Series 已加载并准备好 DatetimeIndex # 演示用合成数据生成示例: date_rng = pd.date_range(start='1949-01-01', end='1960-12-01', freq='MS') passengers = ( 110 + # 基础水平略高 (date_rng.year - 1949) * 22 + # 趋势略陡 (1 + (date_rng.year - 1949) * 0.12) * ( # 季节性增长略强 35 * (date_rng.month == 7) + 25 * (date_rng.month == 8) + -25 * (date_rng.month == 11) + -20 * (date_rng.month == 2) ) + pd.Series(np.random.normal(0, 12, size=len(date_rng)), index=date_rng) # 噪声略大 ).astype(int) air_passengers = pd.Series(passengers, index=date_rng) # 执行乘法分解(月度年度周期为 12) result_mul = seasonal_decompose(air_passengers, model='multiplicative', period=12) # 执行加法分解以作比较 result_add = seasonal_decompose(air_passengers, model='additive', period=12) # -- 使用 Plotly 绘图以获得更好的网页显示效果 -- import plotly.graph_objects as go from plotly.subplots import make_subplots import numpy as np # 用于 np.nan 比较 fig = make_subplots( rows=4, cols=2, shared_xaxes=True, subplot_titles=('乘法模型:观测值', '加法模型:观测值', '乘法模型:趋势', '加法模型:趋势', '乘法模型:季节', '加法模型:季节', '乘法模型:残差', '加法模型:残差'), vertical_spacing=0.06 # 间距略大 ) # 添加迹线的函数,处理趋势/残差末端的潜在 NaN 值 def add_trace_safe(fig, data, name, color, row, col, showlegend=True): # 只绘制非 NaN 数据点 valid_index = data.dropna().index valid_data = data.dropna().values fig.add_trace(go.Scatter(x=valid_index, y=valid_data, mode='lines', name=name, line=dict(color=color), showlegend=showlegend), row=row, col=col) # 按列添加迹线 add_trace_safe(fig, result_mul.observed, '观测值', '#1c7ed6', 1, 1) add_trace_safe(fig, result_mul.trend, '趋势', '#f76707', 2, 1) add_trace_safe(fig, result_mul.seasonal, '季节', '#37b24d', 3, 1) add_trace_safe(fig, result_mul.resid, '残差', '#adb5bd', 4, 1) add_trace_safe(fig, result_add.observed, '观测值', '#1c7ed6', 1, 2, showlegend=False) add_trace_safe(fig, result_add.trend, '趋势', '#f76707', 2, 2, showlegend=False) add_trace_safe(fig, result_add.seasonal, '季节', '#37b24d', 3, 2, showlegend=False) add_trace_safe(fig, result_add.resid, '残差', '#adb5bd', 4, 2, showlegend=False) fig.update_layout( height=750, # 略高 title_text='时间序列分解:乘法模型与加法模型对比 (航空旅客)', margin=dict(l=60, r=30, t=90, b=60), hovermode='x unified', legend_title_text='成分', plot_bgcolor='#e9ecef', # 浅灰色背景 paper_bgcolor='#ffffff' # 白色纸张背景 ) fig.update_xaxes(title_text="日期", row=4, col=1, showgrid=False) fig.update_xaxes(title_text="日期", row=4, col=2, showgrid=False) fig.update_yaxes(showgrid=True, gridwidth=1, gridcolor='#dee2e6') # 浅色网格线 # 生成用于嵌入的 JSON 输出: # print(fig.to_json()){"layout": {"height": 750, "title": {"text": "时间序列分解:乘法模型与加法模型对比 (航空旅客)"}, "margin": {"l": 60, "r": 30, "t": 90, "b": 60}, "hovermode": "x unified", "legend": {"title": {"text": "成分"}}, "plot_bgcolor": "#e9ecef", "paper_bgcolor": "#ffffff", "xaxis": {"anchor": "y1", "domain": [0.0, 0.475], "title": {"text": "日期"}, "showgrid": false}, "xaxis2": {"anchor": "y2", "domain": [0.525, 1.0], "title": {"text": "日期"}, "showgrid": false}, "yaxis": {"anchor": "x1", "domain": [0.78, 1.0], "showgrid": true, "gridwidth": 1, "gridcolor": "#dee2e6"}, "yaxis2": {"anchor": "x2", "domain": [0.78, 1.0], "showgrid": true, "gridwidth": 1, "gridcolor": "#dee2e6"}, "yaxis3": {"anchor": "x1", "domain": [0.5166666666666666, 0.73], "showgrid": true, "gridwidth": 1, "gridcolor": "#dee2e6"}, "yaxis4": {"anchor": "x2", "domain": [0.5166666666666666, 0.73], "showgrid": true, "gridwidth": 1, "gridcolor": "#dee2e6"}, "yaxis5": {"anchor": "x1", "domain": [0.2533333333333333, 0.4666666666666666], "showgrid": true, "gridwidth": 1, "gridcolor": "#dee2e6"}, "yaxis6": {"anchor": "x2", "domain": [0.2533333333333333, 0.4666666666666666], "showgrid": true, "gridwidth": 1, "gridcolor": "#dee2e6"}, "yaxis7": {"anchor": "x1", "domain": [0.0, 0.21333333333333335], "showgrid": true, "gridwidth": 1, "gridcolor": "#dee2e6"}, "yaxis8": {"anchor": "x2", "domain": [0.0, 0.21333333333333335], "showgrid": true, "gridwidth": 1, "gridcolor": "#dee2e6"}, "annotations": [{"showarrow": false, "text": "乘法模型:观测值", "x": 0.2375, "xanchor": "center", "xref": "paper", "y": 0.995, "yanchor": "bottom", "yref": "paper"}, {"showarrow": false, "text": "加法模型:观测值", "x": 0.7625, "xanchor": "center", "xref": "paper", "y": 0.995, "yanchor": "bottom", "yref": "paper"}, {"showarrow": false, "text": "乘法模型:趋势", "x": 0.2375, "xanchor": "center", "xref": "paper", "y": 0.725, "yanchor": "bottom", "yref": "paper"}, {"showarrow": false, "text": "加法模型:趋势", "x": 0.7625, "xanchor": "center", "xref": "paper", "y": 0.725, "yanchor": "bottom", "yref": "paper"}, {"showarrow": false, "text": "乘法模型:季节", "x": 0.2375, "xanchor": "center", "xref": "paper", "y": 0.46166666666666667, "yanchor": "bottom", "yref": "paper"}, {"showarrow": false, "text": "加法模型:季节", "x": 0.7625, "xanchor": "center", "xref": "paper", "y": 0.46166666666666667, "yanchor": "bottom", "yref": "paper"}, {"showarrow": false, "text": "乘法模型:残差", "x": 0.2375, "xanchor": "center", "xref": "paper", "y": 0.20833333333333334, "yanchor": "bottom", "yref": "paper"}, {"showarrow": false, "text": "加法模型:残差", "x": 0.7625, "xanchor": "center", "xref": "paper", "y": 0.20833333333333334, "yanchor": "bottom", "yref": "paper"}], "grid": {"rows": 4, "columns": 2, "pattern": "independent"}}, "data": [{"type": "scatter", "x": ["1949-01-01", "1949-02-01", "1949-03-01", "1949-04-01", "1949-05-01", "1949-06-01", "1949-07-01", "1949-08-01", "1949-09-01", "1949-10-01", "1949-11-01", "1949-12-01", "1950-01-01", "1950-02-01", "1950-03-01", "1950-04-01", "1950-05-01", "1950-06-01", "1950-07-01", "1950-08-01", "1950-09-01", "1950-10-01", "1950-11-01", "1950-12-01", "1951-01-01", "1951-02-01", "1951-03-01", "1951-04-01", "1951-05-01", "1951-06-01", "1951-07-01", "1951-08-01", "1951-09-01", "1951-10-01", "1951-11-01", "1951-12-01", "1952-01-01", "1952-02-01", "1952-03-01", "1952-04-01", "1952-05-01", "1952-06-01", "1952-07-01", "1952-08-01", "1952-09-01", "1952-10-01", "1952-11-01", "1952-12-01", "1953-01-01", "1953-02-01", "1953-03-01", "1953-04-01", "1953-05-01", "1953-06-01", "1953-07-01", "1953-08-01", "1953-09-01", "1953-10-01", "1953-11-01", "1953-12-01", "1954-01-01", "1954-02-01", "1954-03-01", "1954-04-01", "1954-05-01", "1954-06-01", "1954-07-01", "1954-08-01", "1954-09-01", "1954-10-01", "1954-11-01", "1954-12-01", "1955-01-01", "1955-02-01", "1955-03-01", "1955-04-01", "1955-05-01", "1955-06-01", "1955-07-01", "1955-08-01", "1955-09-01", "1955-10-01", "1955-11-01", "1955-12-01", "1956-01-01", "1956-02-01", "1956-03-01", "1956-04-01", "1956-05-01", "1956-06-01", "1956-07-01", "1956-08-01", "1956-09-01", "1956-10-01", "1956-11-01", "1956-12-01", "1957-01-01", "1957-02-01", "1957-03-01", "1957-04-01", "1957-05-01", "1957-06-01", "1957-07-01", "1957-08-01", "1957-09-01", "1957-10-01", "1957-11-01", "1957-12-01", "1958-01-01", "1958-02-01", "1958-03-01", "1958-04-01", "1958-05-01", "1958-06-01", "1958-07-01", "1958-08-01", "1958-09-01", "1958-10-01", "1958-11-01", "1958-12-01", "1959-01-01", "1959-02-01", "1959-03-01", "1959-04-01", "1959-05-01", "1959-06-01", "1959-07-01", "1959-08-01", "1959-09-01", "1959-10-01", "1959-11-01", "1959-12-01", "1960-01-01", "1960-02-01", "1960-03-01", "1960-04-01", "1960-05-01", "1960-06-01", "1960-07-01", "1960-08-01", "1960-09-01", "1960-10-01", "1960-11-01", "1960-12-01"], "y": [106, 83, 120, 116, 112, 125, 147, 161, 135, 115, 79, 118, 142, 118, 141, 139, 133, 157, 193, 190, 162, 145, 111, 144, 159, 142, 165, 173, 175, 187, 235, 228, 182, 163, 129, 162, 195, 167, 206, 206, 198, 229, 266, 269, 214, 191, 151, 187, 221, 201, 234, 232, 225, 256, 315, 302, 251, 224, 185, 232, 241, 222, 251, 254, 248, 284, 331, 337, 279, 250, 206, 258, 288, 258, 284, 291, 296, 323, 387, 377, 315, 286, 244, 288, 318, 301, 319, 342, 338, 368, 432, 432, 363, 327, 270, 326, 346, 311, 362, 375, 370, 405, 485, 495, 403, 359, 305, 360, 371, 349, 390, 414, 419, 464, 550, 555, 467, 403, 335, 405, 413, 390, 422, 429, 451, 499, 591, 605, 501, 462, 369, 438], "mode": "lines", "name": "观测值", "line": {"color": "#1c7ed6"}, "xaxis": "x", "yaxis": "y"}, {"type": "scatter", "x": ["1949-07-01", "1949-08-01", "1949-09-01", "1949-10-01", "1949-11-01", "1949-12-01", "1950-01-01", "1950-02-01", "1950-03-01", "1950-04-01", "1950-05-01", "1950-06-01", "1950-07-01", "1950-08-01", "1950-09-01", "1950-10-01", "1950-11-01", "1950-12-01", "1951-01-01", "1951-02-01", "1951-03-01", "1951-04-01", "1951-05-01", "1951-06-01", "1951-07-01", "1951-08-01", "1951-09-01", "1951-10-01", "1951-11-01", "1951-12-01", "1952-01-01", "1952-02-01", "1952-03-01", "1952-04-01", "1952-05-01", "1952-06-01", "1952-07-01", "1952-08-01", "1952-09-01", "1952-10-01", "1952-11-01", "1952-12-01", "1953-01-01", "1953-02-01", "1953-03-01", "1953-04-01", "1953-05-01", "1953-06-01", "1953-07-01", "1953-08-01", "1953-09-01", "1953-10-01", "1953-11-01", "1953-12-01", "1954-01-01", "1954-02-01", "1954-03-01", "1954-04-01", "1954-05-01", "1954-06-01", "1954-07-01", "1954-08-01", "1954-09-01", "1954-10-01", "1954-11-01", "1954-12-01", "1955-01-01", "1955-02-01", "1955-03-01", "1955-04-01", "1955-05-01", "1955-06-01", "1955-07-01", "1955-08-01", "1955-09-01", "1955-10-01", "1955-11-01", "1955-12-01", "1956-01-01", "1956-02-01", "1956-03-01", "1956-04-01", "1956-05-01", "1956-06-01", "1956-07-01", "1956-08-01", "1956-09-01", "1956-10-01", "1956-11-01", "1956-12-01", "1957-01-01", "1957-02-01", "1957-03-01", "1957-04-01", "1957-05-01", "1957-06-01", "1957-07-01", "1957-08-01", "1957-09-01", "1957-10-01", "1957-11-01", "1957-12-01", "1958-01-01", "1958-02-01", "1958-03-01", "1958-04-01", "1958-05-01", "1958-06-01", "1958-07-01", "1958-08-01", "1958-09-01", "1958-10-01", "1958-11-01", "1958-12-01", "1959-01-01", "1959-02-01", "1959-03-01", "1959-04-01", "1959-05-01", "1959-06-01", "1959-07-01"], "y": [115.0, 116.375, 118.66666666666667, 121.04166666666667, 123.79166666666667, 126.70833333333333, 130.0, 133.66666666666666, 137.41666666666666, 141.79166666666666, 146.375, 151.20833333333334, 156.125, 160.75, 165.04166666666666, 168.91666666666666, 172.875, 176.625, 180.58333333333334, 184.625, 188.70833333333334, 192.95833333333334, 197.41666666666666, 201.95833333333334, 206.5, 211.0, 215.5, 220.0, 224.5, 228.875, 233.08333333333334, 237.375, 241.70833333333334, 246.125, 250.66666666666666, 255.125, 259.5416666666667, 264.0, 268.625, 273.5416666666667, 278.6666666666667, 283.4583333333333, 288.1666666666667, 292.875, 297.7083333333333, 302.6666666666667, 307.625, 312.5, 317.25, 322.0, 326.8333333333333, 331.75, 336.625, 341.375, 346.0, 350.5416666666667, 355.0, 359.4166666666667, 363.7083333333333, 367.9583333333333, 372.0833333333333, 376.2083333333333, 380.4166666666667, 384.8333333333333, 389.5, 394.4166666666667, 399.5, 404.5833333333333, 409.5416666666667, 414.25, 418.75, 423.0833333333333, 427.4166666666667, 431.9166666666667, 436.5833333333333, 441.4166666666667, 446.25, 451.0, 455.625, 460.0833333333333, 464.4166666666667, 468.6666666666667, 472.8333333333333, 477.0, 481.25, 485.5833333333333, 490.0, 494.5, 499.0833333333333, 503.75, 508.4166666666667, 513.0, 517.5, 521.875, 526.1666666666667, 530.4166666666667, 534.75, 539.125, 543.5416666666667, 548.0], "mode": "lines", "name": "趋势", "line": {"color": "#f76707"}, "xaxis": "x", "yaxis": "y3"}, {"type": "scatter", "x": ["1949-01-01", "1949-02-01", "1949-03-01", "1949-04-01", "1949-05-01", "1949-06-01", "1949-07-01", "1949-08-01", "1949-09-01", "1949-10-01", "1949-11-01", "1949-12-01", "1950-01-01", "1950-02-01", "1950-03-01", "1950-04-01", "1950-05-01", "1950-06-01", "1950-07-01", "1950-08-01", "1950-09-01", "1950-10-01", "1950-11-01", "1950-12-01", "1951-01-01", "1951-02-01", "1951-03-01", "1951-04-01", "1951-05-01", "1951-06-01", "1951-07-01", "1951-08-01", "1951-09-01", "1951-10-01", "1951-11-01", "1951-12-01", "1952-01-01", "1952-02-01", "1952-03-01", "1952-04-01", "1952-05-01", "1952-06-01", "1952-07-01", "1952-08-01", "1952-09-01", "1952-10-01", "1952-11-01", "1952-12-01", "1953-01-01", "1953-02-01", "1953-03-01", "1953-04-01", "1953-05-01", "1953-06-01", "1953-07-01", "1953-08-01", "1953-09-01", "1953-10-01", "1953-11-01", "1953-12-01", "1954-01-01", "1954-02-01", "1954-03-01", "1954-04-01", "1954-05-01", "1954-06-01", "1954-07-01", "1954-08-01", "1954-09-01", "1954-10-01", "1954-11-01", "1954-12-01", "1955-01-01", "1955-02-01", "1955-03-01", "1955-04-01", "1955-05-01", "1955-06-01", "1955-07-01", "1955-08-01", "1955-09-01", "1955-10-01", "1955-11-01", "1955-12-01", "1956-01-01", "1956-02-01", "1956-03-01", "1956-04-01", "1956-05-01", "1956-06-01", "1956-07-01", "1956-08-01", "1956-09-01", "1956-10-01", "1956-11-01", "1956-12-01", "1957-01-01", "1957-02-01", "1957-03-01", "1957-04-01", "1957-05-01", "1957-06-01", "1957-07-01", "1957-08-01", "1957-09-01", "1957-10-01", "1957-11-01", "1957-12-01", "1958-01-01", "1958-02-01", "1958-03-01", "1958-04-01", "1958-05-01", "1958-06-01", "1958-07-01", "1958-08-01", "1958-09-01", "1958-10-01", "1958-11-01", "1958-12-01", "1959-01-01", "1959-02-01", "1959-03-01", "1959-04-01", "1959-05-01", "1959-06-01", "1959-07-01", "1959-08-01", "1959-09-01", "1959-10-01", "1959-11-01", "1959-12-01", "1960-01-01", "1960-02-01", "1960-03-01", "1960-04-01", "1960-05-01", "1960-06-01", "1960-07-01", "1960-08-01", "1960-09-01", "1960-10-01", "1960-11-01", "1960-12-01"], "y": [0.9172888853299017, 0.882896378986152, 0.9887569097199853, 0.9619997117360669, 0.962063133707788, 1.0810349934524766, 1.1917883233607435, 1.180737540179151, 1.0596684343532043, 0.9169239937251102, 0.7993018784573601, 0.9172888853299017, 0.9172888853299017, 0.882896378986152, 0.9887569097199853, 0.9619997117360669, 0.962063133707788, 1.0810349934524766, 1.1917883233607435, 1.180737540179151, 1.0596684343532043, 0.9169239937251102, 0.7993018784573601, 0.9172888853299017, 0.9172888853299017, 0.882896378986152, 0.9887569097199853, 0.9619997117360669, 0.962063133707788, 1.0810349934524766, 1.1917883233607435, 1.180737540179151, 1.0596684343532043, 0.9169239937251102, 0.7993018784573601, 0.9172888853299017, 0.9172888853299017, 0.882896378986152, 0.9887569097199853, 0.9619997117360669, 0.962063133707788, 1.0810349934524766, 1.1917883233607435, 1.180737540179151, 1.0596684343532043, 0.9169239937251102, 0.7993018784573601, 0.9172888853299017, 0.9172888853299017, 0.882896378986152, 0.9887569097199853, 0.9619997117360669, 0.962063133707788, 1.0810349934524766, 1.1917883233607435, 1.180737540179151, 1.0596684343532043, 0.9169239937251102, 0.7993018784573601, 0.9172888853299017, 0.9172888853299017, 0.882896378986152, 0.9887569097199853, 0.9619997117360669, 0.962063133707788, 1.0810349934524766, 1.1917883233607435, 1.180737540179151, 1.0596684343532043, 0.9169239937251102, 0.7993018784573601, 0.9172888853299017, 0.9172888853299017, 0.882896378986152, 0.9887569097199853, 0.9619997117360669, 0.962063133707788, 1.0810349934524766, 1.1917883233607435, 1.180737540179151, 1.0596684343532043, 0.9169239937251102, 0.7993018784573601, 0.9172888853299017, 0.9172888853299017, 0.882896378986152, 0.9887569097199853, 0.9619997117360669, 0.962063133707788, 1.0810349934524766, 1.1917883233607435, 1.180737540179151, 1.0596684343532043, 0.9169239937251102, 0.7993018784573601, 0.9172888853299017, 0.9172888853299017, 0.882896378986152, 0.9887569097199853, 0.9619997117360669, 0.962063133707788, 1.0810349934524766, 1.1917883233607435, 1.180737540179151, 1.0596684343532043, 0.9169239937251102, 0.7993018784573601, 0.9172888853299017, 0.9172888853299017, 0.882896378986152, 0.9887569097199853, 0.9619997117360669, 0.962063133707788, 1.0810349934524766, 1.1917883233607435, 1.180737540179151, 1.0596684343532043, 0.9169239937251102, 0.7993018784573601, 0.9172888853299017, 0.9172888853299017, 0.882896378986152, 0.9887569097199853, 0.9619997117360669, 0.962063133707788, 1.0810349934524766, 1.1917883233607435, 1.180737540179151, 1.0596684343532043, 0.9169239937251102, 0.7993018784573601, 0.9172888853299017, 0.9172888853299017, 0.882896378986152, 0.9887569097199853, 0.9619997117360669, 0.962063133707788, 1.0810349934524766, 1.1917883233607435, 1.180737540179151, 1.0596684343532043, 0.9169239937251102, 0.7993018784573601, 0.9172888853299017], "mode": "lines", "name": "季节", "line": {"color": "#37b24d"}, "xaxis": "x", "yaxis": "y5"}, {"type": "scatter", "x": ["1949-07-01", "1949-08-01", "1949-09-01", "1949-10-01", "1949-11-01", "1949-12-01", "1950-01-01", "1950-02-01", "1950-03-01", "1950-04-01", "1950-05-01", "1950-06-01", "1950-07-01", "1950-08-01", "1950-09-01", "1950-10-01", "1950-11-01", "1950-12-01", "1951-01-01", "1951-02-01", "1951-03-01", "1951-04-01", "1951-05-01", "1951-06-01", "1951-07-01", "1951-08-01", "1951-09-01", "1951-10-01", "1951-11-01", "1951-12-01", "1952-01-01", "1952-02-01", "1952-03-01", "1952-04-01", "1952-05-01", "1952-06-01", "1952-07-01", "1952-08-01", "1952-09-01", "1952-10-01", "1952-11-01", "1952-12-01", "1953-01-01", "1953-02-01", "1953-03-01", "1953-04-01", "1953-05-01", "1953-06-01", "1953-07-01", "1953-08-01", "1953-09-01", "1953-10-01", "1953-11-01", "1953-12-01", "1954-01-01", "1954-02-01", "1954-03-01", "1954-04-01", "1954-05-01", "1954-06-01", "1954-07-01", "1954-08-01", "1954-09-01", "1954-10-01", "1954-11-01", "1954-12-01", "1955-01-01", "1955-02-01", "1955-03-01", "1955-04-01", "1955-05-01", "1955-06-01", "1955-07-01", "1955-08-01", "1955-09-01", "1955-10-01", "1955-11-01", "1955-12-01", "1956-01-01", "1956-02-01", "1956-03-01", "1956-04-01", "1956-05-01", "1956-06-01", "1956-07-01", "1956-08-01", "1956-09-01", "1956-10-01", "1956-11-01", "1956-12-01", "1957-01-01", "1957-02-01", "1957-03-01", "1957-04-01", "1957-05-01", "1957-06-01", "1957-07-01", "1957-08-01", "1957-09-01", "1957-10-01", "1957-11-01", "1957-12-01", "1958-01-01", "1958-02-01", "1958-03-01", "1958-04-01", "1958-05-01", "1958-06-01", "1958-07-01", "1958-08-01", "1958-09-01", "1958-10-01", "1958-11-01", "1958-12-01", "1959-01-01", "1959-02-01", "1959-03-01", "1959-04-01", "1959-05-01", "1959-06-01", "1959-07-01"], "y": [1.0503071666088192, 1.0824040799882898, 0.9983789731379213, 0.9648268371152426, 0.909009033552025, 0.980277041674745, 1.0127575168771234, 0.9589623190338933, 0.9919246024074968, 0.9999535191897336, 0.9450322228016017, 0.999740473923701, 1.0375341058502763, 1.0027005408214825, 0.9590152014324622, 0.902883443844957, 0.8725918926488618, 0.926232928997871, 0.9608169690100709, 0.9005206058995595, 0.9207426734863078, 0.9536098729960398, 0.9486175540122428, 0.9636770925251104, 1.0032911298490898, 0.987083302932291, 0.9032100616111112, 0.8824145077571079, 0.8441605671057713, 0.8834678377304556, 0.9417550729350778, 0.8477081006296918, 0.9611264761804463, 0.939039092423008, 0.9189766484149742, 0.9812228526017563, 1.005815558083438, 1.0130518711746665, 0.8857880753848328, 0.8815511230764604, 0.8500114200733138, 0.8937345043971222, 0.9703031768600848, 0.8888956058995595, 1.0010217474285187, 0.9834648155364774, 0.9511689315448274, 1.0245782449330912, 1.0687473086713055, 1.0414443885002528, 0.9528941184005957, 0.9222908231861218, 0.8772246446555895, 0.9491826047101327, 0.9798512798991142, 0.9130931006296918, 1.017534547288234, 1.016920712979091, 0.991913290847944, 1.0307626483985933, 1.0621023572900155, 1.0835240515131535, 0.9768131155274274, 0.9382957517442987, 0.8674334664069393, 0.9538848883638107, 0.9990263530901554, 0.885483094263025, 1.0072856201839845, 1.0001279622671713, 0.9915071116359088, 1.025712745465068, 1.0822289835116908, 1.069428088496052, 0.9748370063342253, 0.9348404356046051, 0.8845249112587998, 0.9510371719768003, 0.9891712059519593, 0.9031905950000238, 0.9969218966091875, 1.019156634619818, 0.9978643364979172, 1.0224658438184794, 1.079849236004683, 1.0914641598218318, 0.9762970740799751, 0.9554748491957947, 0.8770966178754664, 0.953643221697144, 0.9987150588137633, 0.8806780887300598, 1.006965555033776, 1.0200097290210713, 0.996698096422889, 1.028670942751603, 1.0899900142313663, 1.1089120876342048, 1.0036742801060415, 0.9696790825700776, 0.8931027650136624, 0.9742720697148928, 0.9818628832157673, 0.9124880824599275, 1.008735969759017, 1.0250163070494502, 1.0224929487017075, 1.058507818033043, 1.1137320198829807], "mode": "lines", "name": "残差", "line": {"color": "#adb5bd"}, "xaxis": "x", "yaxis": "y7"}, {"type": "scatter", "x": ["1949-01-01", "1949-02-01", "1949-03-01", "1949-04-01", "1949-05-01", "1949-06-01", "1949-07-01", "1949-08-01", "1949-09-01", "1949-10-01", "1949-11-01", "1949-12-01", "1950-01-01", "1950-02-01", "1950-03-01", "1950-04-01", "1950-05-01", "1950-06-01", "1950-07-01", "1950-08-01", "1950-09-01", "1950-10-01", "1950-11-01", "1950-12-01", "1951-01-01", "1951-02-01", "1951-03-01", "1951-04-01", "1951-05-01", "1951-06-01", "1951-07-01", "1951-08-01", "1951-09-01", "1951-10-01", "1951-11-01", "1951-12-01", "1952-01-01", "1952-02-01", "1952-03-01", "1952-04-01", "1952-05-01", "1952-06-01", "1952-07-01", "1952-08-01", "1952-09-01", "1952-10-01", "1952-11-01", "1952-12-01", "1953-01-01", "1953-02-01", "1953-03-01", "1953-04-01", "1953-05-01", "1953-06-01", "1953-07-01", "1953-08-01", "1953-09-01", "1953-10-01", "1953-11-01", "1953-12-01", "1954-01-01", "1954-02-01", "1954-03-01", "1954-04-01", "1954-05-01", "1954-06-01", "1954-07-01", "1954-08-01", "1954-09-01", "1954-10-01", "1954-11-01", "1954-12-01", "1955-01-01", "1955-02-01", "1955-03-01", "1955-04-01", "1955-05-01", "1955-06-01", "1955-07-01", "1955-08-01", "1955-09-01", "1955-10-01", "1955-11-01", "1955-12-01", "1956-01-01", "1956-02-01", "1956-03-01", "1956-04-01", "1956-05-01", "1956-06-01", "1956-07-01", "1956-08-01", "1956-09-01", "1956-10-01", "1956-11-01", "1956-12-01", "1957-01-01", "1957-02-01", "1957-03-01", "1957-04-01", "1957-05-01", "1957-06-01", "1957-07-01", "1957-08-01", "1957-09-01", "1957-10-01", "1957-11-01", "1957-12-01", "1958-01-01", "1958-02-01", "1958-03-01", "1958-04-01", "1958-05-01", "1958-06-01", "1958-07-01", "1958-08-01", "1958-09-01", "1958-10-01", "1958-11-01", "1958-12-01", "1959-01-01", "1959-02-01", "1959-03-01", "1959-04-01", "1959-05-01", "1959-06-01", "1959-07-01", "1959-08-01", "1959-09-01", "1959-10-01", "1959-11-01", "1959-12-01", "1960-01-01", "1960-02-01", "1960-03-01", "1960-04-01", "1960-05-01", "1960-06-01", "1960-07-01", "1960-08-01", "1960-09-01", "1960-10-01", "1960-11-01", "1960-12-01"], "y": [106, 83, 120, 116, 112, 125, 147, 161, 135, 115, 79, 118, 142, 118, 141, 139, 133, 157, 193, 190, 162, 145, 111, 144, 159, 142, 165, 173, 175, 187, 235, 228, 182, 163, 129, 162, 195, 167, 206, 206, 198, 229, 266, 269, 214, 191, 151, 187, 221, 201, 234, 232, 225, 256, 315, 302, 251, 224, 185, 232, 241, 222, 251, 254, 248, 284, 331, 337, 279, 250, 206, 258, 288, 258, 284, 291, 296, 323, 387, 377, 315, 286, 244, 288, 318, 301, 319, 342, 338, 368, 432, 432, 363, 327, 270, 326, 346, 311, 362, 375, 370, 405, 485, 495, 403, 359, 305, 360, 371, 349, 390, 414, 419, 464, 550, 555, 467, 403, 335, 405, 413, 390, 422, 429, 451, 499, 591, 605, 501, 462, 369, 438], "mode": "lines", "name": "观测值", "line": {"color": "#1c7ed6"}, "showlegend": false, "xaxis": "x2", "yaxis": "y2"}, {"type": "scatter", "x": ["1949-07-01", "1949-08-01", "1949-09-01", "1949-10-01", "1949-11-01", "1949-12-01", "1950-01-01", "1950-02-01", "1950-03-01", "1950-04-01", "1950-05-01", "1950-06-01", "1950-07-01", "1950-08-01", "1950-09-01", "1950-10-01", "1950-11-01", "1950-12-01", "1951-01-01", "1951-02-01", "1951-03-01", "1951-04-01", "1951-05-01", "1951-06-01", "1951-07-01", "1951-08-01", "1951-09-01", "1951-10-01", "1951-11-01", "1951-12-01", "1952-01-01", "1952-02-01", "1952-03-01", "1952-04-01", "1952-05-01", "1952-06-01", "1952-07-01", "1952-08-01", "1952-09-01", "1952-10-01", "1952-11-01", "1952-12-01", "1953-01-01", "1953-02-01", "1953-03-01", "1953-04-01", "1953-05-01", "1953-06-01", "1953-07-01", "1953-08-01", "1953-09-01", "1953-10-01", "1953-11-01", "1953-12-01", "1954-01-01", "1954-02-01", "1954-03-01", "1954-04-01", "1954-05-01", "1954-06-01", "1954-07-01", "1954-08-01", "1954-09-01", "1954-10-01", "1954-11-01", "1954-12-01", "1955-01-01", "1955-02-01", "1955-03-01", "1955-04-01", "1955-05-01", "1955-06-01", "1955-07-01", "1955-08-01", "1955-09-01", "1955-10-01", "1955-11-01", "1955-12-01", "1956-01-01", "1956-02-01", "1956-03-01", "1956-04-01", "1956-05-01", "1956-06-01", "1956-07-01", "1956-08-01", "1956-09-01", "1956-10-01", "1956-11-01", "1956-12-01", "1957-01-01", "1957-02-01", "1957-03-01", "1957-04-01", "1957-05-01", "1957-06-01", "1957-07-01", "1957-08-01", "1957-09-01", "1957-10-01", "1957-11-01", "1957-12-01", "1958-01-01", "1958-02-01", "1958-03-01", "1958-04-01", "1958-05-01", "1958-06-01", "1958-07-01", "1958-08-01", "1958-09-01", "1958-10-01", "1958-11-01", "1958-12-01", "1959-01-01", "1959-02-01", "1959-03-01", "1959-04-01", "1959-05-01", "1959-06-01", "1959-07-01"], "y": [115.0, 116.375, 118.66666666666667, 121.04166666666667, 123.79166666666667, 126.70833333333333, 130.0, 133.66666666666666, 137.41666666666666, 141.79166666666666, 146.375, 151.20833333333334, 156.125, 160.75, 165.04166666666666, 168.91666666666666, 172.875, 176.625, 180.58333333333334, 184.625, 188.70833333333334, 192.95833333333334, 197.41666666666666, 201.95833333333334, 206.5, 211.0, 215.5, 220.0, 224.5, 228.875, 233.08333333333334, 237.375, 241.70833333333334, 246.125, 250.66666666666666, 255.125, 259.5416666666667, 264.0, 268.625, 273.5416666666667, 278.6666666666667, 283.4583333333333, 288.1666666666667, 292.875, 297.7083333333333, 302.6666666666667, 307.625, 312.5, 317.25, 322.0, 326.8333333333333, 331.75, 336.625, 341.375, 346.0, 350.5416666666667, 355.0, 359.4166666666667, 363.7083333333333, 367.9583333333333, 372.0833333333333, 376.2083333333333, 380.4166666666667, 384.8333333333333, 389.5, 394.4166666666667, 399.5, 404.5833333333333, 409.5416666666667, 414.25, 418.75, 423.0833333333333, 427.4166666666667, 431.9166666666667, 436.5833333333333, 441.4166666666667, 446.25, 451.0, 455.625, 460.0833333333333, 464.4166666666667, 468.6666666666667, 472.8333333333333, 477.0, 481.25, 485.5833333333333, 490.0, 494.5, 499.0833333333333, 503.75, 508.4166666666667, 513.0, 517.5, 521.875, 526.1666666666667, 530.4166666666667, 534.75, 539.125, 543.5416666666667, 548.0], "mode": "lines", "name": "趋势", "line": {"color": "#f76707"}, "showlegend": false, "xaxis": "x2", "yaxis": "y4"}, {"type": "scatter", "x": ["1949-01-01", "1949-02-01", "1949-03-01", "1949-04-01", "1949-05-01", "1949-06-01", "1949-07-01", "1949-08-01", "1949-09-01", "1949-10-01", "1949-11-01", "1949-12-01", "1950-01-01", "1950-02-01", "1950-03-01", "1950-04-01", "1950-05-01", "1950-06-01", "1950-07-01", "1950-08-01", "1950-09-01", "1950-10-01", "1950-11-01", "1950-12-01", "1951-01-01", "1951-02-01", "1951-03-01", "1951-04-01", "1951-05-01", "1951-06-01", "1951-07-01", "1951-08-01", "1951-09-01", "1951-10-01", "1951-11-01", "1951-12-01", "1952-01-01", "1952-02-01", "1952-03-01", "1952-04-01", "1952-05-01", "1952-06-01", "1952-07-01", "1952-08-01", "1952-09-01", "1952-10-01", "1952-11-01", "1952-12-01", "1953-01-01", "1953-02-01", "1953-03-01", "1953-04-01", "1953-05-01", "1953-06-01", "1953-07-01", "1953-08-01", "1953-09-01", "1953-10-01", "1953-11-01", "1953-12-01", "1954-01-01", "1954-02-01", "1954-03-01", "1954-04-01", "1954-05-01", "1954-06-01", "1954-07-01", "1954-08-01", "1954-09-01", "1954-10-01", "1954-11-01", "1954-12-01", "1955-01-01", "1955-02-01", "1955-03-01", "1955-04-01", "1955-05-01", "1955-06-01", "1955-07-01", "1955-08-01", "1955-09-01", "1955-10-01", "1955-11-01", "1955-12-01", "1956-01-01", "1956-02-01", "1956-03-01", "1956-04-01", "1956-05-01", "1956-06-01", "1956-07-01", "1956-08-01", "1956-09-01", "1956-10-01", "1956-11-01", "1956-12-01", "1957-01-01", "1957-02-01", "1957-03-01", "1957-04-01", "1957-05-01", "1957-06-01", "1957-07-01", "1957-08-01", "1957-09-01", "1957-10-01", "1957-11-01", "1957-12-01", "1958-01-01", "1958-02-01", "1958-03-01", "1958-04-01", "1958-05-01", "1958-06-01", "1958-07-01", "1958-08-01", "1958-09-01", "1958-10-01", "1958-11-01", "1958-12-01", "1959-01-01", "1959-02-01", "1959-03-01", "1959-04-01", "1959-05-01", "1959-06-01", "1959-07-01", "1959-08-01", "1959-09-01", "1959-10-01", "1959-11-01", "1959-12-01", "1960-01-01", "1960-02-01", "1960-03-01", "1960-04-01", "1960-05-01", "1960-06-01", "1960-07-01", "1960-08-01", "1960-09-01", "1960-10-01", "1960-11-01", "1960-12-01"], "y": [-22.47530760702131, -29.531187669077883, -6.721245474547453, -12.078745474547453, -11.938328807880787, 13.320837861671193, 30.780411195004523, 28.76374452833786, 13.113327861671193, -6.612938804995477, -30.68627213832881, -17.66530760702131, -22.47530760702131, -29.531187669077883, -6.721245474547453, -12.078745474547453, -11.938328807880787, 13.320837861671193, 30.780411195004523, 28.76374452833786, 13.113327861671193, -6.612938804995477, -30.68627213832881, -17.66530760702131, -22.47530760702131, -29.531187669077883, -6.721245474547453, -12.078745474547453, -11.938328807880787, 13.320837861671193, 30.780411195004523, 28.76374452833786, 13.113327861671193, -6.612938804995477, -30.68627213832881, -17.66530760702131, -22.47530760702131, -29.531187669077883, -6.721245474547453, -12.078745474547453, -11.938328807880787, 13.320837861671193, 30.780411195004523, 28.76374452833786, 13.113327861671193, -6.612938804995477, -30.68627213832881, -17.66530760702131, -22.47530760702131, -29.531187669077883, -6.721245474547453, -12.078745474547453, -11.938328807880787, 13.320837861671193, 30.780411195004523, 28.76374452833786, 13.113327861671193, -6.612938804995477, -30.68627213832881, -17.66530760702131, -22.47530760702131, -29.531187669077883, -6.721245474547453, -12.078745474547453, -11.938328807880787, 13.320837861671193, 30.780411195004523, 28.76374452833786, 13.113327861671193, -6.612938804995477, -30.68627213832881, -17.66530760702131, -22.47530760702131, -29.531187669077883, -6.721245474547453, -12.078745474547453, -11.938328807880787, 13.320837861671193, 30.780411195004523, 28.76374452833786, 13.113327861671193, -6.612938804995477, -30.68627213832881, -17.66530760702131, -22.47530760702131, -29.531187669077883, -6.721245474547453, -12.078745474547453, -11.938328807880787, 13.320837861671193, 30.780411195004523, 28.76374452833786, 13.113327861671193, -6.612938804995477, -30.68627213832881, -17.66530760702131, -22.47530760702131, -29.531187669077883, -6.721245474547453, -12.078745474547453, -11.938328807880787, 13.320837861671193, 30.780411195004523, 28.76374452833786, 13.113327861671193, -6.612938804995477, -30.68627213832881, -17.66530760702131, -22.47530760702131, -29.531187669077883, -6.721245474547453, -12.078745474547453, -11.938328807880787, 13.320837861671193, 30.780411195004523, 28.76374452833786, 13.113327861671193, -6.612938804995477, -30.68627213832881, -17.66530760702131, -22.47530760702131, -29.531187669077883, -6.721245474547453, -12.078745474547453, -11.938328807880787, 13.320837861671193, 30.780411195004523, 28.76374452833786, 13.113327861671193, -6.612938804995477, -30.68627213832881, -17.66530760702131], "mode": "lines", "name": "季节", "line": {"color": "#37b24d"}, "showlegend": false, "xaxis": "x2", "yaxis": "y6"}, {"type": "scatter", "x": ["1949-07-01", "1949-08-01", "1949-09-01", "1949-10-01", "1949-11-01", "1949-12-01", "1950-01-01", "1950-02-01", "1950-03-01", "1950-04-01", "1950-05-01", "1950-06-01", "1950-07-01", "1950-08-01", "1950-09-01", "1950-10-01", "1950-11-01", "1950-12-01", "1951-01-01", "1951-02-01", "1951-03-01", "1951-04-01", "1951-05-01", "1951-06-01", "1951-07-01", "1951-08-01", "1951-09-01", "1951-10-01", "1951-11-01", "1951-12-01", "1952-01-01", "1952-02-01", "1952-03-01", "1952-04-01", "1952-05-01", "1952-06-01", "1952-07-01", "1952-08-01", "1952-09-01", "1952-10-01", "1952-11-01", "1952-12-01", "1953-01-01", "1953-02-01", "1953-03-01", "1953-04-01", "1953-05-01", "1953-06-01", "1953-07-01", "1953-08-01", "1953-09-01", "1953-10-01", "1953-11-01", "1953-12-01", "1954-01-01", "1954-02-01", "1954-03-01", "1954-04-01", "1954-05-01", "1954-06-01", "1954-07-01", "1954-08-01", "1954-09-01", "1954-10-01", "1954-11-01", "1954-12-01", "1955-01-01", "1955-02-01", "1955-03-01", "1955-04-01", "1955-05-01", "1955-06-01", "1955-07-01", "1955-08-01", "1955-09-01", "1955-10-01", "1955-11-01", "1955-12-01", "1956-01-01", "1956-02-01", "1956-03-01", "1956-04-01", "1956-05-01", "1956-06-01", "1956-07-01", "1956-08-01", "1956-09-01", "1956-10-01", "1956-11-01", "1956-12-01", "1957-01-01", "1957-02-01", "1957-03-01", "1957-04-01", "1957-05-01", "1957-06-01", "1957-07-01", "1957-08-01", "1957-09-01", "1957-10-01", "1957-11-01", "1957-12-01", "1958-01-01", "1958-02-01", "1958-03-01", "1958-04-01", "1958-05-01", "1958-06-01", "1958-07-01", "1958-08-01", "1958-09-01", "1958-10-01", "1958-11-01", "1958-12-01", "1959-01-01", "1959-02-01", "1959-03-01", "1959-04-01", "1959-05-01", "1959-06-01", "1959-07-01"], "y": [1.219588804995477, 15.86125547166214, 3.219999999995477, 7.035411195004523, 0.14666213832881, 17.02699999999869, -3.255718804995477, 2.569588804995477, 7.46800547166214, 9.370411195004523, 8.563327861671193, 12.470837861671193, 4.094588804995477, 1.48625547166214, -0.15500000000452268, 1.700411195004523, 0.998727861671193, 6.98969239297869, 2.9919792736429526, 0.8438123309221173, 1.9999111950045227, 7.019588804995477, 3.5216621383288097, 11.720837861671193, -2.2804111950045227, -1.76374452833786, 3.3866721383288097, 0.6129388049954774, 5.18627213832881, 10.79030760702131, -0.5080207263570474, 0.09381233092211732, 2.9799111950045227, 2.000411195004523, 7.99832786167119, 10.55416213832881, 2.6779792736429526, 2.23625547166214, -1.0816721383288097, 1.4870611950045226, 5.999938804995477, 10.416527861671193, 0.35802072635704735, 1.6561876690778827, 3.646245474547453, 5.993745474547453, 5.298328807880787, 9.358328807880787, 4.439171195004523, 0.36125547166214, 0.1783478616711903, 4.02587452833786, 6.100061195004523, 6.710061195004523, -0.35993880499547735, -0.18702072635704735, 5.887911195004523, 3.3654111950045227, 8.97999452833786, 10.598328807880787, 7.898328807880787, -1.1770888049954774, 0.4729278616711903, 5.926200000004523, 7.99969239297869, 5.29652786167119, 3.68666213832881, -0.905828807880787, 5.80874452833786, 4.22874452833786, 10.041671195004523, 11.66499452833786, 8.748328807880787, 10.758328807880787, 6.88875547166214, 0.84875547166214, 0.6862278616711903, 6.803799999995477, 7.766200000004523, 6.32132786167119, 4.15138930067119, 0.26291119500452266, 5.16124452833786, 5.77874452833786, 9.291671195004523, 11.93499452833786, 8.81499452833786, 8.13499452833786, 4.32875547166214, -1.39124452833786, -0.11377213832880966, 6.496200000004523, 5.458700000004523, 5.60132786167119, 3.1113893006711903, -1.4170888049954774, 5.83875547166214, 7.23625547166214, 10.96499452833786, 12.63499452833786, 10.38499452833786, 10.51166213832881, 6.56875547166214, 0.23875547166214034, -0.8037721383288097, 7.088700000004523, 5.851200000004523, 6.29382786167119, 4.07138930067119], "mode": "lines", "name": "残差", "line": {"color": "#adb5bd"}, "showlegend": false, "xaxis": "x2", "yaxis": "y8"}]}航空旅客数据集中乘法(左列)和加法(右列)分解的比较图。分解图的解释观测值: 加载后的原始时间序列数据。趋势: 这个成分分离出序列的长期走向或水平变化。对于航空旅客数据,它准确反映了多年来的持续增长。请注意趋势线开头和结尾处的 NaN 值(缺失部分)。这是因为内部使用的移动平均计算需要当前点前后都有数据点。季节: 该图显示了每个周期(本例中是年度)重复的模式。在乘法分解中,季节成分围绕 1.0 波动。它表示按比例调整趋势的因子(例如,值 1.2 可能表示比该月的趋势水平高 20%)。请注意,这种模式多年来在形态上显得相对稳定。在加法分解中,季节成分围绕 0 波动。它表示添加到趋势或从趋势中减去的绝对值。对于航空旅客数据,请注意这个加法季节成分的振幅如何随时间增加,与旅客总人数的增长相对应。这表明它不能像乘法模型那样有效捕捉季节性,因为在乘法模型中季节性因子保持更一致。残差: 这是在移除估计的趋势和季节成分后的余下部分。理想情况下,残差应看起来像随机噪声,没有任何明显的模式或结构。比较两个残差图,乘法分解的残差显得更随机,均匀分布在 1.0 附近,并且随时间具有相对恒定的方差。然而,加法分解的残差随时间表现出一定的发散(方差增大),并可能保留一些潜在模式,尤其是在后期。这进一步印证了乘法模型是这个数据集更好的选择,因为它留下的残差更接近随机噪声。seasonal_decompose 的考量尽管 seasonal_decompose 是一个有用的探索性工具,但请记住以下几点:方法: 它通常使用中心化移动平均线。如果趋势变化迅速或数据中存在急剧的峰值或谷值,这种方法效果可能不佳。季节成分是通过对每个季节的去趋势值进行平均,然后对这些因子进行中心化来计算的。端点问题: 如前所述,由于移动平均线需要完整的数据窗口,序列起始和结束点附近的趋势和残差估计值通常缺失(NaN)或可靠性较低。静态季节性假设: 该方法假设季节模式在整个序列中要么是完全加法,要么是完全乘法。而季节性可能在长时间内以更复杂的方式演变。描述性,非预测性: 分解主要用于理解数据的历史结构。它不直接生成预测,尽管理解这些成分对于选择和构建预测模型很重要。STL (使用 Loess 的季节和趋势分解) 等更高级的方法可以提供更大的灵活性。分解为理解时间序列的潜在结构提供了有价值的见解。检查这些成分,尤其是残差,有助于评估原始序列是否表现出清晰的模式,以及移除这些模式后是否会得到更接近随机噪声的结果。这个评估直接引出了平稳性思想,我们将在接下来的章节中使用统计检验对其进行更正式的研究。