## Classification of predicted value on logistic regression model

Dear Communities:

Greetings all!

I have data in the following format.

Patient_ID  status  level  prediction

165201         0        0        0.0090204072

165201         0        1        0.4682205524

165201         0        2        0.8122016298

165201         0        3        0.9751736188

165205         1        0        0.0081253999

165205         1        1        0.4420893893

165205         1        2        0.7955942710

165205         1        3        0.9724900318

165208         2        0        0.0011220970

.

.                   .          .

165210      3          0        0.0980113921

165210      3          1        0.3479984169

165210      3          2        0.8289891254

165210      3          3        0.9509891254

...etc

Here I have two questions:

1. The "prediction" variable is the predicted cumulative probability for ordinal response 0 to 4(but 4 is reference due to the fact that it is not displayed in the table). But I want create a variable that change the cumulative probability into non-cumulative probability, that is, example for the first patient_Id with the 0 level: cumulative probability at level 1 minus at level 0,  for the first patient_Id with the second level: cumulative probability at level 2 minus at level 1,  for the first patient_Id with the third level: cumulative probability at level 3 minus at level 2, and finally one minus cumulative probability at level 3. The same procedure for all Patient Id.

Finally

2. Based on the created variable in "1" I want to select a level with maximum probability so that I can get one probability value per patient_Id.

I'm happy to justify it if it is not clear.

1 ACCEPTED SOLUTION

Accepted Solutions

## Re: Classification of predicted value on logistic regression model

``````data want;
set have;
by patient_id;
prev_pred=lag(prediction);
if first.patient_id then do;
non_cumulative_prediction=prediction;
output;
end;
else if not last.patient_id then do;
non_cumulative_prediction=prediction-prev_pred;
output;
end;
else if last.patient_id then do;
non_cumulative_prediction=prediction-prev_pred;
output;
level=4;
non_cumulative_prediction=1-prev_pred;
output;
end;
drop prev_pred;
run;
proc summary nway data=want;
class patient_id;
var non_cumulative_prediction;
output out=maximum max=max_prediction
maxid(non_cumulative_prediction(level))=level_at_max_pred;
run;``````
--
Paige Miller
2 REPLIES 2

## Re: Classification of predicted value on logistic regression model

``````data want;
set have;
by patient_id;
prev_pred=lag(prediction);
if first.patient_id then do;
non_cumulative_prediction=prediction;
output;
end;
else if not last.patient_id then do;
non_cumulative_prediction=prediction-prev_pred;
output;
end;
else if last.patient_id then do;
non_cumulative_prediction=prediction-prev_pred;
output;
level=4;
non_cumulative_prediction=1-prev_pred;
output;
end;
drop prev_pred;
run;
proc summary nway data=want;
class patient_id;
var non_cumulative_prediction;
output out=maximum max=max_prediction
maxid(non_cumulative_prediction(level))=level_at_max_pred;
run;``````
--
Paige Miller

## Re: Classification of predicted value on logistic regression model

Dear

Discussion stats
• 2 replies
• 327 views
• 0 likes
• 2 in conversation