Being a user of both ETS and occasional user of Risk Dimensions, I've often wanted to incorporate logistic models into my simulations. It is possible to fit the logistic regressions through numerous PROCs in SAS/STAT and incorporate the fitted parameters into MODEL or RISK statements. It would be nice to be able to fit a logistic regression in PROC MODEL to save the macro programming hoops necessary to fit in something else and incorporate in MODEL.
First there are two resources I used for this example.
Now, let's generate some binomial data
Next, let's fit the model in PROC LOGISTICdata test;a = 5;b = 10;do i=1 to 10000;rand = rannor(123);xb = a + b*rand ;p = 1 / (1+ exp(-xb));if ranuni(123) < p theny = 1;elsey = 0;output;end;run;
The interesting part of the output:proc logistic data=test descending;model y = rand;run;
The fitted values are within reason of the true values.The LOGISTIC ProcedureAnalysis of Maximum Likelihood EstimatesStandard WaldParameter DF Estimate Error Chi-Square Pr > ChiSqIntercept 1 4.9155 0.1517 1050.0422 <.0001rand 1 9.7196 0.2896 1126.4620 <.0001
Now let's use the eq 9. on page 5 of the Czepiel paper. Also of note is the documentation on the general likelihood function in PROC MODEL for use in ML estimation.
First, we define a function, "reg," which is our regression equation. Next, we define the equation for y. Using Eq. 9, we define the likelihood function. Note, PROC MODEL uses a minimization of the sum of the likelihood function, so we negate the value.proc model data=test;parameters a b;reg = a + b*rand;y = 1 / (1 + exp(-reg));llik = -(y*reg - log(1 + exp(reg)));errormodel y ~ general(llik);fit y / fiml ;quit;
The key is to now define the ERRORMODEL for y as a general likelihood function. The FIT statement with the "/ fiml" option tell SAS to use a ML estimation. Because the general likelihood function is defined, this is used for the fitting.
Here is the relevant output from PROC MODEL:
The MODEL ProcedureNonlinear Liklhood Summary of Residual ErrorsDF DF AdjEquation Model Error SSE MSE Root MSE R-Square R-Sqy 2 9998 359.5 0.0360 0.1896 0.8335 0.8335Nonlinear Liklhood Parameter EstimatesApprox ApproxParameter Estimate Std Err t Value Pr > |t|a 4.915868 0.1517 32.42 <.0001b 9.719905 0.2895 33.57 <.0001Number of Observations Statistics for SystemUsed 10000 Log Likelihood -1179Missing 0
Thanks for the helpful post. In the first data step, why are you using a random uniform variable as the cutoff point, why not using 0.5? that is, instead of writing
ReplyDeleteif ranuni(123) < p then ....
why can't we write the following?
if 0.5 < p then ....
Logostic regression in proc at nice posts thanku for sharing..
ReplyDelete]
Hadoop training in hyderabad.All the basic and get the full knowledge of hadoop.
hadoop training in hyderabad
ReplyDeleteThank you for sharing the article. The data that you provided in the blog is informative and effective.
Best Devops Training Institute
Thank your valuable content.we are very thankful to you.one of the recommanded blog. which is very useful to new learners and professionals. content is very useful for New learners.
ReplyDeleteSalesforce Training in Chennai
Salesforce Online Training in Chennai
Salesforce Training in Bangalore
Salesforce Training in Hyderabad
Salesforce training in ameerpet
Salesforce Training in Pune
Salesforce Online Training
Salesforce Training
Here is the best music to calm and relax your mind
ReplyDelete1. best relaxing music
2. best Depp sleep music
3. best meditation music
4. best calm music
5. best deep focus music
Online Training | Classroom | Virtual Classes
ReplyDeleteData Science Course in Hyderabad with 100% placement assistance
Data Analyse Career Guidance
Data Science Course in Hyderabad from Real time expert trainers
Indutry oriented training with corporate casestudies
Free Aptitude classes & Mock interviews
rexbet
ReplyDeletepusulabet
sex hattı
rulet siteleri
hipodrombet
12Q
kuşadası
ReplyDeletemilas
çeşme
bağcılar
amasya
00J