Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion arch/tests/univariate/test_mean.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from arch.compat.pandas import MONTH_END

from arch.univariate.mean import MAMean
from io import StringIO
import itertools
from itertools import product
Expand Down Expand Up @@ -104,6 +104,7 @@ def simulated_data(request):
HARX(SP500, lags=[1, 5]),
ConstantMean(SP500),
ZeroMean(SP500),
MAMean(SP500,lags=2)
]

mean_models = [
Expand Down Expand Up @@ -232,6 +233,30 @@ def test_constant_mean(self):
with pytest.raises(ValueError, match="horizon must be an integer >= 1"):
res.forecast(horizon=0, start=20)

def test_ma_mean(self):
with np.errstate(over="ignore", invalid="ignore"):
ma = MAMean(self.y, lags=2)
assert ma.name == "MA"
assert_equal(ma.num_params, 3)
assert_equal(ma.constant, True)
bounds = ma.bounds()
assert_equal(len(bounds), 3)
params = np.array(
[0.5, 0.3, -0.2, 0.1, 0.5, 0.2]
) # mu, theta_1, theta_2 + GARCH

ma.volatility = GARCH()
sim_data = ma.simulate(params, self.T)
assert isinstance(sim_data, pd.DataFrame)
assert sim_data.shape == (self.T, 3)

res = ma.fit(disp=DISPLAY)
assert isinstance(res.__str__(), str)
assert isinstance(ma.__repr__(), str)

forecasts = res.forecast(horizon=5, start=5)
assert isinstance(forecasts, ARCHModelForecast)

def test_zero_mean(self):
zm = ZeroMean(self.y)
parameters = np.array([1.0])
Expand Down
2 changes: 2 additions & 0 deletions arch/univariate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
ARCHInMean,
ConstantMean,
ZeroMean,
MAMean,
arch_model,
)
from arch.univariate.volatility import (
Expand Down Expand Up @@ -43,6 +44,7 @@
"ARCHInMean",
"ARX",
"ConstantMean",
"MAMean",
"ConstantVariance",
"Distribution",
"EGARCH",
Expand Down
Loading
Loading