Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Calculation of critical p-, z-, t- and F-values

5 views
Skip to first unread message

schuetz...@t-online.de

unread,
Nov 13, 2007, 3:15:21 AM11/13/07
to
Hallo,

could you give me the formulas for calculating critical values for z,
p, t and F for a significance level (e. g. 99 %)? Or could you say me
where I can find those?

Please excuse my bad English.

Thanks
Daniel

Nasser Abbasi

unread,
Nov 13, 2007, 3:34:10 AM11/13/07
to

<schuetz...@t-online.de> wrote in message
news:1194941721....@v3g2000hsg.googlegroups.com...

Ofcourse one can calculate these from the distribution itself. but it is
easier to use tables. (our text book has them)

You can look at these tables on-line, some are on wikipedia and google book
has it. do google book search on
Elementary Statistics Tables By Henry R. Neave

Here is also a web site that has them on-line
http://www.statsoft.com/textbook/stathome.html

Scroll down the right hand side to the 'distribution tables' button and
click on it.

Nasser


schuetz...@t-online.de

unread,
Nov 13, 2007, 4:36:36 AM11/13/07
to
Yes, surely. But if I have very much populations that should be
compared then it would be better to make values automatically
computed. This would be time-saving.

On 13 Nov., 09:34, "Nasser Abbasi" <n...@12000.org> wrote:
> <schuetz-dan...@t-online.de> wrote in message


>
> news:1194941721....@v3g2000hsg.googlegroups.com...
>
> > Hallo,
>
> > could you give me the formulas for calculating critical values for z,
> > p, t and F for a significance level (e. g. 99 %)? Or could you say me
> > where I can find those?
>
> > Please excuse my bad English.
>
> > Thanks
> > Daniel
>
> Ofcourse one can calculate these from the distribution itself. but it is
> easier to use tables. (our text book has them)
>
> You can look at these tables on-line, some are on wikipedia and google book
> has it. do google book search on
> Elementary Statistics Tables By Henry R. Neave
>

> Here is also a web site that has them on-linehttp://www.statsoft.com/textbook/stathome.html

Nasser Abbasi

unread,
Nov 13, 2007, 5:21:31 AM11/13/07
to

>
> On 13 Nov., 09:34, "Nasser Abbasi" <n...@12000.org> wrote:
>> <schuetz-dan...@t-online.de> wrote in message
>>
>> news:1194941721....@v3g2000hsg.googlegroups.com...
>>
>> > Hallo,
>>
>> > could you give me the formulas for calculating critical values for z,
>> > p, t and F for a significance level (e. g. 99 %)? Or could you say me
>> > where I can find those?
>>
>> > Please excuse my bad English.
>>
>> > Thanks
>> > Daniel
>>

>> Ofcourse one can calculate these from the distribution itself. but it is
>> easier to use tables. (our text book has them)
>>
>> You can look at these tables on-line, some are on wikipedia and google
>> book
>> has it. do google book search on
>> Elementary Statistics Tables By Henry R. Neave
>>
>> Here is also a web site that has them
>> on-linehttp://www.statsoft.com/textbook/stathome.html
>>
>> Scroll down the right hand side to the 'distribution tables' button and
>> click on it.
>>
>> Nasser
>

<schuetz...@t-online.de> wrote in message
news:1194946596....@d55g2000hsg.googlegroups.com...


> Yes, surely. But if I have very much populations that should be
> compared then it would be better to make values automatically
> computed. This would be time-saving.

(please do not top post, makes it harder to follow).

Ok, lets look at this problem a little more carefully.

To make like easier, let look at the Z distribution (or standard), i..e
normal with zero mean, and sigma 1.

For confidence interval say 95% what this means is to find the x value such
that are the area under the pdf from -x to +x is .95 (since the area is the
probability). So the problem is to find x such that the area is some value.

For example, we know that the critical value for Z for 95% is 1.96, this is
because if we integrate from -1.96 to +1.96 the pdf we get .95:

Integrate[PDF[NormalDistribution[0, 1], x], {x, -1.96, 1.96}]
0.9500042092453821

Ok, but what we want is the reverse problem, we want x such as the area is
such and such. Then how to find x in this case?

One could find the indefinite integral of the pdf which will be a function
of x, and then solve for x by setting the integral to .95 or whatever C.I.
one wants.

But the indefinite integral can be a nonlinear form as for example here with
standard pdf:

area = Integrate[PDF[NormalDistribution[0, 1], x], x]

(1/2)*Erf[x/Sqrt[2]]

You see, the integral is expressed in terms of erf() function. not a nice
function to work with.

Using CDF is no help help. The same problem.

So the easy way is to make a TABLE. i.e. pick x, and then find the area for
that x. and this is what these tables do.

For example, here is one line of Mathematica code to generate few critical
values for the normal distribution.
Table[{to, 2*Integrate[PDF[NormalDistribution[0, 1], x], {x, 0, to}]}, {to,
1.9, 2, 0.01}]

{{1.9, 0.9425668801186563}, {1.91, 0.9438667864345321},
{1.92, 0.9451421003498051}, {1.93, 0.9463931620067536},
{1.94, 0.9476203098833256}, {1.95, 0.9488238807243032},
{1.96, 0.9500042094744706}, {1.97, 0.9511616292137779},
{1.98, 0.9522964710944976}, {1.99, 0.9534090642803622},
{2., 0.9544997358876777}}

So, you give me the PDF, I can give you back the tables. I can make the
tables as detailed as you want.
It would be easy to write a function then to do a 'lookup' on these tables
to find the critical value for the C.I. you want.

Nasser


schuetz...@t-online.de

unread,
Nov 13, 2007, 5:44:46 AM11/13/07
to
Tanks. Now I know how to do and so I can do it for myself. Thanks a
lot.

On 13 Nov., 11:21, "Nasser Abbasi" <n...@12000.org> wrote:
> > On 13 Nov., 09:34, "Nasser Abbasi" <n...@12000.org> wrote:
> >> <schuetz-dan...@t-online.de> wrote in message
>
> >>news:1194941721....@v3g2000hsg.googlegroups.com...
>
> >> > Hallo,
>
> >> > could you give me the formulas for calculating critical values for z,
> >> > p, t and F for a significance level (e. g. 99 %)? Or could you say me
> >> > where I can find those?
>
> >> > Please excuse my bad English.
>
> >> > Thanks
> >> > Daniel
>
> >> Ofcourse one can calculate these from the distribution itself. but it is
> >> easier to use tables. (our text book has them)
>
> >> You can look at these tables on-line, some are on wikipedia and google
> >> book
> >> has it. do google book search on
> >> Elementary Statistics Tables By Henry R. Neave
>
> >> Here is also a web site that has them
> >> on-linehttp://www.statsoft.com/textbook/stathome.html
>
> >> Scroll down the right hand side to the 'distribution tables' button and
> >> click on it.
>
> >> Nasser
>
> <schuetz-dan...@t-online.de> wrote in message
>

Art Kendall

unread,
Nov 13, 2007, 8:42:59 AM11/13/07
to
I am not sure what you mean by the critical value of p.
In the olden days we used to use tables, now functions are available in
software. SPSS and PYTHON can call each other. SPSS can also call R.

One way is to write tiny SPSS programs. I can send you a few examples if
you would like them.

SPSS has many cumulative density functions like CDF.t(t,prob) to find
probabilities given the value of the test statistic and the degrees of
freedom.

It also has many inverse density functions like IDF.t(prob,df) to get
critical values.

It also has many pseudorandom value functions like RV.t to generate sets
of values drawn from different distributions if you need them to demo
how a stat works or to test code you write.

The algorithms behind the CDF.*, IDF.*, and RV.* functions are in the
documentation that comes with SPSS.

The algorithms are also available free on line.

go to www.spss.com
click <support>
click <login>
click <login to online tech support> (left pane)
click <login> (main pane)
login as "guest" password "guest" click "ok"
click <statistics documentation> (left pane)
click <algorithms> (main pane)

click <appendix 1> for Z
click <appendix 2> for t
click <appendix 3> for chi**2
click <appendix 4> for F


Art Kendall
Social Research Consultants

Karl Ove Hufthammer

unread,
Nov 13, 2007, 9:36:55 AM11/13/07
to
Nasser Abbasi:

> Integrate[PDF[NormalDistribution[0, 1], x], {x, -1.96, 1.96}]
> 0.9500042092453821

Surely so many digits is not necessary. And actually, the
digits after the second 9 is incorrect. The correct value
should be 0.950004209703559.

--
Karl Ove Hufthammer

Barry W Brown

unread,
Nov 13, 2007, 12:10:46 PM11/13/07
to
On Nov 13, 8:36 am, Karl Ove Hufthammer <Karl.Huftham...@math.uib.no>
wrote:

Our free (open source, no charge) software package Stattab calculates
the values for most common statistical distributions (and a few
uncommon
ones). Windows and Mac executables available as well as source.

http://biostatistics.mdanderson.org/SoftwareDownload

Also, the (free) statistical package R (www.r-project.org) contains
the tables built in; however R has a somewhat steep learning curve.

Barry W. Brown

David Winsemius

unread,
Nov 13, 2007, 10:35:13 PM11/13/07
to
Barry W Brown <brow...@gmail.com> wrote in news:1194973846.237936.54710
@o3g2000hsb.googlegroups.com:

> Our free (open source, no charge) software package Stattab calculates
> the values for most common statistical distributions (and a few
> uncommon ones). Windows and Mac executables available as well as
> source.
>
> http://biostatistics.mdanderson.org/SoftwareDownload

M.D. Anderson Cancer Center has a consistent history of making useful
software and statistical advice available on its website. I salute you.

> Also, the (free) statistical package R (www.r-project.org) contains
> the tables built in; however R has a somewhat steep learning curve.

All one needs to do in R is execute very simple procedures. If you cannot
remember all the distribution functions, all you need to do is type:
help.search("distribution")

Typing qnorm(0.975) will produce the desired quantile of the inverse
Normal. The OP desired a method for "critical values for z,
p, t and F for a significance level (e. g. 99 %)". I don't know what he
meant by "p" but the corresponding values to the t from qt(<quantile>,
<degrees of freedom>) and for the F distribution would be obtained by
typing qf(<quantile>,<df1>,<df2> ).

> qt(0.975,60)
[1] 2.000298
> qt(0.975,120)

[1] 1.979930
# if you wanted the critical values for 10 through 60 df in steps of 10
this would work:

> qt(0.975,seq(10,60,10))
[1] 2.228139 2.085963 2.042272 2.021075 2.008559 2.000298

> qt(0.975,Inf)
[1] 1.959964
> qnorm(0.975)
[1] 1.959964

You would find that qf(2*p - 1, 1, df)) was identical to qt(p, df)^2).

Not very steep if you ask me. Installation is simple enough for an old doc
to do it without much pain ever since version 1.8.

--
David Winsemius, MD, MPH

Nasser Abbasi

unread,
Nov 14, 2007, 4:34:10 AM11/14/07
to
Hello David;

I thought I try the Mathematica equivalence commands to your R commands.

I just started to learn R as well. But I find that with Mathematica, I can
also do analytical analysis, and not just numerical, which can be very
useful to me, which is not so easily done in R. But R seems to be quite good
in statistics and has many more functions in statistics than Mathematica (as
can be expected :)

Below I show the Mathematrica commands below your R commands. I was able to
find Mathematica command equivalent to each one of the R commands.

I am using version 6 (new version of Mathematica) where they have added many
new statistics functions to the system. I use the student version of
Mathematica (about $130 US)

"David Winsemius" <doe_...@comcast.n0T> wrote in message
news:Xns99E7E5D6B...@216.196.97.136...

> All one needs to do in R is execute very simple procedures. If you cannot
> remember all the distribution functions, all you need to do is type:
> help.search("distribution")
>
> Typing qnorm(0.975) will produce the desired quantile of the inverse
> Normal.

Quantile[NormalDistribution[0, 1], 975/1000]
Sqrt[2]*InverseErf[19/20]

N[%] <----- This say to convert the above output to a number
1.9599639845400538

>The OP desired a method for "critical values for z,
> p, t and F for a significance level (e. g. 99 %)". I don't know what he
> meant by "p" but the corresponding values to the t from qt(<quantile>,
> <degrees of freedom>) and for the F distribution would be obtained by
> typing qf(<quantile>,<df1>,<df2> ).
>
>> qt(0.975,60)
> [1] 2.000298

Quantile[StudentTDistribution[60], 975/1000]
2*Sqrt[15*(-1 + 1/InverseBetaRegularized[1, -(19/20), 30, 1/2])]

N[%]
2.0002978220142507

>> qt(0.975,120)
>
> [1] 1.979930

Quantile[StudentTDistribution[120], 975/1000]
2*Sqrt[30*(-1 + 1/InverseBetaRegularized[1, -(19/20), 60, 1/2])]

N[%]
1.9799304050824413

> # if you wanted the critical values for 10 through 60 df in steps of 10
> this would work:
>
>> qt(0.975,seq(10,60,10))
> [1] 2.228139 2.085963 2.042272 2.021075 2.008559 2.000298
>

Table[Quantile[StudentTDistribution[k], 0.975], {k, 10, 60, 10}]
{2.2281388519862735, 2.0859634472658626, 2.042272456301236,
2.0210753903062715, 2.008559112100758, 2.0002978220142507}

>> qt(0.975,Inf)
> [1] 1.959964

With Infinity for degrees of Freedom, Mathematica does not evaluate it, but
I could put large values ok
(Might be some limiting issue involved. I do not know how R does it).

Quantile[StudentTDistribution[100000000], 0.975]
1.959964074411019

>
> You would find that qf(2*p - 1, 1, df)) was identical to qt(p, df)^2).
>

The above is valid when assuming 1-2p<0 :

r1 = Quantile[StudentTDistribution[df], p];
r2 = Quantile[FRatioDistribution[1, df], 2*p - 1];
Assuming[1 - 2*p < 0, FullSimplify[ r1^2 - r2] ]

Out[154]= 0

> Not very steep if you ask me. Installation is simple enough for an old doc
> to do it without much pain ever since version 1.8.
>
> --
> David Winsemius, MD, MPH
>

Nasser


iandj...@aol.com

unread,
Nov 14, 2007, 6:04:32 AM11/14/07
to
On 14 Nov, 09:34, "Nasser Abbasi" <n...@12000.org> wrote:
> Hello David;
>
> I thought I try the Mathematica equivalence commands to your R commands.
>
> I just started to learn R as well. But I find that with Mathematica, I can
> also do analytical analysis, and not just numerical, which can be very
> useful to me, which is not so easily done in R. But R seems to be quite good
> in statistics and has many more functions in statistics than Mathematica (as
> can be expected :)
>
> Below I show the Mathematrica commands below your R commands. I was able to
> find Mathematica command equivalent to each one of the R commands.
>
> I am using version 6 (new version of Mathematica) where they have added many
> new statistics functions to the system. I use the student version of
> Mathematica (about $130 US)
>
> "David Winsemius" <doe_s...@comcast.n0T> wrote in message

I have never used Mathematica, so I do not understand all of your
notes on its use.

I gather when you ask for

Quantile[StudentTDistribution[120], 975/1000]

it returns 2*Sqrt[30*(-1 + 1/InverseBetaRegularized[1, -(19/20), 60,
1/2])] as the symbolic equivalent of it and then evaluates this
expression and outputs it as 1.9799304050824413. You can control the
number of digits in the output value.

Can you control the accuracy of the calculation? I am just curious
because none of the values returned are particularly accurate and if
Quantile[StudentTDistribution[100000000], 0.975] returns
1.959964074411019 then it is surprisingly inaccurate (relative error
of about 3e-8).

Ian Smith

Nasser Abbasi

unread,
Nov 14, 2007, 6:16:23 AM11/14/07
to

<iandj...@aol.com> wrote in message
news:1195038272.5...@19g2000hsx.googlegroups.com...

>
> I have never used Mathematica, so I do not understand all of your
> notes on its use.
>
> I gather when you ask for
>
> Quantile[StudentTDistribution[120], 975/1000]
>
> it returns 2*Sqrt[30*(-1 + 1/InverseBetaRegularized[1, -(19/20), 60,
> 1/2])] as the symbolic equivalent of it and then evaluates this
> expression and outputs it as 1.9799304050824413.

Mathematica does everthing when possible in symbolic form (numbers are kept
in rational form, etc..) unless there is a numeric value in the expression
(i.e. decimal). So, yes, all the above calculations are done analytically,
then at the end a user can ask for the numerical value using the function
N[].

>
> Can you control the accuracy of the calculation?

Yes.

>I am just curious
> because none of the values returned are particularly accurate and if
> Quantile[StudentTDistribution[100000000], 0.975] returns
> 1.959964074411019 then it is surprisingly inaccurate (relative error
> of about 3e-8).
>

Tis is the actual Quantile expression:

Quantile[StudentTDistribution[100000000], 975/1000]

10000*Sqrt[-1 + 1/InverseBetaRegularized[1, -(19/20), 50000000, 1/2]]

I can now Ask Mathematica to give me the numerical value of the above to 50
decimals for example

N[%, 50]
1.9599640082627668207600863127853028493573117315681873087708854414654`50.

In my last message I was using the default settings. Is the above asnwer
accurate enough now?

Nasser


Karl Ove Hufthammer

unread,
Nov 14, 2007, 6:40:24 AM11/14/07
to
Nasser Abbasi:

>>I am just curious
>> because none of the values returned are particularly accurate and if
>> Quantile[StudentTDistribution[100000000], 0.975] returns
>> 1.959964074411019 then it is surprisingly inaccurate (relative error
>> of about 3e-8).
>

> I can now Ask Mathematica to give me the numerical value of the above to
> 50 decimals for example
>
> N[%, 50]
> 1.9599640082627668207600863127853028493573117315681873087708854414654`50.
>
> In my last message I was using the default settings. Is the above asnwer
> accurate enough now?

This looks much more accurate, at least. But it's worrying that Mathematica
by default prints many more digits than its calculations are accurate for.

--
Karl Ove Hufthammer

iandj...@aol.com

unread,
Nov 14, 2007, 7:30:23 AM11/14/07
to
On 14 Nov, 11:16, "Nasser Abbasi" <n...@12000.org> wrote:
> <iandjmsm...@aol.com> wrote in message

I've got it. The problem was you asked for
Quantile[StudentTDistribution[100000000], 0.975] and the 0.975 causes
it to work to machine precision. The method of calculation is very
poor and hence only delivers a results with relative error of 3e-8.

You can ask for exact calculations with


Quantile[StudentTDistribution[100000000], 975/1000]

According to http://reference.wolfram.com/mathematica/ref/N.html?q=N&lang=en
N[%, n] attempts to give a result with n-digit precision.

It is not clear what is stopping it giving rather than attempting to
give a result with n-digit precision. The + operation is going to lose
about 8 figures so InverseBetaRegularized[1, -(19/20), 50000000, 1/2]
must be calculated to about 58 digits to give 50 digit accuracy. I am
still lost as to why it has printed out 68 digits. Maybe that is how
many figures it did the calculations to.

Ian Smith

Nasser Abbasi

unread,
Nov 14, 2007, 8:58:47 AM11/14/07
to

<iandj...@aol.com> wrote in message
news:1195043423.4...@o3g2000hsb.googlegroups.com...

> I've got it. The problem was you asked for
> Quantile[StudentTDistribution[100000000], 0.975] and the 0.975 causes
> it to work to machine precision. The method of calculation is very
> poor and hence only delivers a results with relative error of 3e-8.

That is correct. As I said, when there is a 'numeric' value in the
expression, this will force the computation to be done in non-symbolic.

>
> You can ask for exact calculations with
> Quantile[StudentTDistribution[100000000], 975/1000]
>

Yes.

> According to
> http://reference.wolfram.com/mathematica/ref/N.html?q=N&lang=en
> N[%, n] attempts to give a result with n-digit precision.
>

Yes.

> It is not clear what is stopping it giving rather than attempting to
> give a result with n-digit precision. The + operation is going to lose
> about 8 figures so InverseBetaRegularized[1, -(19/20), 50000000, 1/2]
> must be calculated to about 58 digits to give 50 digit accuracy. I am
> still lost as to why it has printed out 68 digits. Maybe that is how
> many figures it did the calculations to.
>
> Ian Smith
>

Well, Mathematica floating point model is a little hard for me to comprehend
without spending more time on it, and I am no expert at this aspect of
Mathematica, may be a Mathematica expert can comment on this. I know it
sometimes uses "significance arithmetic" and is implemented in software.

I copied a reply I wrote sometime ago in another newsgroup which has a link
to a detailed paper about Mathematica floating point model if anyone is
interested in some reading over their coffee break :)

"There is this paper that goes into all the details you ever wanted to know
about Mathematica handling of floating point arithmetic (LONG URL)

http://www.sciencedirect.com/science?_ob=ArticleURL&_udi=B6W8D-4FFGJ35-1&_coverDate=07%2F31%2F2005&_alid=458876682&_rdoc=1&_fmt=&_orig=search&_qd=1&_cdi=6652&_sort=d&view=c&_acct=C000050221&_version=1&_urlVersion=0&_userid=10&md5=d64b2c0097f2daf6c879b7f57ad45ab2

"M. Sofroniou and G. Spaletta. Precise numerical computation. The Journal of
Logic and Algebraic Programming 64:113-134. 2005."

There is a 1999 version of the paper that anyone can download for free ( I
am not sure what is the difference):
http://citeseer.ist.psu.edu/sofroniou99precise.html

Any way, I am trying to understand it. But related to significant
arithmetic use in Mathematica, the paper says that is not done all the time,
here is the quote:

"Indeed Mathematica uses fixed-precision arithmetic instead of significance
arithmetic in its large scale numerical routines, such as in linear algebra
and the numerical solution of differential equations; the error bounds
provided by these numerical methods are well studied and provide much
tighter bounds than those based on assumptions of independent error
accumulation."

There is also standard way to tell Mathematica to use hardware floating
point arithmatics as well if you want by setting some global options at the
start of the session.

Nasser "

Nasser


0 new messages