Skip to content

ENH: Add FIAPARCH volatility model#833

Open
gjunjie wants to merge 8 commits intobashtage:mainfrom
gjunjie:add-fiaparch
Open

ENH: Add FIAPARCH volatility model#833
gjunjie wants to merge 8 commits intobashtage:mainfrom
gjunjie:add-fiaparch

Conversation

@gjunjie
Copy link
Copy Markdown

@gjunjie gjunjie commented Apr 3, 2026

Implements the Fractionally Integrated Asymmetric Power ARCH (FIAPARCH) volatility model, partially addressing #531

FIAPARCH extends FIGARCH with an asymmetry parameter (gamma) and a flexible power parameter (delta). Includes Python/Cython recursions, FIAPARCHUpdater for ARCH-in-mean support, arch_model(..., vol="fiaparch") integration, and tests.

gjunjie added 2 commits April 2, 2026 21:24
Implement the Fractionally Integrated Asymmetric Power ARCH model,
extending FIGARCH with an asymmetry parameter (gamma) and a flexible
power parameter (delta). Includes Python and Cython recursions,
FIAPARCHUpdater for ARCH-in-mean support, simulation and forecasting,
arch_model integration via vol="fiaparch", and comprehensive tests.

Made-with: Cursor
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.56%. Comparing base (2524b62) to head (450fbad).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #833      +/-   ##
==========================================
+ Coverage   99.53%   99.56%   +0.03%     
==========================================
  Files          78       78              
  Lines       15817    16694     +877     
  Branches     1294     1367      +73     
==========================================
+ Hits        15743    16622     +879     
+ Misses         39       38       -1     
+ Partials       35       34       -1     
Flag Coverage Δ
adder 99.53% <100.00%> (+0.03%) ⬆️
subtractor 99.53% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

raise ValueError("o must be either 0 or 1.")
if self._truncation <= 0:
raise ValueError("truncation must be a positive integer")
self._num_params = 2 + p + q + o + int(self._est_delta)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

override the default

if self._truncation <= 0:
raise ValueError("truncation must be a positive integer")
self._num_params = 2 + p + q + o + int(self._est_delta)
self._name = self._generate_name()
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

override the default

return sigma2


fiaparch_recursion = jit(fiaparch_recursion_python, nopython=True)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fiaparch_recursion is consumed by volatility.py through the rec alias

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds the Fractionally Integrated Asymmetric Power ARCH (FIAPARCH) volatility process and wires it into the high-level arch_model API, including recursions/updaters and unit tests.

Changes:

  • Implement FIAPARCH volatility process (variance recursion, simulation, forecasting, constraints/bounds, parameter naming).
  • Add Cython + Python (Numba) recursions and FIAPARCHUpdater for ARCH-in-mean compatibility.
  • Integrate vol="fiaparch" into arch_model and add targeted tests.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
arch/univariate/volatility.py Adds the FIAPARCH volatility process implementation and hooks it to recursion/updater code.
arch/univariate/recursions.pyx Adds the Cython FIAPARCH recursion and volatility updater.
arch/univariate/recursions.pyi Exposes typing for the new recursion and updater.
arch/univariate/recursions_python.py Adds the Python/Numba FIAPARCH recursion and updater implementation.
arch/univariate/mean.py Enables arch_model(..., vol="fiaparch") selection.
arch/univariate/__init__.py Exports FIAPARCH at package level.
arch/tests/univariate/test_volatility.py Adds unit tests for FIAPARCH recursion, updater, simulation, and parameterization variants.
arch/tests/univariate/test_mean.py Tests arch_model integration for vol="fiaparch".
Comments suppressed due to low confidence (2)

arch/univariate/mean.py:2004

  • arch_model now accepts vol="fiaparch" (via known_vol), but the function signature type annotation and docstring list of supported volatility models still omit FIAPARCH. This makes the public API docs/type checking inconsistent with runtime behavior. Update the vol: Literal[...] annotation and the docstring’s supported options to include FIAPARCH (and keep casing/aliases consistent with the existing options).
    known_mean = ("zero", "constant", "harx", "har", "ar", "arx", "ls")
    known_vol = (
        "arch",
        "figarch",
        "fiaparch",
        "aparch",
        "garch",
        "harch",
        "constant",
        "egarch",
    )

arch/univariate/mean.py:2045

  • The p-type validation checks vol (original input) against a lowercase tuple. This means arch_model(..., vol="FIAPARCH") (or other uppercase variants) won’t trigger the intended TypeError when p is not an int, and will instead fail later via an assert isinstance(p, int) branch. Use vol_model (the lowercased value) in this condition to make validation case-insensitive and avoid AssertionError for user input.
    if vol in ("arch", "garch", "figarch", "fiaparch", "egarch", "aparch") and not isinstance(
        p, int
    ):
        raise TypeError(
            "p must be a scalar int for all volatility processes except HARCH."
        )

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bashtage
Copy link
Copy Markdown
Owner

bashtage commented Apr 3, 2026

I've only just skimmed and it looks good on first pass. Any chance you could hit edge cases that are missed in coverage?

@gjunjie
Copy link
Copy Markdown
Author

gjunjie commented Apr 3, 2026

I've only just skimmed and it looks good on first pass. Any chance you could hit edge cases that are missed in coverage?

Thanks! @bashtage Let me resolve the comments and think more on the edge cases.

gjunjie added 5 commits April 3, 2026 10:27
- Add FIAPARCH to arch_model vol parameter type hint and docstring
- Fix delta assignment bug in FIAPARCH.__init__ (used raw delta
  instead of self._delta for range check, then reassigned)
- Fix arch_model using `vol` instead of `vol_model` for p type check
- Parametrize updater-vs-recursion test over o and delta
- Add tests for no-beta/no-asym compute_variance, simulation,
  backcast_transform, fixed-delta str, and high-persistence warnings
- Include FIAPARCH in forecast test volatilities list

Made-with: Cursor
Fix bug using vol_model instead of vol in arch_model type check.
Add tests for FIAPARCH with reduced p, o, q combinations including
forecasting, simulation, parameter names, and backcast_transform.

Made-with: Cursor
Cover the two partial-coverage lines flagged by Codecov (q=0 branch
in fiaparch_recursion_python, persistence >= 1 simulation path) and
exercise additional edge cases: p=0/q=0 recursion, updater buffer
reuse, and compute_variance sigma_delta reuse.

Made-with: Cursor
The `if persistence < 1` guard is unnecessary since the test
parameters always yield persistence < 1. The persistence >= 1
case is already covered by dedicated tests.

Made-with: Cursor
Matches the Cython updater so pickle round-tripping works when the
extension is not built (e.g. ARCH_NO_BINARY CI), fixing
test_fiaparch_updater_reduce_setstate.

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants