Japan Fiscal Simulator - New Keynesian DSGEモデルによる財政政策分析
Project description
jpfs - Japan Fiscal Simulator
消費税減税・社会保障費増額・補助金政策などの財政政策が日本経済に与える影響をシミュレートするツール。Smets-Wouters級の中規模New Keynesian DSGEモデルをPythonでフルスクラッチ実装。
特徴
- 14方程式の構造NKモデル: 16変数(state 5 + control 9 + 財政・税ブロック)、7構造ショック
- 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型簡略版)
- 外部資金プレミアム
- リスクプレミアムショック
構造ショック(7種類)
技術(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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jpfs-0.5.0.tar.gz.
File metadata
- Download URL: jpfs-0.5.0.tar.gz
- Upload date:
- Size: 242.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
994830f4db4fb256720311ec7ea8c35b3cbb92f18e9325c10bc9f940b755c401
|
|
| MD5 |
0913440b5f6d1d38fd51442070d72630
|
|
| BLAKE2b-256 |
bcb3bd45f503836d18148a3895988a5726dbe03c3ffa8deab5273cce8fa2aef4
|
Provenance
The following attestation bundles were made for jpfs-0.5.0.tar.gz:
Publisher:
publish.yml on DaisukeYoda/japan-fiscal-simulator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jpfs-0.5.0.tar.gz -
Subject digest:
994830f4db4fb256720311ec7ea8c35b3cbb92f18e9325c10bc9f940b755c401 - Sigstore transparency entry: 975606165
- Sigstore integration time:
-
Permalink:
DaisukeYoda/japan-fiscal-simulator@231aee5980f44dd12bc93603dc0ac8c8f7109db6 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/DaisukeYoda
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@231aee5980f44dd12bc93603dc0ac8c8f7109db6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file jpfs-0.5.0-py3-none-any.whl.
File metadata
- Download URL: jpfs-0.5.0-py3-none-any.whl
- Upload date:
- Size: 102.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12d60b380a2bc25c754f51b3ce9a2ea00345daa5f51a4dbba0869db1e115b71f
|
|
| MD5 |
322e2bb999696035ee290e0cd68cade5
|
|
| BLAKE2b-256 |
100c03467e5c13e96edb5e2c40335388cadedb7aff268f4d2165980bf368532c
|
Provenance
The following attestation bundles were made for jpfs-0.5.0-py3-none-any.whl:
Publisher:
publish.yml on DaisukeYoda/japan-fiscal-simulator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jpfs-0.5.0-py3-none-any.whl -
Subject digest:
12d60b380a2bc25c754f51b3ce9a2ea00345daa5f51a4dbba0869db1e115b71f - Sigstore transparency entry: 975606169
- Sigstore integration time:
-
Permalink:
DaisukeYoda/japan-fiscal-simulator@231aee5980f44dd12bc93603dc0ac8c8f7109db6 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/DaisukeYoda
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@231aee5980f44dd12bc93603dc0ac8c8f7109db6 -
Trigger Event:
release
-
Statement type: