Statistics  @ eMaestro

Wednesday, November 17, 2004

SAS code

http://www.ph.ucla.edu/class/biostat/200a/sascode/statdist.html

SAS Code for p-values and quantiles
(courtesy of Hector Lemus)
To find p-values
1. t-distribution PROBT(x,df)
The PROBT function returns the probability that an observation from a Student's t distribution, with degrees of freedom df, is less than or equal to x. The significance level of a two-tailed t test is given by p=(1-probt(abs(x),df))*2;
2. F-distribution PROBF(x,ndf,ddf)
The PROBF function returns the probability that an observation from an F distribution, with numerator degrees of freedom ndf and denominator degrees of freedom ddf, is less than or equal to x. The PROBF function accepts noninteger degrees of freedom parameters ndf and ddf. The significance level for an F test statistic is given by p=1-probf(x,ndf,ddf);
3. Normal distribution PROBNORM(x)
The PROBNORM function returns the probability that an observation from the standard normal distribution is less than or equal to x. The significance level of a two-tailed z test is given by p=(1-probnorm(abs(x)))*2; Example: data pvalues;
pt=2*(1-probt(3.04,118));
pf=1-probf(9.24,1,118);
run;
proc print data=pvalues;
run;
Obs pt pf
1 0.002914602 0.002916962
To find quantiles
1. t-distribution TINV(p,df)
The TINV function returns the pth quantile from the Student's t distribution with degrees of freedom df. The probability that an observation from a t distribution is less than or equal to the returned quantile is p.
2. F-distribution FINV(p,ndf,ddf)
The FINV function returns the pth quantile from the F distribution with numerator degrees of freedom ndf and denominator degrees of freedom ddf. The probability that an observation from the F distribution is less than the quantile is p.
3. Normal distribution PROBIT(p)
The PROBIT function returns the pth quantile from the standard normal distribution. The probability that an observation from the standard normal distribution is less than or equal to the returned quantile is p. Example: data quantiles;
t=tinv(0.995,118);
f=finv(0.95,2,118); /* this one might be useful for 2.13... */
z=probit(0.975);
run;
proc print data=quantiles;
run;
Obs t f z
1 2.87844 3.55456 1.95996
Back to main page.

SAS links

http://www.psych.yorku.ca/lab/sas/index.htm#macros

Applied Linear Models

5th Ed. http://apps.csom.umn.edu/Nachtsheim/5th/

4th Ed. http://apps.csom.umn.edu/nachtsheim/