simulate from a logistics

Accepted Solution Solved
Reply
Super Contributor
Posts: 297
Accepted Solution

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: 17,963

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.

View solution in original post


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

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: 3,490

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.

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.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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