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;
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.
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.
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.