Ranking SPSS-如何通过重复测量对多个变量进行排序
我有以下问题:我的数据如下所示:Ranking SPSS-如何通过重复测量对多个变量进行排序,ranking,spss,repeat,Ranking,Spss,Repeat,我有以下问题:我的数据如下所示: UserId |Act1 |Act2 |Act3 |Act4 1 | 2 | 3 | 2 | 2 1 | 2 | 5 | 1 | 0 1 | 0 | 3 | 3 | 0 2 | 2 | 2 | 3 | 0 2 | 2 | 2 | 2 | 2 2 | 1 | 2 | 1 | 5 ... 999 | 1 | 2 | 2
UserId |Act1 |Act2 |Act3 |Act4
1 | 2 | 3 | 2 | 2
1 | 2 | 5 | 1 | 0
1 | 0 | 3 | 3 | 0
2 | 2 | 2 | 3 | 0
2 | 2 | 2 | 2 | 2
2 | 1 | 2 | 1 | 5
...
999 | 1 | 2 | 2 | 3
/*Computing strategy*/
/*Calculating dominant action*/
LOOP #i=1 TO 999. /*Assuming I have 999 cases.
/* Calculating the biggest value among activities.
VECTOR #act(4). /* This is a temporary array variable.
COMPUTE #act(1) = Act1.
COMPUTE #act(2) = Act2.
COMPUTE #act(3) = Act3.
COMPUTE #act(4) = Act4.
/*Bubble sorting the numbers.
LOOP #j=1 to 3.
LOOP #k=#j+1 TO 4.
DO IF (#act(#k) >= #act(#j)).
COMPUTE #temp = #k.
COMPUTE #act(#j) = #act(#k).
COMPUTE #act(#k) = #temp.
END IF.
END LOOP.
/*At this point we have the biggest value in the first position of the array variable, i.e. "#act(1)".
/*Here I check whether the specific action is equal to the highest score.
VECTOR #strat(4).
COMPUTE #strat(1) = Act1.
COMPUTE #strat(2) = Act2.
COMPUTE #strat(3) = Act3.
COMPUTE #strat(4) = Act4.
/*Here I create 2 temporary variables to fix the result.
COMPUTE #temp1 = 0.
COMPUTE #temp2 = 0.
/*Next step is hard to explain, but: firstly, an participant could use two strategies, which is ok; secondly, if a participant uses more than 2 strategies, I assume he was acting not strategicaly (it comes from my research design, it may not fit to yours; e.g. Act1 = 0, Act2 = 0, Act3 = 0, Act4=0; or all actions are euqal to 3).
LOOP #m=1 TO 4.
DO IF (#strat(#m) = #act(1)).
DO IF (#temp1 = 0).
COMPUTE #temp1 = #m. /* If the variable has the highest value it is assumed to be a strategy; the value is stored in the variable "#temp1".
ELSE.
DO IF (#temp2=0). /*if the first strtegy is assigned, then the second temporry variable is used, "#temp2".
COMPUTE #temp2 = #m.
ELSE.
COMPUTE #temp1 = 0. /*If all more than 2 variables have "highest" score, than no strategy was played; both temporary variables are defined as 0.
COMPUTE #temp2 = 0.
END IF.
END IF.
END IF.
END LOOP.
/*And finally we create variables which are stored in our dataset and prescribe them values of our temporary variables.
COMPUTE DominantStrategy1 = #temp1.
COMPUTE DominantStrategy2 = #temp2.
END LOOP.
END CASE. /*Making the same with the next case.
END LOOP.
EXECUTE.
我想对每个案例的活动量进行排名,并创建一个变量“策略”。如果Act1是Act1、ACT2、ACT3和Act4中的最高值,则“策略”应等于“1”。如果Act2较高,则“策略”应等于“2”,依此类推。我有相同的用户ID,因为我重复测量了相同的变量(在本例中为3次)。
SPSS语法代码应该是什么样子?我能在每个案例中循环(即使UserId是相同的)来定义我的用户在这次实验中使用的策略吗?想法
谢谢,
最好的,
尤金我似乎找到了解决我自己问题的办法。看起来是这样的:
UserId |Act1 |Act2 |Act3 |Act4
1 | 2 | 3 | 2 | 2
1 | 2 | 5 | 1 | 0
1 | 0 | 3 | 3 | 0
2 | 2 | 2 | 3 | 0
2 | 2 | 2 | 2 | 2
2 | 1 | 2 | 1 | 5
...
999 | 1 | 2 | 2 | 3
/*Computing strategy*/
/*Calculating dominant action*/
LOOP #i=1 TO 999. /*Assuming I have 999 cases.
/* Calculating the biggest value among activities.
VECTOR #act(4). /* This is a temporary array variable.
COMPUTE #act(1) = Act1.
COMPUTE #act(2) = Act2.
COMPUTE #act(3) = Act3.
COMPUTE #act(4) = Act4.
/*Bubble sorting the numbers.
LOOP #j=1 to 3.
LOOP #k=#j+1 TO 4.
DO IF (#act(#k) >= #act(#j)).
COMPUTE #temp = #k.
COMPUTE #act(#j) = #act(#k).
COMPUTE #act(#k) = #temp.
END IF.
END LOOP.
/*At this point we have the biggest value in the first position of the array variable, i.e. "#act(1)".
/*Here I check whether the specific action is equal to the highest score.
VECTOR #strat(4).
COMPUTE #strat(1) = Act1.
COMPUTE #strat(2) = Act2.
COMPUTE #strat(3) = Act3.
COMPUTE #strat(4) = Act4.
/*Here I create 2 temporary variables to fix the result.
COMPUTE #temp1 = 0.
COMPUTE #temp2 = 0.
/*Next step is hard to explain, but: firstly, an participant could use two strategies, which is ok; secondly, if a participant uses more than 2 strategies, I assume he was acting not strategicaly (it comes from my research design, it may not fit to yours; e.g. Act1 = 0, Act2 = 0, Act3 = 0, Act4=0; or all actions are euqal to 3).
LOOP #m=1 TO 4.
DO IF (#strat(#m) = #act(1)).
DO IF (#temp1 = 0).
COMPUTE #temp1 = #m. /* If the variable has the highest value it is assumed to be a strategy; the value is stored in the variable "#temp1".
ELSE.
DO IF (#temp2=0). /*if the first strtegy is assigned, then the second temporry variable is used, "#temp2".
COMPUTE #temp2 = #m.
ELSE.
COMPUTE #temp1 = 0. /*If all more than 2 variables have "highest" score, than no strategy was played; both temporary variables are defined as 0.
COMPUTE #temp2 = 0.
END IF.
END IF.
END IF.
END LOOP.
/*And finally we create variables which are stored in our dataset and prescribe them values of our temporary variables.
COMPUTE DominantStrategy1 = #temp1.
COMPUTE DominantStrategy2 = #temp2.
END LOOP.
END CASE. /*Making the same with the next case.
END LOOP.
EXECUTE.
这是我的解决方案,似乎有效
最好的,
Eugen从你的描述中,我不太确定你是如何排名的。因此对于
UserId
1是Act2
最高的,因为行的总和最大(例如对于UserId=1,Act2=3+5+3=11
)?此外,大多数排名策略将需要指定如何处理关系。