statsmodels.tsa.exponential_smoothing.ets.ETSResults.simulate

ETSResults.simulate(nsimulations, anchor=None, repetitions=1, random_errors=None, random_state=None)[source]

使用状态空间公式的随机模拟。

Parameters:
nsimulationsint

模拟步骤的数量。

anchorint, str, or datetime, optional

模拟的第一个周期。模拟将以锚点之前的所有现有数据点为条件。类型取决于给定的内生变量在模型中的索引。两个特殊情况是字符串‘start’和‘end’。start表示从样本的第一个周期开始模拟(即使用初始值作为模拟锚点),而end表示从样本后的第一个周期开始模拟。整数值可以从0到nobs,或者可以是负数以应用负索引。最后,如果向模型提供了日期/时间索引,则此参数可以是日期字符串或日期时间类型。默认值为‘start’。 注意:锚点对应于预测方法中开始观测之前的观测。

repetitionsint, optional

要生成的模拟路径数量。默认是1条模拟路径。

random_errorsoptional

指定如何获取随机误差。可以是以下之一:

  • None: 随机正态分布的值,方差根据拟合误差估计,从numpy的标准随机数生成器中抽取(可以使用random_state参数进行种子设定)。这是默认选项。

  • 来自 scipy.stats 的分布函数,例如 scipy.stats.norm:将分布函数拟合到拟合误差并从拟合的分布中抽取样本。 注意 scipy.stats.normscipy.stats.norm() 之间的区别,后者是一个冻结的分布函数。

  • 来自 scipy.stats 的冻结分布函数,例如 scipy.stats.norm(scale=2):从冻结的分布函数中抽取样本。

  • 一个形状为 (nsimulations, repetitions) 的 np.ndarray:使用给定的值作为随机误差。

  • "bootstrap": 从拟合误差中对随机误差进行采样。

random_stateint or np.random.RandomState, optional

随机数生成器的种子或一个 np.random.RandomState 对象。仅在 random_errorsNone 时使用。默认值为 None

Returns:
simpd.Series, pd.DataFrame or np.ndarray

一个 np.ndarraypd.Seriespd.DataFrame 的模拟值。 如果原始数据是 pd.Seriespd.DataFramesim 将是一个 pd.Series 如果 repetitions 是 1,并且是一个 pd.DataFrame 的形状 (nsimulations, repetitions) 否则。 否则,如果 repetitions 是 1,返回一个 np.ndarray 的形状 (nsimulations,),如果 repetitions 不是 1,则返回一个 np.ndarray 的形状 (nsimulations, repetitions)。


Last update: Oct 16, 2024