Skip to content

Theta

The Theta method decomposes a time series into two "theta lines" and combines their forecasts.


Theta

from durbyn import Theta

model = Theta(model_type="OTM").fit(y, m=12)
fc = model.forecast(h=12, level=[80, 95])

Parameters

Parameter Type Default Description
model_type str "OTM" Model type: "OTM" (optimised), "STM" (simple), "DSTM", "DOTM"
alpha float \| None None Smoothing parameter
theta_param float \| None None Theta parameter value
initial_level float \| None None Initial level value
nmse int 3 Steps for multi-step MSE evaluation

Model Types

Type Description
"STM" Simple Theta Method
"OTM" Optimised Theta Method
"DSTM" Dynamic Simple Theta Method
"DOTM" Dynamic Optimised Theta Method

AutoTheta

Automatically selects the best Theta model type.

from durbyn import AutoTheta

model = AutoTheta().fit(y, m=12)
fc = model.forecast(h=12, level=[80, 95])

# With specific decomposition
model = AutoTheta(
    decomposition_type="multiplicative",
    nmse=5,
).fit(y, m=12)

Parameters

Parameter Type Default Description
model str \| None None Specific model type. None to try all
decomposition_type str "multiplicative" Seasonal decomposition: "multiplicative" or "additive"
alpha float \| None None Smoothing parameter
theta_param float \| None None Theta parameter
initial_level float \| None None Initial level value
nmse int 3 Steps for multi-step MSE

Example

from durbyn import Theta, AutoTheta, compare

y_train = y[:24]
y_test = y[24:]

result = compare(
    models={
        "STM": Theta(model_type="STM"),
        "OTM": Theta(model_type="OTM"),
        "DOTM": Theta(model_type="DOTM"),
        "AutoTheta": AutoTheta(),
    },
    y_train=y_train,
    y_test=y_test,
    m=12,
)

print(result.to_dataframe())