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