incline.trend_with_deseasonalization

incline.trend_with_deseasonalization(df, smoother=None, value_column='value', time_column=None, method='auto', period=None, n_bootstrap=100, random_state=None, **fit_kwargs)[source]

Deseasonalize, then estimate the trend of what is left.

A convenience wrapper over estimate(smoother, deseasonalize(df)). Takes a Smoother rather than a method name, so it works with every estimator without a dispatch table.

With with_uncertainty=True the uncertainty accounts for the seasonal fit as well as the trend fit. The standard error comes from bootstrapping the whole pipeline, drawing from the requested noise process and refitting both the decomposition and the trend.

That costs n_bootstrap decompositions, which is the price of an honest number and is only paid when a standard error is asked for. If you want the cheap interval that treats the adjusted series as data, compose the two steps yourself:

adjusted = deseasonalize(df)
result = sgolay_trend(
    adjusted, value_column="deseasonalized", with_uncertainty=True
)

which says plainly what it assumes.

Parameters:
  • df (pd.DataFrame) – Time series data.

  • smoother (Smoother | None) – Estimator to run. Penalized spline by default.

  • value_column (str) – Column holding the values.

  • time_column (str | None) – Numeric time column.

  • method (str) – Decomposition method; see deseasonalize().

  • period (int | None) – Cycle length. Detected when None.

  • n_bootstrap (int) – Replicates used to propagate the decomposition.

  • random_state (int | np.random.Generator | None) – Seed or Generator for the bootstrap.

  • **fit_kwargs (Any) – Passed through to the estimator, e.g. with_uncertainty=True.

Returns:

The estimator’s usual columns plus DECOMPOSITION_COLUMNS. One schema, whether or not a cycle was found.

Raises:
  • ValueError – If an argument is outside its domain or simultaneous whole-curve uncertainty is requested. The pipeline bootstrap computes pointwise intervals only.

  • RuntimeError – If every pipeline-bootstrap refit fails.

Return type:

pd.DataFrame