BookmarkSubscribeRSS Feed
BlueNose
Quartz | Level 8

Hello all

I wish to simulate data from a logistic regression model, with the following elements:

1. A binary response ( 1 = Success, 0 = Failure)

2. A binary independent variable (1 = Treatment, 0 = Control)

3. For each subject in the sample, there are 2 observations (like two ears if it's ear drops, for example), which are assumed to be correlated, or at least can't be assumed not to be.

The purpose is to do a power analysis for a given sample size. Before I try the power analysis with the looping, I am not sure how to simulate a single data set of that kind.

I have a copy of Rick Wicklin's book on simulations, I saw the code for logistic regression. The independent variables there are continuous (I think), and there is no correlation (no clusters), the clusters comes later with a normal dependent variable. I am not sure how to merge the two examples.

One more comment, I would prefer to do it using the data step and not IML, if possible .

Any assistant will be very appreciated !

(when helping you can make up any correlation and proportion you like, I can always change it later as part of a simulation).

Thank you in advance !

P.S. I have posted this on the data step forum and was suggested to move it here, the previous one shall be ignored and removed if an admin sees this comment. Thank you

1 REPLY 1
Rick_SAS
SAS Super FREQ

The easiest way to do this is to think of it as two steps.

In Step 1, create the explanatory variables by using the techniques described throughout the book. Since you have a repeated measures term, pay paticular attention to section 12.3.

After you have the explanatory variables modeled to your satisfaction, Step 2 is to add the response variable as in section 12.2:

data LogisticData;

set Explanatory;   /* all BY groups and explanatory variables (including random effect) in here */

eta = b0 + b1*treatment + randomEffect; /* specify linear model of treatment + random effect */

p = logistic(eta);    /* convert to probability via logistic transformation */

y = rand("Bernoulli", p);

run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 1 reply
  • 1057 views
  • 0 likes
  • 2 in conversation