1
votes

I have 2 variables, one for raw p-values and another for adjusted p-values. I need to compute a new variable based on the values of these two variables. What I need to do isn't too complicated, but I have a hard time doing it in SPSS because I can't figure out how I can reference a particular row for an existing variable in SPSS syntax.

The first column lists raw p-values in ascending order. The next column lists adjusted p-values, but these adjusted p-values are still incomplete. I need to compare two adjacent p-values in the adjusted p-values column (e.g., row 1 and 2, row 2 and 3, row 3 and 4, and so forth), and take the p-values whichever is smaller in each of these comparisons and enter those p-values into the following column as values for a new variable.

However, that's not the end of the story. One more condition has to be met. That is, the new p-values have to be in the same order as the raw p-values. However, I cannot ensure this if I start the comparisons from the top row. You can see that (i') is greater than (h') and (g'), and (d') is greater than (c'), (b'), and (a') in the example below (picture).

In order to solve this issue, I would need to start the comparison of the adjusted p-values from the bottom. In addition, I would need to compare the adjusted p-values to the new p-values of one row below. One exception is that I can simply use the value of (a) as the value of (a') since the value of (a) should always be the greatest of all the p-values as a rule. Then, for (b') , I need to compare (b) and (a') and enter whichever is smaller as (b'). For (c'), I need to compare (c) and (b') and enter whichever is smaller as (c'), and so forth. By doing this way, (d') would be 0.911 and (i') would be 0.017.

Sorry for this long post, but I would really appreciate if I can get some help to do this task in SPSS.

Thank you in advance for your help.

Raw p-values | Adjusted p-values (Temporal)| New p-values (Final)
-------------|-----------------------------|---------------------
0.002        | 0.030 (i)                   | 0.025 (i')
0.003        | 0.025 (h)                   | 0.017 (h')
0.004        | 0.017 (g)                   | 0.017 (g')
0.005        | 0.028 (f)                   | 0.028 (f')
0.023        | 0.068 (e)                   | 0.068 (e')
0.450        | 1.061 (d)                   | 1.061 (d')
0.544        | 1.145 (c)                   | 0.911 (c')
0.850        | 0.911 (b)                   | 0.911 (b') 
0.974        | 0.974 (a)                   | 0.974 (a')
2

2 Answers

0
votes

To get you started, here are a few tools that can help you with this task:

The LAG function
you can compare values in this line and the previous one, for example, the following will compare the Pval in each line to the one in the previous one, and put the smaller of the two in the NewPval:

compute NewPVal=min(Pval, lag(Pval)).

If you want to do the same process only start from the bottom, you can easily sort your data in reverse order and do the same.

CREATE + LEAD
if you want to make comparisons to the next line instead of the previous line, you should first create a "lead" variable and then compare to it.
for example, the following syntax will create a new variable that for each line contains the value of Pval in the next line, and then chooses the smaller of the two for the NewPval:

create /LeadPval=LEAD(Pval 1).  
compute NewPVal=min(Pval, LeadPval).

Using case numbers
You can use case numbers (line numbers) in calculations and in conditions. For example, the following syntax will let you make different calculations in the first line and the following ones:

if $casenum=1 NewPval=Pval.
if $casenum>1 NewPVal=min(Pval, lag(Pval)).
0
votes

Another tool that may be convenient is the SHIFT VALUES command. It can move one or more columns of data either forward or backward.

I wonder whether the purpose of this has to do with adjusting p values for multiple testing corrections as with Benjamin-Hochberg FDR or others similar. If that is the case, you might find the STATS PADJUST (Analyze > Descriptives > Calculate adjusted p values) extension command useful. It offers six adjustment methods. You can install it from the Utilities (pre-V24) or Extensions (V24+) menu.