Skip to main content

Japan Fiscal Simulator - New Keynesian DSGEモデルによる財政政策分析

Project description

jpfs - Japan Fiscal Simulator

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

特徴

  • 5部門DSGEモデル: 家計、企業、政府、中央銀行、金融部門
  • 日本経済向けキャリブレーション: 低金利環境、高債務水準、消費税10%
  • Blanchard-Kahn解法: 合理的期待均衡の数値解法
  • MCPサーバー: Claude Desktopとの連携
  • CLI: コマンドラインからのシミュレーション実行

インストール

pip install -e .

使用方法

CLI

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

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

# 定常状態表示
jpfs steady-state

# パラメータ表示
jpfs parameters

# MCPサーバー起動
jpfs mcp

Pythonからの使用

from japan_fiscal.core.model import DSGEModel
from japan_fiscal.core.simulation import ImpulseResponseSimulator
from japan_fiscal.parameters.calibration import JapanCalibration

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

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

# シミュレーション
simulator = 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"]
    }
  }
}

モデル概要

家計部門

  • 異時点間効用最大化
  • 習慣形成(外部習慣)
  • 労働供給の内生化

企業部門

  • Calvo型価格硬直性
  • CES生産関数
  • New Keynesian Phillips曲線

政府部門

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

中央銀行

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

金融部門

  • 金融加速器(BGG型簡略版)
  • 外部資金プレミアム
  • 純資産発展方程式

パラメータ

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

パラメータ 説明
β 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
  }
}

開発

テスト実行

pytest tests/

型チェック

mypy src/japan_fiscal

今後の拡張候補

モデル拡張

  • 消費税ショックの持続性: 現在は一時的ショックのみ。AR(1)プロセスで持続的な効果をモデル化
  • 金融加速器の本格実装: BGG型の完全版(現在は簡略化)
  • ZLB制約の明示的モデル化: ゼロ金利下限での非線形ダイナミクス
  • 開放経済拡張: 為替レート、輸出入、海外金利の導入
  • 異質的家計: 流動性制約を持つ家計(Hand-to-Mouth)の追加

分析機能

  • グラフ出力: --graphオプションでMatplotlibによる可視化
  • レポート生成: Jinja2テンプレートによるHTML/PDFレポート
  • 感度分析: パラメータの変化に対する結果の感応度
  • シナリオ比較: 複数政策シナリオの同時比較機能
  • ベイズ推定: 実データを用いたパラメータ推定

インターフェース

  • MCPサーバーの拡充: 追加ツール・リソースの実装
  • Web UI: Streamlit/Gradioによるインタラクティブダッシュボード
  • API サーバー: FastAPIによるREST API提供

コード品質

  • 型チェック強化: mypy strict モードへの対応
  • ドキュメント: Sphinxによる API ドキュメント自動生成
  • CI/CD: GitHub Actionsによる自動テスト・デプロイ

ライセンス

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jpfs-0.0.1.tar.gz (169.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jpfs-0.0.1-py3-none-any.whl (67.9 kB view details)

Uploaded Python 3

File details

Details for the file jpfs-0.0.1.tar.gz.

File metadata

  • Download URL: jpfs-0.0.1.tar.gz
  • Upload date:
  • Size: 169.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for jpfs-0.0.1.tar.gz
Algorithm Hash digest
SHA256 df1285a683b50ae524882e3eef100b61b1cc3b8059749751d565c719e246b921
MD5 de8cfc5fca0824312bf54eb00c37e53b
BLAKE2b-256 8ecf94e1427135c3e4db9eebaca0cf8f0b9695cdbb1db7474b64ca6c9f827987

See more details on using hashes here.

Provenance

The following attestation bundles were made for jpfs-0.0.1.tar.gz:

Publisher: publish.yml on DaisukeYoda/japan-fiscal-simulator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jpfs-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: jpfs-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 67.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for jpfs-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8f406f9045c2278fed1597b64b65ecb874624a9e947ac32b226ff1a8fd64f75f
MD5 c3c5366a03040ca45c3e9f89c3d0fced
BLAKE2b-256 5b32811854d7276e658c0a18decbe9a5e6a89120072a95f172e002080fa41a38

See more details on using hashes here.

Provenance

The following attestation bundles were made for jpfs-0.0.1-py3-none-any.whl:

Publisher: publish.yml on DaisukeYoda/japan-fiscal-simulator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page