# statsmodels.tsa.tsatools.add_trend¶

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

Adds a trend and/or constant to an array.

Parameters: X (array-like) – Original array of data. trend (str {"c","t","ct","ctt"}) – “c” add constant only “t” add trend only “ct” add constant and linear trend “ctt” add constant and linear and quadratic trend. prepend (bool) – If True, prepends the new data to the columns of X. has_constant (str {'raise', 'add', 'skip'}) – Controls what happens when trend is ‘c’ and a constant already exists in X. ‘raise’ will raise an error. ‘add’ will duplicate a constant. ‘skip’ will return the data without change. ‘skip’ is the default. y – The original data with the additional trend columns. If x is a recarray or pandas Series or DataFrame, then the trend column names are ‘const’, ‘trend’ and ‘trend_squared’. array, recarray or DataFrame

Notes

Returns columns as [“ctt”,”ct”,”c”] whenever applicable. There is currently no checking for an existing trend.