2014-02-10 4 views
1

을 측정하여 여러 변수를 평가하는 방법은 다음과 같은 질문이 : 내 데이터를 다음과 같습니다SPSS - 반복이

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 

내가 모든 경우를위한 활동의 ​​양을 평가하고 변수를 만들려면을 " 병법". Act1이 Act1, ACT2, ACT3 및 Act4 중에서 가장 높은 경우 "전략"은 "1"과 같아야합니다. Act2가 더 높으면 "전략"은 "2"와 같아야합니다. 동일한 변수 (이 예제에서는 3 번)를 반복해서 측정 한 이후로 동일한 UserId를 사용합니다. SPSS 구문 코드는 어떻게 생겼습니까? 이번 경우에 사용자가 실험에 사용한 전략을 정의하기 위해 모든 사례 (예 : UserId가 동일하더라도)를 통해 루프를 만들 수 있습니까? 아이디어?

감사합니다, 보다도, 유진

+0

난 당신이 순위를 어떻게 귀하의 설명에서 꽤 확신 해요. 따라서 'UserID = 1, Act2 = 3 + 5 + 3 = 11'과 같이 행의 합이 가장 크기 때문에 'UserId'1의 경우 'Act2'가 가장 높습니다. 또한 대부분의 순위 전략은 동점을 다루는 방법을 지정해야합니다. –

답변

0

나는 내 자신의 문제에 대한 해결책을 찾을 것으로 보인다. 다음과 같이 보입니다.

/*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. 

이것은 내 해결책이었고 작동하는 것 같습니다.

최저

, 오이겐