Search code examples
rstatisticsstat

Trouble using qt function for P(-t<x<t)


I have found very little information regarding this. I am new to statistical analysis and Rscript, so I am having trouble getting this to.

I am trying to find t for P(-t<X<t) = 0.96 where X ~t(11) using the qt function

I've gone and found P(X<t) which gave me 1.928427, qt(0.96,11) but when I try to find P(x<-t) I get NaN. (I'm trying to solve 1-P = P(x<-t) and then find the difference from P(X<t) and P(X<-t)

Am I approaching this from the wrong way all together?


Solution

  • The t(11) distribution is symmetric, so you just need to find the point where half your probability lies below the lower threshold. For example

    t <- abs(qt((1-0.96)/2, 11))
    t
    # [1] 2.32814
    

    And you can verify that give the correct answer with

    # P(T < t) - P(T < -t)
    pt(t, 11) - pt(-t, 11)
    # [1] 0.96