
の続きです。前回はデータをRに取り込むところまでやりました。今回はデータの様子を確認しましょう。
amt: 残高(単位1億円)のヒストグラムをみてみましょう。


分布の山が2つある感じですね。
date別に箱ひげ図を作って、2025年と2026年で違いがあるかをみてみます。


違いがあるようには見えないです。
type別の箱ひげ図も作ってみます。


これははっきりした違いがありますね。y10, つまり10年国債の残高が突出して大きいですね。
図で見るだけでなく、数値としても確認します。まずは、date別のamtの基本統計量です。

2025-03-10のamtの平均は1兆7583億円、2026-03-10のamtの平均は1兆6158億円です。あまり違いは無いですね。
type別の基本統計量をみてみます。

本数が一番多いのは20年債ですね。y5cは5年債のクライメート・トランジション債、y10cは10年債のクライメート・トランジション債です。inflは物価連動債のことです。
平均値でなくて、合計値をグラフにしてみましょう。
はじめは、date別です。


2026年のほうが少し残高が減っています。ただ、大きな違いはないです。
次はタイプ別です。


あきらかに、10年国債の残高が他と比べて大きいとわかります。
今回の分析でわかったことは、2025年と2026年で各国債の残高の平均値に大きな違いはないここと、国債の償還年限別に大きな違いはあり、10年国債が平均的に大きな残高になっている、ということです。
今回は以上です。
次回は
です。
はじめから読むには、
です。
今回のコードは以下になります。
#
# amtのヒストグラム
df |>
ggplot(aes(x = amt)) +
geom_histogram(color = "white") +
theme_minimal()
#
# date別
df |>
ggplot(aes(x = amt, fill = date)) +
geom_boxplot() +
theme_minimal()
#
# type別
df |>
ggplot(aes(x = amt, fill = type)) +
geom_boxplot() +
theme_minimal()
#
# date別のamtの基本統計量
df |>
group_by(date) |>
summarize(
min = min(amt),
med = median(amt),
avg = mean(amt),
max = max(amt),
sd = sd(amt),
n = n()
)
#
# type別のamtの基本統計量
df |>
group_by(type) |>
summarize(
min = min(amt),
med = median(amt),
avg = mean(amt),
max = max(amt),
sd = sd(amt),
n = n()
)
#
# date別の合計残高
df |>
group_by(date) |>
summarize(
total = sum(amt)
) |>
ggplot(aes(x = date, y = total)) +
geom_col(aes(fill = date)) +
theme_minimal()
#
# type別の合計残高
df |>
group_by(type) |>
summarize(
total = sum(amt)
) |>
ggplot(aes(x = type, y = total)) +
geom_col(aes(fill = type)) +
theme_minimal()
#
(冒頭の画像は、Bing Image Creator で生成しました。プロンプトは Landscape of natural long-wide view of green and brown grass field, close up of yellow rapeseed flowers, blue sky, photo です。)