信頼区間付きの割合

割合をウィルソンの 95% 信頼区間とともに、並べ替えたドットプロットで示します。

信頼区間付きの割合

「各群のうちどれだけの割合が…?」という問いには、棒グラフよりも、群ごとの点と信頼区間のほうが適しています。目は位置を比較でき、区間の幅から各割合の精度がすぐにわかります。教科書的なワルド区間ではなく ウィルソンのスコア区間 を用いているのは、小さな標本や 0 または 1 に近い割合でも 95% の被覆率を保てるためです。破線は要素全体の平均割合です。

設定は Kouloukoui, de Marcellis-Warin & Warin (2025, Climate) による、企業の気候移行計画の研究です。データは説明のための シミュレーション であり、論文のデータや結果では ありません。240 社について、計画に7つの要素(目標、設備投資、ガバナンス、スコープ3 など)が含まれるかどうかをコード化しています。区間は statsmodels.stats.proportion.proportion_confint(method="wilson") で求めています。すべての企業がすべての要素についてコード化されているため、7つの割合が等しいかどうかは コクランの Q 検定(statsmodels.stats.contingency_tables.cochrans_q)で検定しています。

コードおよび図中のテキストは英語です。

proportions-with-ci.py · 49 行
ダウンロード GitHub
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from statsmodels.stats.contingency_tables import cochrans_q
from statsmodels.stats.proportion import proportion_confint
# Simulated data, set in the context of Kouloukoui, de Marcellis-Warin & Warin (2025) [kouloukoui2025climate]

# Simulated coding: 240 firms × 7 plan elements (1 = included), linked by a firm-level ambition
rng = np.random.default_rng(88)
elements = {"Emission-reduction targets": 1.3, "Board oversight of climate": 0.7,
            "Interim (2030) milestones": 0.2, "Capex aligned with the plan": -0.6,
            "Scope 3 emissions covered": -0.9, "Executive pay linked to climate": -1.3,
            "Just-transition measures": -1.9}
ambition = rng.normal(0, 1, 240)
plans = pd.DataFrame({e: (b + ambition + rng.normal(0, 1, 240) > 0).astype(int)
                      for e, b in elements.items()})

# Proportion + Wilson 95% CI per element, sorted
g = pd.DataFrame({"k": plans.sum(), "n": len(plans)})
g["p"] = g.k / g.n
g["low"], g["high"] = proportion_confint(g.k, g.n, alpha=0.05, method="wilson")
g = g.sort_values("p")

# Cochran's Q: do the seven elements appear equally often in the same firms' plans?
q = cochrans_q(plans.to_numpy())
overall = g.p.mean()

fig, ax = plt.subplots(figsize=(8, 4.8))
y = np.arange(len(g))
ax.axvline(overall, color="#8E8E93", lw=1, ls="--", zorder=1)
ax.text(overall, len(g) - 0.45, f" average {overall:.0%}", fontsize=9, color="#6E6E73", va="bottom")
ax.hlines(y, g.low, g.high, color="#007AFF", lw=2.5, alpha=0.45, zorder=2)
ax.scatter(g.p, y, s=80, color="#007AFF", edgecolor="white", lw=1.5, zorder=3)

for yi, (_, row) in zip(y, g.iterrows()):
    ax.text(1.04, yi, f"{row.p:.0%}", va="center", fontsize=10, fontweight="semibold", color="#007AFF")
    ax.text(1.12, yi, f"{row.k:.0f} / {row.n:.0f}", va="center", fontsize=9.5, color="#6E6E73")

ax.set_yticks(y, g.index)
ax.set_ylim(-0.6, len(g) - 0.2)
ax.set_xlim(0, 1.26)
ax.set_xticks(np.arange(0, 1.01, 0.2))
ax.xaxis.set_major_formatter(plt.matplotlib.ticker.PercentFormatter(1, decimals=0))
ax.grid(axis="x"); ax.grid(axis="y", visible=False)
ax.set_xlabel("Firms whose transition plan includes the element (Wilson 95% CI)")
ax.set_title("Targets are common in transition plans; just-transition measures are rare", pad=26)
ax.text(0, 1.02, f"Cochran's Q({len(g) - 1}) = {q.statistic:.0f}, p < .001 for equal shares · "
        f"n = {len(plans)} firms (simulated)", transform=ax.transAxes, fontsize=9.5, color="#6E6E73")
plt.show()

図にはオプションの PyStatlas スタイル を使用しています。同じ見た目にするには plt.style.use("pystatlas.mplstyle") を追加してください。

データの出典

  • Simulated data. Simulated data with a fixed random seed, created for this example.
    No real respondents, documents or measurements: the numbers only illustrate how the chart and its statistics work.
  • Kouloukoui, de Marcellis-Warin & Warin (2025), corporate climate transition plans. Kouloukoui, D., de Marcellis-Warin, N., & Warin, T. (2025). Barriers, opportunities and best practices for corporate climate transition plans: A literature review. Climate, 13(5), 88. https://doi.org/10.3390/cli13050088
    The example is set in the context of this paper; unless its description says otherwise, the numbers are simulated and are not the paper's data or results.

これらの例は統計手法を説明するためのものです。項目に別の記載がない限り数値はシミュレーションであり、図のタイトルはこのシミュレーションデータで図が示す内容を述べたものです。引用した論文の知見でも、実質的な問いに対する著者の立場でもありません。結果、背景、データについては、ここに挙げた論文を参照してください。

引用方法

PyStatlas は Thierry Warin が作成・運営しています。研究や業務に役立った場合は、ぜひ引用してください。

Warin, T. (2026). Proportions with confidence intervals. In PyStatlas: A Python Gallery of Statistical Graphics for the Social Sciences (Version 1.1.0) [Computer software]. https://warin.ca/pystatlas/proportions-surveys/proportions-with-ci/

@misc{warin2026statlas,
  author       = {Warin, Thierry},
  title        = {PyStatlas: A Python Gallery of Statistical Graphics for the Social Sciences},
  year         = {2026},
  version      = {1.1.0},
  howpublished = {\url{https://warin.ca/pystatlas/}},
  note         = {Source code: https://github.com/warint/pystatlas}
}

割合と調査データのその他のグラフ