### F分布のグラフィクス

MINAKA Nobuhiro — Nov 4, 2013, 3:04 PM

``````## F分布に関連する関数（df, pf, qf, rf）

# —————————————————————————————————
# Ｆ分布の密度関数（df）を表示
# —————————————————————————————————

x <- seq(0, 4, 0.01)
plot(x, df(x, 15, 50), type="n", xlab="x", ylab="density")
``````

``````
# —————————————————————————————————
# Ｆ分布の確率分布関数（pf）を追加表示
# —————————————————————————————————

x <- seq(0, 4, 0.01)
plot(x, df(x, 15, 50), type="n", xlab="x", ylab="density")
curve(pf(x, 13, 50), type="l", lty=3, add=T)
``````

``````
# —————————————————————————————————
# 5％点の追加表示
# —————————————————————————————————

x <- seq(0, 4, 0.01)
plot(x, df(x, 15, 50), type="n", xlab="x", ylab="density")
curve(pf(x, 13, 50), type="l", lty=3, add=T)

abline(h=0.05)
lower.alpha5 <- qf(0.05, 13, 50)
lower.alpha5
``````
``````[1] 0.4322
``````
``````abline(v=lower.alpha5)
points(lower.alpha5, 0.05, cex=3.0, pch="*")

abline(h=0.95)
upper.alpha5 <- qf(0.05, 13, 50, lower.tail = FALSE)
upper.alpha5
``````
``````[1] 1.921
``````
``````abline(v=upper.alpha5)
points(upper.alpha5, 0.95, cex=3.0, pch="*")
``````

``````
# —————————————————————————————————
# 1％点の追加表示
# —————————————————————————————————

x <- seq(0, 4, 0.01)
plot(x, df(x, 15, 50), type="n", xlab="x", ylab="density")
curve(pf(x, 13, 50), type="l", lty=3, add=T)

abline(h=0.05)
abline(v=lower.alpha5)
points(lower.alpha5, 0.05, cex=3.0, pch="*")

abline(h=0.95)
abline(v=upper.alpha5)
points(upper.alpha5, 0.95, cex=3.0, pch="*")

abline(h=0.01, lty=2)
lower.alpha1 <- qf(0.01, 13, 50)
lower.alpha1
``````
``````[1] 0.2963
``````
``````abline(v=lower.alpha1, lty=2)
points(lower.alpha1, 0.01, cex=3.0, pch="*")

abline(h=0.99, lty=2)
upper.alpha1 <- qf(0.01, 13, 50, lower.tail = FALSE)
upper.alpha1
``````
``````[1] 2.508
``````
``````abline(v=upper.alpha1, lty=2)
points(upper.alpha1, 0.99, cex=3.0, pch="*")
``````

``````
# —————————————————————————————————
# F分布のパラメーター（１）――分子自由度n1を変える
# —————————————————————————————————

x <- seq(0, 4, 0.01)
plot(x, df(x, 15, 50), type="n", xlab="x", ylab="density")
title("F Distribution\nn1=13 -> 5")
for (i in 1:5) curve(df(x, 13-2*(i-1), 50), type="l", lty=i, add=T)
``````

``````
# —————————————————————————————————
# F分布のパラメーター（２）――分母自由度n2を変える
# —————————————————————————————————

x <- seq(0, 4, 0.01)
plot(x, df(x, 15, 50), type="n", xlab="x", ylab="density")
title("F Distribution\nn2=50 -> 10")
for (i in 1:5) curve(df(x, 13, 50-10*(i-1)), type="l", lty=i, add=T)
``````

``````
# —————————————————————————————————
# F分布のパラメーター（３）――分子と分母の自由度を同時に変える
# —————————————————————————————————

x <- seq(0, 4, 0.01)
plot(x, df(x, 15, 50), type="n", xlab="x", ylab="density")
title("F Distribution\nn1=13 -> 5\nn2=50 -> 10")
for (i in 1:5) curve(df(x, 13-2*(i-1), 50-10*(i-1)), type="l", lty=i, add=T)
``````

``````
# Original Script: 8 December 2004 by MINAKA Nobuhiro