R:创建t分布的百分点表

时间:2015-07-26 13:15:29

标签: r statistics distribution

我想知道如何在R中创建table of percentage points of the t-distribution。我的MWE是:

Prob <- c(0.40, 0.25, 0.10, 0.05, 0.025, 0.01, 0.005, 0.0025, 0.001, 0.0005)
DegreeFreedom <- c(1:30, 40, 60, 120)

qt(
    p          = Prob
  , df         = DegreeFreedom
  , ncp        = 0
  , lower.tail = FALSE
  , log.p      = FALSE
  )

[1] 0.3249197 0.8164966 1.6377444 2.1318468 2.5705818 3.1426684 3.4994833 3.8325187 4.2968057 4.5868939
[11] 0.2595559 0.6954829 1.3501713 1.7613101 2.1314495 2.5834872 2.8982305 3.1965742 3.5794001 3.8495163
[21] 0.2565799 0.6858050 1.3194602 1.7108821 2.0595386 2.4786298 2.7706830 3.0469288 3.3962403 3.6459586
[31] 0.2550387 0.6786007 1.2886462

1 个答案:

答案 0 :(得分:3)

你的意思是

## include Normal (df -> Inf) values at head of the table, as in
## linked example
DegreeFreedom <- c(Inf,DegreeFreedom) 
m <- t(outer(Prob,DegreeFreedom,
          qt,lower.tail=FALSE))
dimnames(m) <- list(df=DegreeFreedom,alpha=Prob)

检查:

m["1","0.1"]  ## 3.077684