選挙データの分析において、今回作成した3つのグラフ(GreenacreのSymbiplot、MDSプロット、相関行列)は、それぞれ「データのどこに光を当てているか」という視点が異なります。
なお、本分析は自治体単位の集計データに基づく生態学的分析であり、個々の有権者の投票行動を直接推定するものではありません。
主な違いは以下の通りです。
1. GreenacreのSymbiplot (対応分析に基づく)
このグラフは、「自治体」と「候補者・政党」の相対的な相関関係を同時に見るためのものです。
- 計算の仕組み: カイ二乗距離(平均的な得票パターンからの「ズレ」)に基づいています。
- 特徴: 単なる得票の多寡ではなく、「どの地域で、どの勢力が特徴的に強いか」を浮き彫りにします。
- Symbiplotの利点: 通常の対応分析(主座標プロット)では、点(自治体)と矢印(候補者)のスケールが異なりますが、Symbiplot(特異値の平方根を掛ける手法)は両者の広がりをバランス良く調整しているため、同一平面上での位置関係を直感的に解釈しやすくなっています。
2. MDSプロット (多次元尺度構成法)
このグラフは、「候補者・政党間の距離(似ている度合い)」そのものを可視化することに特化しています。
- 計算の仕組み: 各自治体での得票率を多次元の「座標」と見なし、候補者同士のユークリッド距離を計算して、その距離をできるだけ維持するように2次元に配置します。
- 特徴: 対応分析(CA)が「期待値からのズレ」に注目するのに対し、MDSは「得票パターンの全体的な形状が似ているか」に注目します。そのため、支持層の重なりや地域的な偏りが近い候補者同士が純粋に近くに配置されます。
3. 相関行列 (Correlation Matrix)
相関行列は、「一方が増えたら、もう一方はどう動くか」という直接的な連動性を示します。
- 計算の仕組み: 候補者・政党の得票率ベクトル間の相関係数(Pearsonなど)を計算します。
- 特徴: 自治体(行)の情報は背後に隠れ、勢力間の「共起性」や「排他性」が数値で明確になります。例えば、「A候補が強いところでは、B党も必ず強い(正の相関)」といった関係を最もシンプルに抽出します。
MST(最小全域木)の役割
SymbiplotとMDSの両方に付加したMST(点線)は、これら多次元の関係性の中に「最も太いパイプ(最短経路)」を通すものです。
点の配置だけでは見落としがちな、「実はこの2人は最も近い関係にある」という支持構造の骨格を浮き彫りにします。
まとめると:
- 「地域と勢力の相性」を見たいなら Symbiplot
- 「勢力間の純粋な距離」を見たいなら MDS
- 「勢力間の連動性(数値)」を確認するなら 相関行列
という使い分けになります。これらを組み合わせることで、多角的な選挙分析が可能になります。
補足
本分析では、得票率の差を幾何学的な距離として配置する古典的MDSを採用しました。念のため、距離の『順序』を重視する非計量的MDS(isoMDS)でも検証を行いましたが、ほぼ同一の配置が得られました。これにより、このグラフに示された勢力配置が、計算手法に左右されない極めて安定した構造であることが確認できました。
使用したデータ
相関行列 (Correlation Matrix)
```{r,out.width="100%"}
# --- AONF定数の定義 (Saved Informationに基づく) ---
AONF_CAPTION <- "Archives from 2026 Onward and Notes for the Future\n2026年以降の記録 | https://ab.cocolog-nifty.com/note/"
library(ggplot2)
library(dplyr)
library(tidyr)
library(reshape2)
# 1. データの読み込み
d26_raw <- read.csv("fukuoka11ku2026_merged_a.csv")
# 2. 前処理:2026年各政党の得票率算出(日本語カラム対応)
d26_party_shares <- d26_raw %>%
mutate(Total_Party = rowSums(select(., 自民党, 中道, 維新, ゆうこく連合, みらい, 保守党, 社民党,
民主党, 共産党, れいわ, 参政))) %>%
transmute(
Municipality = Municipality,
自民党 = 自民党 / Total_Party,
民主党 = 民主党 / Total_Party,
維新 = 維新 / Total_Party,
共産党 = 共産党 / Total_Party,
れいわ = れいわ / Total_Party,
参政 = 参政 / Total_Party,
中道 = 中道 / Total_Party,
ゆうこく連合 = ゆうこく連合 / Total_Party,
みらい = みらい / Total_Party,
保守党 = 保守党 / Total_Party,
社民党 = 社民党 / Total_Party,
)
# 3. 前処理:2026年各候補者の得票率算出
d26_cand_shares <- d26_raw %>%
mutate(Total_Cand = rowSums(select(., Tsuji, Takeda, Shiki, Inoue, Murakami))) %>%
transmute(
Municipality = Municipality,
Tsuji = Tsuji / Total_Cand,
Takeda = Takeda / Total_Cand,
Shiki = Shiki / Total_Cand,
Inoue = Inoue / Total_Cand,
Murakami = Murakami / Total_Cand
)
# 4. 相関行列の計算 (政党 vs 候補者)
parties <- c("自民党", "中道", "維新", "みらい", "民主党", "保守党", "参政", "ゆうこく連合", "共産党", "社民党", "れいわ")
candidates <- c("Takeda", "Murakami", "Inoue", "Tsuji", "Shiki")
cor_matrix <- as.data.frame(cor(d26_party_shares[, parties], d26_cand_shares[, candidates], use = "complete.obs"))
cor_matrix$Party <- rownames(cor_matrix)
cor_long <- melt(cor_matrix, id.vars = "Party", variable.name = "Candidate", value.name = "Correlation")
# 表示順の調整
cor_long$Party <- factor(cor_long$Party, levels = parties)
cor_long$Candidate <- factor(cor_long$Candidate, levels = rev(candidates))
# 5. 可視化:ヒートマップ
ggplot(cor_long, aes(x = Party, y = Candidate, fill = Correlation)) +
geom_tile(color = "white") +
# --- 修正箇所:絶対値が0.51を超える場合のみ数値を表示 ---
geom_text(aes(label = ifelse(abs(Correlation) > 0.51, sprintf("%.2f", Correlation), "")),
size = 3.5, family = "HiraKakuProN-W3") +
# --------------------------------------------------------
scale_fill_gradient2(low = "#e74c3c", mid = "white", high = "#3498db",
midpoint = 0, limit = c(-1, 1), name = "相関係数") +
theme_minimal(base_family = "HiraKakuProN-W3") +
theme(legend.position = "bottom",
axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1),
axis.title = element_blank(),
plot.title = element_text(face = "bold", size = 12),
plot.caption = element_text(size = 8, color = "gray30", hjust = 1, lineheight = 1.2)) +
labs(title = "2026年 福岡11区:政党支持層と候補者の同期率",
subtitle = "2026年比例区政党票と小選挙区候補者得票の地理的相関(|r| > 0.51 のみ数値を表示)",
caption = AONF_CAPTION)
```
GreenacreのSymbiplot
```{r,out.width="100%"}
#######################################
# Symbiplot(Greenacre) with MST
# MST calculation using Principal Coordinates
# Data: fukuoka11ku2026_merged_a.csv
#######################################
# 1. 冒頭のキャプション定義 (AONF標準)
AONF_CAPTION <- "Archives from 2026 Onward and Notes for the Future\n2026年以降の記録 | https://ab.cocolog-nifty.com/note/"
# 2. 必要パッケージの読み込み
if (!require("ca")) install.packages("ca")
if (!require("ape")) install.packages("ape")
if (!require("ggrepel")) install.packages("ggrepel")
library(ca)
library(ape)
library(ggplot2)
library(ggrepel)
# 3. データの読み込み
# 1列目の自治体名を列名として使用
voting_data <- read.csv("fukuoka11ku2026_merged_a.csv", row.names = 1, check.names = FALSE)
counts <- voting_data
# 4. 対応分析 (CA) の実行
res_ca <- ca(counts)
# 5. Symbiplot用の座標計算 (特異値の平方根を掛ける)
sv_sqrt <- diag(sqrt(res_ca$sv))
rows_coord <- as.data.frame(res_ca$rowcoord[, 1:2] %*% sv_sqrt[1:2, 1:2])
cols_coord <- as.data.frame(res_ca$colcoord[, 1:2] %*% sv_sqrt[1:2, 1:2])
colnames(rows_coord) <- c("Dim1", "Dim2")
rows_coord$Name <- rownames(rows_coord)
colnames(cols_coord) <- c("Dim1", "Dim2")
cols_coord$Name <- colnames(counts)
# 6. 最小全域木 (MST) の計算
# MST用の距離計算:主座標 (Principal Coordinates) を使用
full_principal_coords <- res_ca$colcoord %*% diag(res_ca$sv)
party_dist_chi2 <- dist(full_principal_coords)
st_tree <- mst(party_dist_chi2)
# 可視化用のエッジデータ作成
edges <- which(as.matrix(st_tree) == 1, arr.ind = TRUE)
edges <- edges[edges[,1] < edges[,2], ]
edge_df <- data.frame(
x = cols_coord$Dim1[edges[,1]], y = cols_coord$Dim2[edges[,1]],
xend = cols_coord$Dim1[edges[,2]], yend = cols_coord$Dim2[edges[,2]]
)
# 7. 可視化
ggplot() +
# MSTの点線 (政党・候補者間)
geom_segment(data = edge_df, aes(x=x, y=y, xend=xend, yend=yend),
color = "gray60", linetype = "dotted", linewidth = 0.5) +
# 自治体のプロット (青色・透過)
geom_point(data = rows_coord, aes(x=Dim1, y=Dim2), color = "blue", alpha = 0.3, size = 1.5) +
geom_text_repel(data = rows_coord, aes(x=Dim1, y=Dim2, label = Name),
color = "blue", size = 2.5, alpha = 0.6, family="HiraKakuProN-W3") +
# 政党・候補者のプロット (赤色・太字)
geom_point(data = cols_coord, aes(x=Dim1, y=Dim2), color = "red", size = 3) +
geom_text_repel(data = cols_coord, aes(x=Dim1, y=Dim2, label = Name),
color = "red", size = 3.5, fontface = "bold", family="HiraKakuProN-W3",
box.padding = 0.5, max.overlaps = Inf) +
# 原点補助線
geom_vline(xintercept = 0, linetype = "dashed", color = "gray80") +
geom_hline(yintercept = 0, linetype = "dashed", color = "gray80") +
# 座標系設定
coord_fixed() +
labs(title = "Greenacre's Symbiplot with MST",
subtitle = "Scaling: Standard Coordinates * sqrt(Singular Values)",
caption = AONF_CAPTION,
x = paste0("Dimension 1 (", round((res_ca$sv[1]^2/sum(res_ca$sv^2))*100, 1), "%)"),
y = paste0("Dimension 2 (", round((res_ca$sv[2]^2/sum(res_ca$sv^2))*100, 1), "%)")) +
# AONF標準テーマ設定
theme_minimal(base_family = "HiraKakuProN-W3") +
theme(legend.position = "bottom",
plot.caption = element_text(size = 8, color = "gray40", hjust = 1))
```
MDSプロット (多次元尺度構成法)
```{r,out.width="100%"}
############################################
### MDS Plot with Minimum Spanning Tree (MST)
### Applied to: fukuoka11ku2026_merged_a.csv
### Format: AONF Standard
############################################
# 1. 冒頭のキャプション定義 (AONF標準)
AONF_CAPTION <- "Archives from 2026 Onward and Notes for the Future\n2026年以降の記録 | https://ab.cocolog-nifty.com/note/"
# 2. 必要パッケージの読み込み
if (!require("ggplot2")) install.packages("ggplot2")
if (!require("ape")) install.packages("ape")
if (!require("ggrepel")) install.packages("ggrepel")
library(ggplot2)
library(ape)
library(ggrepel)
# 3. データの読み込み
voting_data <- read.csv("fukuoka11ku2026_merged_a.csv", row.names = 1, check.names = FALSE)
voting_numeric <- voting_data
# 4. 規模の影響を除去(各自治体内での得票率に変換)
voting_props <- prop.table(as.matrix(voting_numeric), margin = 1)
# 候補者・政党間の距離を計算するため転置
party_data_t <- t(voting_props)
# 5. 距離行列とMDSの実行
party_dist <- dist(party_data_t)
party_mds <- cmdscale(party_dist, k = 2)
# 6. 最小全域木 (MST) の計算
st <- mst(party_dist)
# 7. プロット用データの作成
mds_party_df <- data.frame(
Dimension1 = party_mds[, 1],
Dimension2 = party_mds[, 2],
Name = rownames(party_data_t)
)
# MSTの線を描画するためのデータ作成
edges <- which(as.matrix(st) == 1, arr.ind = TRUE)
edges <- edges[edges[, 1] < edges[, 2], ]
edge_coords <- data.frame(
x = mds_party_df$Dimension1[edges[, 1]],
y = mds_party_df$Dimension2[edges[, 1]],
xend = mds_party_df$Dimension1[edges[, 2]],
yend = mds_party_df$Dimension2[edges[, 2]]
)
# 8. 描画
ggplot(mds_party_df, aes(x = Dimension1, y = Dimension2)) +
# MSTの線
geom_segment(data = edge_coords, aes(x = x, y = y, xend = xend, yend = yend),
color = "gray", linetype = "dashed") +
# 政党の点
geom_point(color = "red", size = 2) +
# ラベルの重なり防止
geom_text_repel(
aes(label = Name),
size = 3,
fontface = "bold",
family = "HiraKakuProN-W3",
box.padding = 0.5,
point.padding = 0.3,
force = 10,
max.overlaps = Inf
) +
# 表示範囲の設定
expand_limits(
x = c(min(mds_party_df$Dimension1) * 1.3, max(mds_party_df$Dimension1) * 1.3),
y = c(min(mds_party_df$Dimension2) * 1.3, max(mds_party_df$Dimension2) * 1.3)
) +
coord_cartesian(clip = "off") +
# ラベルとAONFキャプション
labs(
title = "MDS Plot with Minimum Spanning Tree (MST)",
subtitle = "Lines connect candidates with the most similar voting patterns",
caption = AONF_CAPTION,
x = "Coordinate 1",
y = "Coordinate 2"
) +
# AONF標準テーマ設定
theme_minimal(base_family = "HiraKakuProN-W3") +
theme(
legend.position = "bottom",
plot.caption = element_text(size = 8, color = "gray40", hjust = 1),
plot.margin = margin(t = 60, r = 60, b = 40, l = 60),
plot.title = element_text(size = 12, face = "bold", vjust = 4)
)
```