Regression Action Set

The logisticType3 Action

Binary Logistic Regression

This section contains PROC CAS code.

Note: Input data must be accessible in your CAS session, either as a CAS table or as a transient-scope table. A CAS table has a two-level name: the first level is your CAS engine libref, and the second level is the table name. You refer to this table in the CAS procedure by specifying only the second level. For more information about two-level names, see Chapter 2, Shared Concepts. A transient-scope table is called directly from the action and exists in memory for the duration of the action. For more information about accessing data, see SAS Viya: System Programming Guide. For more information about PROC CAS and programming in CASL, see SAS Cloud Analytic Services: CASL Programmer’s Guide and SAS Cloud Analytic Services: CASL Reference.

This example uses the mycas.getStarted data table from Example 20.5 to demonstrate how to compute Wald tests for Type 3 contrasts. It also demonstrates how to store and restore your model.

The following PROC CAS statements use the logistic action in the regression action set to fit a logistic model to these data and store the model. The store parameter stores the model in a special data table named mycas.myModel. The model fit results are displayed in Example 20.5.

proc cas;
   regression.logistic
      table='getStarted',
      class={'C'},
      model={depvar='y',
             effects={'C', 'x2', 'x8'}},
      store={name='myModel', replace=true};
run;

The following PROC CAS statements use the logisticType3 action in the regression action set to compute the Wald Type 3 analysis of effects without refitting the model. The restore parameter names the stored model to be used.

proc cas;
   regression.logisticType3
      restore='myModel';
run;

The output from this analysis is displayed in Output 20.13.1. Note that the test for the classification effect, C, has 9 degrees of freedom, and you cannot reject the null hypothesis that all the parameter estimates of C are jointly all 0. The tests of the continuous covariates have 1 degree of freedom and are both significantly different from 0.

Output 20.13.1: Wald Test Results

Results from regression.logisticType3

Model Analysis of Variance (Type
III)
EffectDFChi-SquarePr > ChiSq
C99.12990.4254
x2123.6900<.0001
x8121.3999<.0001


Binary Logistic Regression

This section contains Lua code for the analysis in the CASL version of this example, which contains details about the results.

Note: In order to run this code, the data that are described in the CASL version need to be accessible to the CAS server. One way to do this is to convert the getStarted data to the comma-separated-value (CSV) file getStarted.csv and then use the following code to load the CSV file into CAS:

s:loadtable{casLib="casuser", path="getStarted.csv"}

For more information about coding in Lua, see Getting Started with SAS Viya for Lua and SAS Viya: System Programming Guide.

The following code loads the regression action set, uses the logistic action to fit a logistic model to the getStarted data table, and demonstrates how to store and restore your model.

The store parameter stores the model in the myModel data table.

s:loadactionset{actionset="regression"}
m=s:logistic{
   table='getStarted',
   class={'C'},
   model={depvar='y',
          effects={'C', 'x2', 'x8'}},
   store={name='myModel', replace=true} }

The following command uses the logisticType3 action in the regression action set to produce the tests. The restore parameter names the stored model to be used.

m=s:logisticType3{
   restore='myModel'}

The following command displays the "ModelAnova" table:

print(m.ModelAnova)
Binary Logistic Regression

This section contains Python code for the analysis in the CASL version of this example, which contains details about the results.

Note: In order to run this code, the data that are described in the CASL version need to be accessible to the CAS server. One way to do this is to convert the getStarted data to the comma-separated-value (CSV) file getStarted.csv and then use the following code to load the CSV file into CAS:

s.upload_file('getStarted.csv')

For more information about coding in Python, see Getting Started with SAS Viya for Python and SAS Viya: System Programming Guide.

The following code loads the regression action set, uses the logistic action to fit a logistic model to the getStarted data table, and demonstrates how to store and restore your model.

The store parameter stores the model in the myModel data table.

s.loadactionset(actionset='regression')
m=s.logistic(
   table='getStarted',
   classvars='C',
   model={'depvar':'y',
          'effects':['C', 'x2', 'x8']},
   store={'name':'myModel', 'replace':'true'} )

The following command uses the logisticType3 action in the regression action set to produce the tests. The restore parameter names the stored model to be used.

m=s.logisticType3(
   restore='myModel' )

The following command displays the "ModelAnova" table:

print(m.ModelAnova)
Binary Logistic Regression

This section contains R code for the analysis in the CASL version of this example, which contains details about the results.

Note: In order to run this code, the data that are described in the CASL version need to be accessible to the CAS server. One way to do this is to convert the getStarted data to the comma-separated-value (CSV) file getStarted.csv and then use the following code to load the CSV file into CAS:

m <- cas.read.csv(s, "getStarted.csv", casOut=list(name="getStarted"))

For more information about coding in R, see Getting Started with SAS Viya for R and SAS Viya: System Programming Guide.

The following code loads the regression action set, uses the logistic action to fit a logistic model to the getStarted data table, and demonstrates how to store and restore your model.

The store parameter stores the model in the myModel data table.

m <- cas.builtins.loadActionSet(s, actionset='regression')
m <- cas.regression.logistic(s,
   table='getStarted',
   class='C',
   model=list(depvar='y',
              effects=list('C', 'x2', 'x8')),
   store=list(name='myModel',replace=TRUE)
)

The following command uses the logisticType3 action in the regression action set to produce the tests. The restore parameter names the stored model to be used.

m <- cas.regression.logisticType3(s,
   restore='myModel'
)

The following command displays the "ModelAnova" table:

print(m$ModelAnova)

For details about the results of this analysis, see the CASL version of this example.

Last updated: September 13, 2022