## simulate from a logistics

Solved
Super Contributor
Posts: 328

# simulate from a logistics

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;

Accepted Solutions
Solution
‎05-28-2014 10:48 PM
Super User
Posts: 23,778

## Re: simulate from a logistics

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.

All Replies
Solution
‎05-28-2014 10:48 PM
Super User
Posts: 23,778

## Re: simulate from a logistics

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.

SAS Super FREQ
Posts: 4,247

## Re: simulate from a logistics

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.

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.

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.

🔒 This topic is solved and locked.

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