BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
desireatem
Pyrite | Level 9

Hi I wish to ask why this logistic simulated data does give the correct estimates for t  when I ran the simulation with 1000 replicate; Any help?

data test;

intercept = 0.01;

beta = 0.5;

beta1=0.1;

do i = 1 to 1000;

t = rand("WEIBULL", .5, .25; );

X=ranbin(0,1,.5);

linpred = intercept + t*beta + x*beta1;

prob = exp(linpred)/ (1 + exp(linpred));

U=.6*(uniform(0)) + 0.4;

y = U lt prob;

output;

end;

run;

proc logistic data=test;

model Y(event='1') = t x;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

I thought x should be normally distributed?

Do you have a reference for this particular methodology, I'm not familiar with it. 

I'd suggest looking at Rick Wicklins Simulation book if you're interested in simulating data.

View solution in original post

2 REPLIES 2
Reeza
Super User

I thought x should be normally distributed?

Do you have a reference for this particular methodology, I'm not familiar with it. 

I'd suggest looking at Rick Wicklins Simulation book if you're interested in simulating data.

Rick_SAS
SAS Super FREQ

Simulation of logistic data is covered in Section 12.2 of Simulating Data with SAS. You can download the code for free from the book's web site. The distribution of the explanatory variables can be whatever you want, but as Reeza points out, the distribution does affect the variability of the estimates.

In your code, your computation of Y is incorrect. Use

  y = rand("Bernoulli",prob);

Even though 1000 obs seems like a lot of observations (and is for linear regression), the logistic parameter estimates are quite variable, so turn on the CLPARM=WALD option to check whether the parameter estimates are "close" to the parameter values:

You'll see that the 95% confidence intervals do in fact contain the parameters.

If you add

CLASS x;

to your model, you also have to be concerned with the parameterization used for the 0/1 variable.That is described in Section 11.3 of my book.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 472 views
  • 4 likes
  • 3 in conversation