t分布のグラフィクス

MINAKA Nobuhiro — Nov 4, 2013, 2:28 PM

## t分布に関連する関数(dchisq, pchisq, qchisq, rchisq)
## Copyright (c) 2004, 2013 by MINAKA Nobuhiro. All rights reserved. 

# —————————————————————————————————
# t分布の密度関数(dt)を表示し,標準正規分布と比較
# —————————————————————————————————

x <- seq(-4, 4, 0.01)
plot(x, dt(x, 20), type="n", xlab="x", ylab="density")
curve(dt(x, 5), type="l", add=T)
curve(dnorm(x), type="l", lty=2, add=T)

plot of chunk unnamed-chunk-1


# —————————————————————————————————
# 1%点の表示
# —————————————————————————————————
x <- seq(-4, 4, 0.01)
plot(x, dt(x, 20), type="n", xlab="x", ylab="density")
curve(dt(x, 5), type="l", add=T)

abline(h=0.05)
lower.alpha5 <- qt(0.05, 5)
lower.alpha5
[1] -2.015
abline(v=lower.alpha5)
points(lower.alpha5, 0.05, cex=3.0, pch="*")

upper.alpha5 <- -lower.alpha5
upper.alpha5
[1] 2.015
abline(v=upper.alpha5)
points(upper.alpha5, 0.05, cex=3.0, pch="*")

plot of chunk unnamed-chunk-1


# —————————————————————————————————
# t分布のパラメーター――自由度を変える
# —————————————————————————————————

x <- seq(-4, 4, 0.01)
plot(x, dt(x, 20), type="n", xlab="x", ylab="density")
title("t Distribution\ndf=1 to 10")
for (i in 1:5) curve(dt(x, i), type="l", lty=i, add=T)

plot of chunk unnamed-chunk-1


# Original Script: 8 December 2004 by MINAKA Nobuhiro
# Last Modified: 4 November 2013 by MINAKA Nobuhiro