係数プロット
回帰係数の推定値を 95% 信頼区間とともに、項ごとに1行で示します。

係数プロット(ドット・アンド・ウィスカープロットとも呼ばれます)は、回帰分析の表に代わるものです。各点が推定値、各線がその 95% 信頼区間で、破線はゼロを示します。区間がゼロをまたぐ項は灰色で描かれるため、有意な効果がひと目でわかります。
設定は Stojkov, Veljanovski & Warin (2024, Post-Communist Economies) による、新興欧州における経済成長と制度・政策要因の研究です。データは説明のために シミュレーション したもので、論文のデータや結果ではありません。n = 220 国・年(11 か国 × 20 年)で、1人あたり GDP の年間成長率を statsmodels の formula API(smf.ols())で6つの説明変数により説明しています。説明変数はあらかじめ標準化しているため、係数は直接比較できます。すなわち、説明変数が1標準偏差変化したときの成長率の変化(パーセントポイント)です。
コードおよび図中のテキストは英語です。
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import statsmodels.formula.api as smf
# Simulated data, set in the context of Stojkov, Veljanovski & Warin (2024) [stojkov2024growth]
# Data: 11 emerging-European economies × 20 years, six institutional and policy factors
rng = np.random.default_rng(2024)
n = 220
labels = {"rule_law": "Rule of law", "reg_quality": "Regulatory quality",
"investment": "Investment (% of GDP)", "openness": "Trade openness",
"inflation": "Inflation", "gov_size": "Government consumption"}
predictors = list(labels)
df = pd.DataFrame(rng.normal(size=(n, 6)), columns=predictors)
df["growth"] = (3 + 0.9 * df.rule_law + 0.45 * df.reg_quality + 0.8 * df.investment
+ 0.15 * df.openness - 0.7 * df.inflation - 0.05 * df.gov_size
+ rng.normal(0, 2.5, n))
df[predictors] = (df[predictors] - df[predictors].mean()) / df[predictors].std()
model = smf.ols("growth ~ " + " + ".join(predictors), data=df).fit()
# Tidy the results: estimate, 95% CI and p-value per term (intercept dropped)
ci = model.conf_int().drop("Intercept")
coefs = (
ci.assign(estimate=model.params, p=model.pvalues)
.rename(columns={0: "low", 1: "high"})
.sort_values("estimate")
)
fig, ax = plt.subplots(figsize=(8, 4.6))
y = np.arange(len(coefs))
colors = np.where(coefs["p"] < 0.05, "#007AFF", "#AEAEB2")
ax.axvline(0, color="#8E8E93", lw=1, ls="--", zorder=1)
ax.hlines(y, coefs["low"], coefs["high"], color=colors, lw=2.5, zorder=2)
ax.scatter(coefs["estimate"], y, s=80, color=colors, edgecolor="white", lw=1.5, zorder=3)
for yi, (_, row) in zip(y, coefs.iterrows()):
stars = "***" if row.p < .001 else "**" if row.p < .01 else "*" if row.p < .05 else ""
ax.annotate(f"{row.estimate:+.2f}{stars}", (row.high, yi), xytext=(8, 0),
textcoords="offset points", va="center", fontsize=10, color="#3A3A3C")
ax.set_yticks(y, [labels[t] for t in coefs.index])
ax.grid(axis="x"); ax.grid(axis="y", visible=False)
ax.set_xlabel("Effect on GDP-per-capita growth (pp per 1 SD), 95% CI")
ax.set_title("Rule of law and investment go with faster growth", pad=26)
ax.text(0, 1.02, f"OLS · n = {int(model.nobs)} country-years (simulated) · R² = {model.rsquared:.2f} · "
"* p<.05 ** p<.01 *** p<.001", transform=ax.transAxes,
fontsize=9.5, color="#6E6E73")
ax.margins(x=0.15)
plt.show()
# Coefficient plot: the R equivalent of plot.py
# Simulated data, set in the context of Stojkov, Veljanovski & Warin (2024) [stojkov2024growth]
# R and NumPy draw different random numbers, so the values differ slightly from the Python figure.
library(ggplot2)
library(broom)
set.seed(2024)
# Data: 11 emerging-European economies × 20 years, six institutional and policy factors
n <- 220
labels <- c(rule_law = "Rule of law", reg_quality = "Regulatory quality",
investment = "Investment (% of GDP)", openness = "Trade openness",
inflation = "Inflation", gov_size = "Government consumption")
predictors <- names(labels)
df <- as.data.frame(matrix(rnorm(n * 6), n, dimnames = list(NULL, predictors)))
df$growth <- with(df, 3 + 0.9 * rule_law + 0.45 * reg_quality + 0.8 * investment
+ 0.15 * openness - 0.7 * inflation - 0.05 * gov_size + rnorm(n, 0, 2.5))
df[predictors] <- scale(df[predictors])
model <- lm(reformulate(predictors, "growth"), data = df)
# Tidy the results: estimate, 95% CI and p-value per term (intercept dropped)
# (ggstats is not installed: broom::tidy() + ggplot2 do what ggcoef_model() does)
coefs <- subset(tidy(model, conf.int = TRUE), term != "(Intercept)")
coefs$label <- factor(labels[coefs$term], levels = labels[coefs$term[order(coefs$estimate)]])
coefs$sig <- coefs$p.value < 0.05
coefs$text <- sprintf("%+.2f%s", coefs$estimate,
ifelse(coefs$p.value < .001, "***", ifelse(coefs$p.value < .01, "**",
ifelse(coefs$p.value < .05, "*", ""))))
p <- ggplot(coefs, aes(estimate, label, colour = sig)) +
geom_vline(xintercept = 0, colour = "#8E8E93", linewidth = 0.5, linetype = "dashed") +
geom_linerange(aes(xmin = conf.low, xmax = conf.high), linewidth = 1.2) +
geom_point(aes(fill = sig), shape = 21, size = 3.8, colour = "white", stroke = 1) +
geom_label(aes(x = conf.high, label = text), hjust = 0, nudge_x = 0.04, size = 3.5,
colour = "#3A3A3C", fill = "white", label.size = 0,
label.padding = unit(0.1, "lines")) + # white box: legible over the zero line
scale_colour_manual(values = c(`TRUE` = "#007AFF", `FALSE` = "#AEAEB2"), guide = "none") +
scale_fill_manual(values = c(`TRUE` = "#007AFF", `FALSE` = "#AEAEB2"), guide = "none") +
scale_x_continuous(breaks = seq(-2, 2, 0.5), expand = expansion(mult = 0.15)) +
labs(title = "Rule of law and investment go with faster growth",
subtitle = sprintf("OLS · n = %d country-years (simulated) · R² = %.2f · * p<.05 ** p<.01 *** p<.001",
nobs(model), summary(model)$r.squared),
x = "Effect on GDP-per-capita growth (pp per 1 SD), 95% CI", y = NULL) +
theme_minimal(base_size = 11) +
theme(plot.title = element_text(face = "bold"),
plot.title.position = "plot",
plot.subtitle = element_text(size = 8.5, colour = "#6E6E73"),
axis.text.y = element_text(colour = "#1D1D1F", size = 10),
panel.grid.minor = element_blank(), panel.grid.major.y = element_blank())
print(p)
図にはオプションの 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. - Stojkov, Veljanovski & Warin (2024), European integration and growth in emerging Europe. Stojkov, A., Veljanovski, M., & Warin, T. (2024). European integration and economic growth in emerging Europe: The role of institutions and policy factors. Post-Communist Economies, 36(7), 778–800. https://doi.org/10.1080/14631377.2024.2376974
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). Coefficient plot. In PyStatlas: A Python Gallery of Statistical Graphics for the Social Sciences (Version 1.1.0) [Computer software]. https://warin.ca/pystatlas/regression-models/coefficient-plot/
@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}
}回帰モデルのその他のグラフ
オッズ比のフォレストプロット
ロジスティック回帰のオッズ比を対数スケールで描き、OR [95% CI] の表を並べます。
ggstats::ggcoef_model(exponentiate = TRUE)入れ子モデルの比較
FDI に関する 3 つの入れ子回帰の係数を並べ、EU ブロックを追加すると推定値がどう動くかを見ます。
ggstats::ggcoef_compare()予測確率
モデルに基づく確率曲線を、群ごとに 95% 信頼帯とともに説明変数の範囲にわたって描きます。
ggeffects::ggpredict() / marginaleffects::plot_predictions()