SPSS で次のような数式をプログラムする最良の方法は何ですか: l(x)=l(x-1)-d(x-1) ここで、l(x) は年齢グループ x で危険にさらされている人の総数です。d(x) は、年齢グループ x の総死亡者数です。したがって、d(x-1) は年齢グループ x-1 での総死亡数です。ありがとう
1 に答える
1
あなたの質問を完全に理解しているかどうかはわかりませんが、SPSS の LAG 機能を活用できるかもしれません。
アイデアを得るために、以下の構文をチェックしてください。
*--------------------------------------------------------------------------------------------------.
* Lets create some fake data.
*--------------------------------------------------------------------------------------------------.
DATA LIST LIST (",") / id risk death.
BEGIN DATA
1, 274, 123
1, 123, 34
1, 1235, 23
2, 3456, 231
2, 1897, 12
END DATA.
*--------------------------------------------------------------------------------------------------.
* Create a basic lag to get the previous record's values.
*--------------------------------------------------------------------------------------------------.
COMPUTE risk.lag1 = LAG(risk, 1).
COMPUTE death.lag1 = LAG(death, 1).
*--------------------------------------------------------------------------------------------------.
* Create a lag if group dependent -- assumes your cases are in the order you want
* Only executes if the previous records value of ID is the same as the current record.
*--------------------------------------------------------------------------------------------------.
IF (id = LAG(id,1)) risk.lag2 = lag(risk,1).
IF (id=LAG(id,1)) death.lag2 = lag(death,1).
EXECUTE.
*--------------------------------------------------------------------------------------------------.
* ....And the data.....
*--------------------------------------------------------------------------------------------------.
LIST CASES.
次のデータ計算を提供します....
id risk death risk.lag1 death.lag1 risk.lag2 death.lag2
1 274 123 . . . .
1 123 34 274 123 274 123
1 1235 23 123 34 123 34
2 3456 231 1235 23 . .
2 1897 12 3456 231 3456 231
Number of cases read: 5 Number of cases listed: 5
于 2010-11-09T05:39:06.237 に答える