<?xml version="1.0" encoding="utf-8"?><!DOCTYPE article  PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'  'http://www.docbook.org/xml/4.4/docbookx.dtd'><article><articleinfo><title>FAQ/pvalues</title><revhistory><revision><revnumber>9</revnumber><date>2013-03-08 10:17:16</date><authorinitials>localhost</authorinitials><revremark>converted to 1.6 markup</revremark></revision><revision><revnumber>8</revnumber><date>2007-02-01 16:54:43</date><authorinitials>PeterWatson</authorinitials></revision><revision><revnumber>7</revnumber><date>2007-02-01 16:54:20</date><authorinitials>PeterWatson</authorinitials></revision><revision><revnumber>6</revnumber><date>2007-02-01 16:54:07</date><authorinitials>PeterWatson</authorinitials></revision><revision><revnumber>5</revnumber><date>2007-02-01 16:29:32</date><authorinitials>PeterWatson</authorinitials></revision><revision><revnumber>4</revnumber><date>2007-02-01 16:23:21</date><authorinitials>PeterWatson</authorinitials></revision><revision><revnumber>3</revnumber><date>2007-01-25 16:07:26</date><authorinitials>PeterWatson</authorinitials></revision><revision><revnumber>2</revnumber><date>2006-08-16 14:38:48</date><authorinitials>PeterWatson</authorinitials></revision><revision><revnumber>1</revnumber><date>2006-08-03 14:35:07</date><authorinitials>PeterWatson</authorinitials></revision></revhistory></articleinfo><section><title>Obtaining p-values in SPSS</title><para>The SPSS syntax below gives p-values for four distributions. These can also be done using a <ulink url="https://lsr-wiki-02.mrc-cbu.cam.ac.uk/statswiki/FAQ/pvalues/statswiki/FAQ/pvalues?action=AttachFile&amp;do=get&amp;target=pvals.xls">spreadsheet</ulink>.  </para><para>[CUT AND PASTE INTO A SPSS SYNTAX WINDOW, SELECT ALL AND RUN; AMEND DATA INPUT AS REQUIRED] </para><screen><![CDATA[* 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 (.)
*
]]><![CDATA[
set errors=none.
data list free
/ type (a1)  cv (f10.5) df (f10.5) df2 (f10.5).
]]><![CDATA[
begin data  
t -1.645 5 . 
z 2.58 . .
f 5 10 34 
c 3.84 1 .
end data.
]]><![CDATA[
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.
]]><![CDATA[
define !pvalz ( !pos !charend('/')).
compute pout=pout+2*(1-cdfnorm(abs(!1)))*(type='z').
!enddefine.
]]><![CDATA[
define !pvalf ( !pos !charend('/')
                 / !pos !tokens(1)
                 / !pos !tokens(1) ).
compute pout=pout+(1-cdf.f(!1,!2,!3))*(type='f').
!enddefine.
]]><![CDATA[
define !pvalc ( !pos !charend('/')
                 / !pos !tokens(1)).
compute pout=pout+(1-cdf.chisq(!1,!2))*(type='c').
!enddefine.
]]><![CDATA[
]]><![CDATA[
]]><![CDATA[
]]><![CDATA[
]]><![CDATA[
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.
]]><![CDATA[
!pvalt  cv/ df.
!pvalz  cv/ .
!pvalf  cv/ df df2.
!pvalc  cv/ df .
]]><![CDATA[
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".]]></screen></section></article>