turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- Simulated binary repeated measures

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-29-2014 07:44 AM

Hello,

I would very much like to have some help with a specific simulation I have to do.

I need to simulate a data set with hierarchal structure (HLM) with 2 level (patient and visits) and with binary output (0/1).

For example, I have 100 patients that came 5 times (visits) to the clinic. Each visits resolved with success/failure.

I have tried to use SAS/IML using RANDMULTINOMIAL but didn't come to any solution.

Any help will be very much appreciated.

Thanks!

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Noah

04-30-2014 11:48 AM

You haven't specified a model that describes how the outcome depends on the patients or visits. If you just want a random matrix of zeros and ones you can do this (requires SAS/IML 12.1):

proc iml;

p = j(1000, 5, 0.5); /* probability of success */

y = j(1000, 5, .); /* outcomes */

call randseed(12345);

call randgen(y, "Bernoulli", p); /* y* = 1 with probability p */*

print (y[1:3,]);

Presumably you want the matrix of probabilities to follow some model.

BTW, I discuss simulating correlated multivariate binary data in Chap 9 of *Simulating Data with SAS*

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Rick_SAS

05-01-2014 04:07 AM

Hi Rick,

Thank you very much for your answer!

You mentioned that I haven’t specified the model, so If I understand you, here is an explanation of my model I'm trying to simulate,

Each patient has 5 visits and at each visit the patient undergo a medical examination.

**New result** - is the **dependent** variable change from visit to visit. The outcome can be 0/1. Once the patient gains a success he’s out of the study (probability of success = 0.2).

**Past result** – also describes success or failure but this variable doesn’t change from visit to visit (**independent** variable).

**Time** - since **each** visit has a different time point this variable may also change from visit to visit and it’s one of the** independents** variables. Time is ordinal and divided to 3 groups with overall proportion of 30%, 40%, 30% , respectively.

I attached a small example to describe how 1 patient look like in the data:

Patient id | Age | Past result | Time | New result |

15283 | 24 | 1 | 1 | 0 |

15283 | 24 | 1 | 1 | 0 |

15283 | 24 | 1 | 1 | 0 |

15283 | 24 | 1 | 2 | 0 |

15283 | 24 | 1 | 2 | 1 |

I hope it's more clear now.

Thanks!

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Noah

05-02-2014 03:37 PM

My definition of model is mnore methematical than what you've provided, but I'll make a few suggestions. Look into the "Proportional Hazards model" in survival analysis. It sounds like your patients are assumed to have a baseline hazard of 0.2. You can read about PH models on the web or in the doc for PROC PHREG.

If you decide that the PH model is what you want to simulate, there is a discussion and programs on pp 242-246 of *Simulating Data with SAS*. You could also try an internet search for

simulate "proportional hazards" sas