Skip to main content

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

Project description

jpfs - Japan Fiscal Simulator

PyPI version Python 3.11+ License: MIT

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

特徴

  • 5部門DSGEモデル: 家計、企業、政府、中央銀行、金融部門
  • 14方程式の構造システム: state 5変数 + control 9変数
  • 日本経済向けキャリブレーション: 低金利環境、高債務水準、消費税10%
  • QZベースBK/Klein解法: 合理的期待均衡の一般解法
  • 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"]
    }
  }
}

モデル概要

家計部門

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

企業部門

  • 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_simulator

今後の拡張候補

モデル拡張

  • 消費税ショックの持続性: 現在は一時的ショックのみ。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.1.0.tar.gz (154.3 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.1.0-py3-none-any.whl (76.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for jpfs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 13ce4bc3ad817d5395ba4f19348ecb994673dfbfd50a29bd7b529e07d00ec65e
MD5 5bff127fb1ad12cffa78f28bfad8f802
BLAKE2b-256 0308814c91473dca410b32a6a73478d433e55eaf1d0420b049f92426c233c965

See more details on using hashes here.

Provenance

The following attestation bundles were made for jpfs-0.1.0.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.1.0-py3-none-any.whl.

File metadata

  • Download URL: jpfs-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 76.4 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 534c8056964f526cc4a221f156163801ae738626303f88eca564bd25192acc16
MD5 e15f7305c79ff5ffbda4af01a095cca9
BLAKE2b-256 b8a0a01fa243504e0c1cecd7129abbccf3fe153d35a97436bfd3faf5e7e440a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for jpfs-0.1.0-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