BookmarkSubscribeRSS Feed
seisel
Calcite | Level 5

I would like to get a model to predict the dichotomous yes/no outcome (yes sleep disturbance/ no sleep disturbance) and then output that to a new dataset for each individual at each time point (is this possible?). There are many individuals that do not have all 4 time points and we would like to be able to include everyone. So far I have only been able to get the model to output means/probabilities and they are the same for each participant and each time point (or just for individuals with data at that time point). Any suggestions on what model/code I should be using? For example, if my data and model look like this:

 

data sleep;

input ID Months SleepDist;

cards;

1         0         1

1         10        1

1         25        0

1         39        1

2         0         1

2         10        .

2         25        1

2         39        0

3         0         1

3         10        .

3         25        0

3         39        .

4         0         1

4         10        .

4         25        0

4         39        0

5         0         1

5         10        1

5         25        1

5         39        0

6         0         0

6         10        .

6         25        0

6         39        1

;

 

proc genmod data= sleepdata;

   class ID /missing;

   model SleepDist = Months / dist=bin expected;

   repeated subject=ID / type=un covb corrw;

          output out = try

                             pred= pred;

run;

 

What I get:

ID

Months

SleepDist

Predicted Value

1

0

1

0.164

1

10

1

0.269

1

25

0

0.485

1

39

1

0.694

2

0

1

0.164

2

10

.

0.269

2

25

1

0.485

2

39

0

0.694

3

0

1

0.164

3

10

.

0.269

3

25

0

0.485

3

39

.

0.694

...

 

I would like:

ID

Months

SleepDist

Predicted Value

1

0

1

1

1

10

1

1

1

25

0

0

1

39

1

1

2

0

1

1

2

10

.

1

2

25

1

1

2

39

0

0

3

0

1

1

3

10

.

0

3

25

0

0

3

39

.

1

 

Thanks!

2 REPLIES 2
Reeza
Super User
You need to decide what your cut off is. Most classification algorithms give you a probability and then you use a cutoff to convert that to a 0/1. Ie if predicted value > 0.7 then 1, else 0. Or 0.5, or 0.3. You usually pick the cutoff by looking at the classification tables or the ROC graphs.

https://www.researchgate.net/post/How_do_I_calculate_the_best_cutoff_for_ROC_curves
PGStats
Opal | Level 21

Also, be careful what probability you are modelling. For a neutral cutoff (0.5) you would be doing:

 

proc genmod data=sleep;
   class ID;
   model SleepDist(event='1') = Months / dist=bin expected;
   repeated subject=ID / type=un covb corrw;
   output out = sleepPred pred=pred;
run;

data sleepProb;
set sleepPred;
SleepDistPred = pred > 0.5;
run;

(event='1') tells the procedure which probability you are modelling.

PG

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 586 views
  • 2 likes
  • 3 in conversation