Marco Wong
Marco Wong

Reputation: 1

Calculating p-value by hand from Stata table

I want to ask a question on how to compute the p-value without a t-stat table, just by looking at the table, like on the first page of the pdf in the following link http://faculty.arts.ubc.ca/dwhistler/326UBC/stataHILL.pdf . Like if I don't know the value 0.062, how can I know it is 0.062 by looking at other information from the table?

Upvotes: 0

Views: 16477

Answers (2)

dimitriy
dimitriy

Reputation: 9470

You need to use the ttail() function, which returns the reverse cumulative Student's t distribution, aka the probability T > t:

display ttail(38,abs(_b[_cons]/_se[_cons]))*2

The first argument, 38, is the degrees of freedom (sample size less number of parameters), while the second, 1.92, is the absolute value of the coefficient of interest divided by its standard error, or the t-stat. The factor of two comes from the fact that Stata is doing a two-tailed test. You can also use the stored DoF with

display ttail(e(df_r),abs(_b[_cons]/_se[_cons]))*2

You can also do the integration of the t density by "hand" using Adrian Mander's integrate:

ssc install integrate
integrate, f(tden(38,x)) l(-1.92) u(1.92)

This gives you 0.93761229, but you want Pr(T>|t|), which is 1-0.93761229=0.06238771.

Upvotes: 1

rajah9
rajah9

Reputation: 12339

If you look at many statistics textbooks, you will find a table called the Z-table which will give you the probability that Z is beyond your test statistic. The table is actually a cumulative distribution function of the normal curve.

When people went to school with 4-function calculators, one or more of the questions on the statistics test would include a copy of this Z-table, and the dear students would have to interpolate columns of numbers to find the p-value. In your example, you would see the test statistic between .06 and .07 and those fingers would tap out that it was closer to .06 and do a linear interpolation to come up with .062.

Today, the p-value is something that Stata or SAS will calculate for you.

Here is another SO question that may be of interest: How do I calculate a p-value if I have the t-statistic and d.f. (in Perl)?

Here is a basic page on how to determine p-value "by hand": http://www.dummies.com/how-to/content/how-to-determine-a-pvalue-when-testing-a-null-hypo.html

Here is how you can determine p-value using Excel: http://ms-office.wonderhowto.com/how-to/find-p-value-with-excel-346366/

===EDIT===

My Stata text ("Microeconometrics using Stata", Revised Ed, Cameron & Trivedi) says the following on p. 402.

* p-values for t(30), F(1,30), Z, and chi(1) at y=2
. scalar y=2
. scalar p_t30 = 2 * ttail(30,y)
. scalar p_f1and30 = Ftail(1,30,y^2)
. scalar p_z = 2 * (1 - normal(y))
. scalar p_chi1 = chi2tail(1,y^2)
. display "p-values" " t(30)=" %7.4f p_t30
p-values t(30) = 0.0546

Upvotes: 0

Related Questions