statsmodels.tsa.tsatools.add_trend

statsmodels.tsa.tsatools.add_trend(x, trend='c', prepend=False, has_constant='skip')[source]

向数组中添加趋势和/或常数。

Parameters:
xarray_like

原始数据数组。

trendstr {‘n’, ‘c’, ‘t’, ‘ct’, ‘ctt’}

要添加的趋势。

  • ‘n’ 不添加趋势。

  • ‘c’ 仅添加常数。

  • ‘t’ 仅添加趋势。

  • ‘ct’ 添加常数和线性趋势。

  • ‘ctt’ 添加常数、线性和二次趋势。

prependbool

如果为真,则将新数据前置到 X 的列中。

has_constantstr {‘raise’, ‘add’, ‘skip’}

控制当趋势为‘c’且常数列已经存在于x中时发生的情况。‘raise’将引发错误。‘add’将添加一列1。‘skip’将返回数据而不做任何更改。‘skip’是默认值。

Returns:
array_like

带有附加趋势列的原始数据。如果 x 是 pandas Series 或 DataFrame,那么趋势列名称为 ‘const’、‘trend’ 和 ‘trend_squared’。

另请参阅

statsmodels.tools.tools.add_constant

向数组添加一个常量列。

注释

在适用的情况下返回列 ['ctt', 'ct', 'c']。目前没有对现有趋势进行检查。


Last update: Oct 16, 2024