Skip to main content

jpfs - Japan Fiscal Simulator

PyPI version Python 3.13+ License: MIT

消費税減税・社会保障費増額・補助金政策などの財政政策が日本経済に与える影響をシミュレートするツール。Smets-Wouters級の中規模New Keynesian DSGEモデルをPythonでフルスクラッチ実装。

特徴

  • 14方程式の構造NKモデル: 17変数(state 5 + control 9 + 財政・税・円安ブロック)、8構造ショック
  • 5部門経済: 家計(習慣形成)、企業(Calvo価格・賃金硬直性)、政府、中央銀行、金融部門
  • QZ分解ベースBK/Klein解法: scipy.linalg.ordqz による合理的期待均衡の一般解法
  • ベイズ推定: Metropolis-Hastings MCMCサンプラー + カルマンフィルタ尤度計算
  • 日本経済向けキャリブレーション: 低金利環境、高債務水準、消費税10%
  • MCPサーバー: Claude Desktopとの連携
  • CLI: コマンドラインからのシミュレーション実行

インストール

pip install jpfs

または

uvx jpfs --help

使用方法

CLI

# シミュレーション実行
jpfs simulate consumption_tax --shock -0.02 --periods 40 --graph
jpfs simulate price_markup --shock 0.01 --periods 40

# 財政乗数計算
jpfs multiplier government_spending --horizon 8

# 定常状態表示
jpfs steady-state

# パラメータ表示
jpfs parameters

# MCPサーバー起動
jpfs mcp

Pythonからの使用

import japan_fiscal_simulator as jpfs

# モデル初期化
calibration = jpfs.JapanCalibration.create()
model = jpfs.DSGEModel(calibration.parameters)

# 定常状態
ss = model.steady_state
print(f"産出: {ss.output:.4f}")
print(f"消費: {ss.consumption:.4f}")

# シミュレーション
simulator = jpfs.ImpulseResponseSimulator(model)
result = simulator.simulate_consumption_tax_cut(tax_cut=0.02, periods=40)

# 結果
y_response = result.get_response("y")
print(f"産出ピーク効果: {max(y_response) * 100:.2f}%")

MCP連携

Claude Desktopの設定ファイル(claude_desktop_config.json)に追加:

{
  "mcpServers": {
    "jpfs": {
      "command": "jpfs",
      "args": ["mcp"]
    }
  }
}

ドキュメント

ドキュメント 内容
Getting Started インストールから最初のシミュレーションまで
CLI リファレンス 全コマンドの使い方とオプション
Python API Pythonライブラリとしての利用方法
ベイズ推定 MH-MCMCによるパラメータ推定
MCP サーバー Claude Desktopとの連携設定
数理モデル仕様書 全14方程式・解法・推定手法の数学的記述

モデル概要

家計部門

  • 異時点間効用最大化(消費のオイラー方程式)
  • 習慣形成(外部習慣)
  • 労働供給の内生化(限界代替率)

企業部門

  • Calvo型価格硬直性 + 価格インデクセーション
  • Calvo型賃金硬直性 + 賃金マークアップショック
  • Cobb-Douglas生産関数、実質限界費用の明示化
  • 資本蓄積(投資調整コスト、Tobin's Q)

政府部門

  • 消費税・所得税・資本所得税
  • 政府支出・移転支払い
  • 財政ルール(債務安定化)

中央銀行

  • テイラールール
  • 金利平滑化
  • ゼロ金利下限(ZLB)考慮

金融部門

  • 金融加速器(BGG型簡略版)
  • 外部資金プレミアム
  • リスクプレミアムショック

構造ショック(8種類)

技術(TFP)、リスクプレミアム、投資固有技術、賃金マークアップ、価格マークアップ、政府支出、金融政策、消費税、円安

パラメータ

主要パラメータ(日本キャリブレーション):

パラメータ 値 説明
β 0.999 割引率(低金利環境)
τ_c 0.10 消費税率(10%)
B/Y 2.00 政府債務/GDP比率
ρ_R 0.85 金利平滑化
θ 0.75 Calvo価格硬直性

出力形式

シミュレーション結果(JSON)

{
  "scenario": {
    "name": "消費税2%pt減税",
    "policy_type": "consumption_tax",
    "shock_size": -0.02
  },
  "impulse_response": {
    "y": {"values": [...]},
    "c": {"values": [...]},
    "pi": {"values": [...]}
  },
  "fiscal_multiplier": {
    "impact_multiplier": 0.85,
    "cumulative_multiplier_4q": 1.12
  }
}

開発

# 依存関係インストール
uv sync

# テスト実行
uv run pytest

# 型チェック(strictモード)
uv run mypy src/japan_fiscal_simulator

# Lint & フォーマット
uv run ruff check src tests
uv run ruff format src tests

今後の拡張候補(Phase 6: 日本固有の拡張)

モデル拡張

  • ZLB制約の明示的モデル化: ゼロ金利下限での非線形ダイナミクス
  • 高債務経済: リカーディアン/非リカーディアン家計の混合、財政持続可能性条件
  • 人口動態: OLG要素の導入、労働力人口減少のトレンド
  • 開放経済拡張: 為替レート、輸出入、海外金利の導入
  • 金融加速器の本格実装: BGG型の完全版(現在は簡略化)

インターフェース

  • Web UI: Streamlit/Gradioによるインタラクティブダッシュボード
  • API サーバー: FastAPIによるREST API提供

ライセンス

MIT License

参考文献

  • Smets, F., & Wouters, R. (2007). Shocks and frictions in US business cycles: A Bayesian DSGE approach.
  • Bernanke, B. S., Gertler, M., & Gilchrist, S. (1999). The financial accelerator in a quantitative business cycle framework.
  • Blanchard, O. J., & Kahn, C. M. (1980). The solution of linear difference models under rational expectations.

Metadata

Release files for jpfs 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jpfs 0.6.0
File Size Uploaded
jpfs-0.6.0.tar.gz 257.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jpfs 0.6.0
File Interpreter ABI Platform
jpfs-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 371.7 kB

Release files / jpfs-0.6.0.tar.gz

Download URL jpfs-0.6.0.tar.gz
Size 257.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b340fcf67e4d5409bd99051cb11be5a49b36a2353bad348dc4f229db1e217dc2
BLAKE2b-256 checksum
How to use checksums
3bfdb4d2ed472f7dfc13a2c70a7f94829134f7e90ceda888308ad31250b5855e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 5, 2026.

Transparency log

Release files / jpfs-0.6.0-py3-none-any.whl

Download URL jpfs-0.6.0-py3-none-any.whl
Size 114.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8709c8982d39bd2c2aa9a94eaa7059a1317ab138d6d1273d5852bb43746c0279
BLAKE2b-256 checksum
How to use checksums
901b194ded1f3223862029f0ebe7e9f2345a535ac57c8333643d4511801212f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 5, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.3

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page