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

## 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;

1 ACCEPTED SOLUTION

Accepted Solutions
Super User

## 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.

2 REPLIES 2
Super User

## 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

## 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.

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.