Logistic regression modeling in Phoenix

The data in this dataset were simulated to demonstrate logistic modeling. Eight subjects were simulated. Within each subject, the response was randomly generated as either zero or one with probability p, where ln(p/(1 – p))=a+bX+eta as X varies between one and 12.

Note:    The completed project (Logistic_Model.phxproj) is available for reference in …\Examples\NLME.

Set up the Maximum Likelihood Models object

Create a new project called Logistic Model.

Import the dataset …\Examples\NLME\Supporting files\logistic.dat.

Press Finish in the File Import Wizard dialog.

Right-click the worksheet and select Send To > Modeling > Maximum Likelihood Models.

In the Structure tab of the ML Model object, select Linear from the Type menu.

From the Linear menu, select E = Alpha + Beta*C.

Select the Parameters > Structural sub-tab.

Clear the Ran checkbox beside Beta to remove random effects from the Beta parameter.

Map the model variables

1.  In the Main Mappings panel, map the columns to the contexts as follows:

ID to ID.

rep to C.

response to EObs.

Change the built-in model to a text model

1.  Press Edit as Textual.

2.  In the confirmation dialog, press Yes.

3.  Select Model in the Setup list.

The model text is displayed in the Model text panel as follows:

     test(){
covariate(C)
E = Alpha + Beta*C
error(EEps = 1)
observe(EObs(C) = E + EEps)
stparm(Alpha = tvAlpha * exp(nAlpha))
stparm(Beta = tvBeta)
fixef(tvAlpha = c(, 1, ))
fixef(tvBeta = c(, 1, ))
ranef(diag(nAlpha) = c(1))
}

Edit the text model

The model text needs to be edited to update the error and observation statements.

Note:    Either type in the Model panel to edit the model text or copy and paste the lines of code from this example.

1.  Change the error statement to a probability statement:
          error(EEps = 1) 
to
          prob = exp(E)/(1 + exp(E)) 

2.  Change the observation statement to a log likelihood statement:
          observe(EObs(C) = E + EEps) 
to
          LL(EObs, EObs == 1 ? log(prob):log(1 - prob)) 

3.  Click icon_execute (Execute icon) to execute the object.

Use the multi statement

Edit the model text to use the multi statement, rather than the LL statement, for the multinomial response. The multi statement can be used for multinomial responses from two to ten ordered categories, and allows use of a variety of link functions in addition to the ilogit function (inverse logit).

1.  Right-click ML Model in the workflow and select Copy.

2.  Right-click Workflow and select Paste.

3.  Rename the model copy as ML Model_multi.

4.  In the Model text panel, change the two statements
          prob=exp(E)/(1 + exp(E)) 
and
          LL(EObs, EObs == 1 ? log(prob):log(1 - prob)) 
to one statement
          multi(EObs, ilogit, E) 

5.  Execute the object.

Save and close the project

1.  Select File > Save Project.

2.  Press Save.

3.  Select File > Close Project.

The project is saved and closed and Phoenix can be safely exited.

This concludes the logistic regression modeling example.


Legal Notice | Contact Certara
© Certara USA, Inc. All rights reserved.