Skip to content
Prev 146554 / 398500 Next

Student Distribution and Funtion qt

On 09-Jun-08 13:14:02, "Antje Schaff?ner" wrote:
You don't give an explicit example of the answer you were expecting,
and the answer you got. However, there are two points in your code
above which, I think, need correcting.

1. For a 95% confidence interval, use qt(0.975,n), not qt(0.98,n).
   Why did you choose 0.98?

2. The number of degrees of freedom for qt() should be (n-1),
   not n as you used.

For example, if n=10:

  qt(0.98,10)
# [1] 2.359315
  qt(0.975,10)
# [1] 2.228139
  (qt(0.98,10)-qt(0.975,10))/qt(0.975,10)
# [1] 0.05887235

so almost 6% error in using 0.98 instead of 0.975

  (qt(0.98,10)-qt(0.98,9))/qt(0.98,9)
# [1] -0.01631325

so 1.6% error (in the opposite direction) in using df=10 instead of 9.

  qt(0.975,9)
# [1] 2.262157

  (qt(0.98,10)-qt(0.975,9))/qt(0.975,9)
# [1] 0.04294903

so 4.3% error using (0.98,10) instead of (0.975,9).

Regarding your point below, about "getting the two-side result
from qt()", for a 5% 2-sided CI you need 2.5% at each end; and
the t-distribution is symmetrical, so qt(0.975,df) will do it.
The other end is at -qt(0.975,df), so the total width would
be 2*qt(0.975,df); so (putting this all together) I think you
should have written

  ciw <- 2 * qt(0.975, n-1) * stdev / sqrt(n)

Hoping this helps,
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 09-Jun-08                                       Time: 15:10:40
------------------------------ XFMail ------------------------------