statsmodels.tsa.deterministic.CalendarTimeTrend¶
-
class statsmodels.tsa.deterministic.CalendarTimeTrend(freq, constant=
True, order=0, *, base_period=None)[source]¶ 基于日历时间的常数和时间趋势确定项
- Parameters:¶
- Attributes:¶
base_period基准期
constant指示包含常量的标志
freq确定性项的频率
is_dummy指示生成的值是否为虚拟变量的标志
order时间趋势的阶数
注释
时间戳 \(\tau_t\) 是从基准期开始以来已经过去的时间段数。\(\tau_t\) 可以是分数。
示例
在这里,我们模拟了不规则间隔的每小时数据,并为这些数据构建了日历时间趋势项。
>>> import numpy as np >>> import pandas as pd >>> base = pd.Timestamp("2020-1-1") >>> gen = np.random.default_rng() >>> gaps = np.cumsum(gen.integers(0, 1800, size=1000)) >>> times = [base + pd.Timedelta(gap, unit="s") for gap in gaps] >>> index = pd.DatetimeIndex(pd.to_datetime(times))>>> from statsmodels.tsa.deterministic import CalendarTimeTrend >>> cal_trend_gen = CalendarTimeTrend("D", True, order=1) >>> cal_trend_gen.in_sample(index)接下来,我们使用第一个时间戳进行归一化
>>> cal_trend_gen = CalendarTimeTrend("D", True, order=1, ... base_period=index[0]) >>> cal_trend_gen.in_sample(index)方法
from_string(freq, trend[, base_period])从字符串描述创建一个时间趋势。
in_sample(index)生成用于样本内拟合的确定性趋势。
out_of_sample(steps, index[, forecast_index])为样本外预测生成确定性趋势
属性
基准期
指示包含常量的标志
确定性项的频率
指示生成的值是否为虚拟变量的标志
时间趋势的阶数
Last update:
Oct 16, 2024