FAQ/pvalues - CBU statistics Wiki
location: FAQ / pvalues

## Obtaining p-values in SPSS

The SPSS syntax below gives p-values for four distributions. These can also be done using a spreadsheet.

[CUT AND PASTE INTO A SPSS SYNTAX WINDOW, SELECT ALL AND RUN; AMEND DATA INPUT AS REQUIRED]

```* gives p-values for z, t, F and chi-square distributions
*
*
* example data set given below
*
* enter your own data in 4 columns as follows:
*
* distribution type: t=T distribution; z=Standard Normal; f=F distribution;
* c= chi-square distribution,
*
* critical value (cv),
*
* degrees of freedom (df, for the t,F and chi-square distributions),
*
* second degree of freedom (for F distribution only)
*
* non-applicable parameters should be denoted by a full stop (.)
*

set errors=none.
data list free
/ type (a1)  cv (f10.5) df (f10.5) df2 (f10.5).

begin data
t -1.645 5 .
z 2.58 . .
f 5 10 34
c 3.84 1 .
end data.

define !pvalt ( !pos !charend('/')
/ !pos !tokens(1)).
compute pout=2*(1-cdf.t(abs(!1),!2))*(type='t').
compute cv=!1.
compute df=!2.
!enddefine.

define !pvalz ( !pos !charend('/')).
compute pout=pout+2*(1-cdfnorm(abs(!1)))*(type='z').
!enddefine.

define !pvalf ( !pos !charend('/')
/ !pos !tokens(1)
/ !pos !tokens(1) ).
compute pout=pout+(1-cdf.f(!1,!2,!3))*(type='f').
!enddefine.

define !pvalc ( !pos !charend('/')
/ !pos !tokens(1)).
compute pout=pout+(1-cdf.chisq(!1,!2))*(type='c').
!enddefine.

define !pval (!pos !tokens(1)
/ !pos !charend('/')
/ !pos !tokens(1)
/ !pos !tokens(1)).
!if (!1 !eq 't') !then.
use all.
!pvalt  !2/ !3.
!ifend.
!if (!1 !eq 'z') !then.
use all.
!pvalz   !2/ .
!ifend.
!if (!1 !eq 'f') !then.
use all.
!pvalf  !2/ !3 !4.
!ifend.
!if (!1 !eq 'c') !then.
use all.
!pvalc  !2/ !3.
!ifend.
!enddefine.

!pvalt  cv/ df.
!pvalz  cv/ .
!pvalf  cv/ df df2.
!pvalc  cv/ df .

formats type (a1) cv df df2 pout (f11.8).
variable labels type 'Distribution' /cv 'Critical Value' /df 'df' /df2 'df2 for F' / pout '2-sided p-value'.
report format=list automatic align(center)
/variables=type cv df df2 pout
/title "Two-sided P-values for z, t, F and chi-square critical values".```

None: FAQ/pvalues (last edited 2013-03-08 10:17:16 by localhost)