Proportional Hazards Regression Modeling Action Set

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

The following DATA step creates the data table mycas.getStarted in your CAS session. This data table consists of 100 observations on a failure time variable (Time), an indicator variable (Status) that has two values (0 for censored observations and 1 for event observations), three classification variables (C1–C3), and four interval variables (X1–X4). This DATA step assumes that your CAS engine libref is named mycas, but you can substitute any appropriately defined CAS engine libref.

data mycas.getStarted;
   input Time Status C1$ C2 C3$ X1-X4;
   datalines;
   53       0      Low          1    M     1.11    2.000    3.6128    12.0
   12       0      High         1    M     1.40    1.362    3.8388     8.8
   11       1      Low          1    F     1.57    1.672    3.8865     7.5
    7       1      Medium       0    M     1.04    2.000    3.7324     5.1
    2       1      Low          1    M     1.52    2.000    3.8751     9.8
   41       0      High         1    M     1.76    1.447    3.7243    12.8
    6       1      Critical     1    F     1.36    1.462    3.5441     9.0
    6       1      Critical     1    M     1.42    1.690    3.9294    10.4
   16       1      Medium       1    M     1.32    0.699    3.6990     8.8
   41       1      Medium       1    M     1.00    1.477    3.4771    10.2
    2       1      High         0    M     1.30    2.000    3.7243     5.1
   58       1      Medium       1    M     1.20    1.580    3.6990    12.1
   11       1      High         1    M     1.08    1.903    3.5051     9.6
   12       0      Critical     1    F     1.15    1.146    3.6435    11.6
   16       0      High         1    F     1.15    0.903    3.8573    13.0
   54       1      Medium       1    M     1.26    1.699    3.7243     9.0
   51       1      Low          0    M     1.57    1.041    3.4150     7.7
   67       1      Medium       1    M     1.32    1.041    3.6435    12.8
    1       1      Low          1    M     1.94    1.954    3.9868    12.0
   19       0      Medium       1    M     1.32    2.000    3.7709    13.0
    1       1      Medium       1    M     2.22    1.954    3.6628     9.4
   35       1      Medium       0    M     1.11    1.176    3.6532     7.0
   41       1      High         1    M     1.15    1.342    3.5185     5.0
   58       1      Medium       1    M     1.20    1.580    3.6990    12.1
   11       1      Medium       1    M     1.11    1.279    3.8808    14.0
   41       1      Medium       1    M     1.00    1.477    3.4771    10.2
   19       1      High         0    M     1.26    1.929    3.7924     7.5
   89       1      High         1    M     1.32    1.623    3.6532    14.0
    4       0      Medium       1    F     1.95    0.778    4.0453    10.2
    6       1      Critical     1    F     1.36    1.462    3.5441     9.0
   57       0      Low          1    F     1.26    1.954    3.9685    12.5
    5       1      High         1    M     2.24    1.663    4.9542    10.1
   17       1      Medium       1    F     1.59    1.613    3.4314    11.2
   77       0      Low          1    F     1.08    0.954    3.6812    14.0
   66       1      High         1    M     1.45    1.820    3.7853     6.6
   16       1      Medium       1    M     1.32    0.699    3.6990     8.8
    8       0      Critical     1    M     1.08    1.653    3.8325     9.9
   19       1      High         0    M     1.26    1.929    3.7924     7.5
   37       1      High         1    F     1.60    1.204    3.9542    11.0
   52       1      Medium       1    M     1.00    1.653    3.8573    10.1
   13       0      High         0    F     1.66    1.792    3.6435     4.9
    3       1      Medium       1    F     1.54    1.935    4.4757     6.7
   51       1      Low          0    M     1.57    1.041    3.4150     7.7
    2       1      High         0    M     1.30    2.000    3.7243     5.1
   25       1      Medium       1    M     1.00    1.644    3.8195    12.4
   11       1      Low          1    F     1.57    1.672    3.8865     7.5
   19       1      Low          1    M     1.08    2.000    3.9191    14.4
    9       1      Low          1    M     1.72    1.740    3.7993     8.2
    6       1      Medium       1    M     1.11    1.398    3.5185     9.7
   16       1      Medium       1    M     1.34    2.000    3.9345     9.0
   12       0      High         1    M     1.40    1.362    3.8388     8.8
   17       1      High         1    M     1.23    1.447    3.8808    10.0
   17       1      High         1    M     1.23    1.447    3.8808    10.0
   41       0      High         1    M     1.76    1.447    3.7243    12.8
   88       1      High         1    F     1.18    1.756    3.5563    10.6
   16       0      High         1    F     1.15    0.903    3.8573    13.0
    4       0      Low          1    F     1.92    1.623    3.9590    10.0
    7       1      Low          1    M     1.18    1.519    3.7243    11.4
   19       0      Medium       1    M     1.32    1.519    3.8808    10.8
    8       0      Critical     1    M     1.08    1.653    3.8325     9.9
   57       0      Low          1    F     1.26    1.954    3.9685    12.5
    7       1      Medium       1    M     1.98    1.568    3.3617     9.5
   19       1      Low          1    M     1.08    2.000    3.9191    14.4
    7       0      Low          1    F     1.53    1.881    3.5911    10.2
    5       1      High         1    F     1.68    1.732    3.7324     6.5
    2       1      Low          0    M     1.75    1.255    3.8062    11.3
    1       1      Low          1    M     1.94    1.954    3.9868    12.0
   15       1      Low          1    M     1.60    1.431    3.6902    10.6
   26       1      Low          1    M     1.23    2.000    3.6021    11.2
   92       1      Low          1    M     1.43    1.415    4.0755    11.0
   11       1      Medium       1    M     1.30    1.820    3.7993    13.2
    3       1      Medium       1    F     1.54    1.935    4.4757     6.7
   66       1      High         1    M     1.45    1.820    3.7853     6.6
    1       1      Medium       1    M     2.22    1.954    3.6628     9.4
   11       1      Medium       1    M     1.30    1.820    3.7993    13.2
   14       1      Medium       1    M     1.40    1.255    3.7243    14.6
   32       1      High         1    M     1.32    1.634    3.6990    10.6
   24       1      High         1    M     1.30    0.477    4.0899    14.6
   18       1      Critical     1    F     1.45    0.903    3.5682     7.5
    5       1      High         1    F     1.68    1.732    3.7324     6.5
    2       1      Low          0    M     1.75    1.255    3.8062    11.3
   26       1      Low          1    M     1.23    2.000    3.6021    11.2
   11       1      High         1    M     1.23    1.176    3.7709    12.0
   28       0      High         1    M     1.23    1.672    3.7482     7.3
   19       0      Medium       1    M     1.32    2.000    3.7709    13.0
   54       1      Medium       1    M     1.26    1.699    3.7243     9.0
    2       1      Low          1    M     1.52    2.000    3.8751     9.8
    7       0      Medium       1    M     1.11    1.857    3.7993    12.4
   19       0      Medium       1    M     1.32    1.519    3.8808    10.8
    6       1      Critical     1    M     1.42    1.690    3.9294    10.4
    6       1      Medium       1    M     1.11    1.398    3.5185     9.7
   11       1      Medium       1    M     1.11    1.279    3.8808    14.0
    6       1      Critical     0    M     2.11    1.362    3.5441    10.2
   13       1      Medium       0    M     0.78    1.398    3.5798     5.5
   18       1      Critical     1    F     1.45    0.903    3.5682     7.5
    7       0      Low          1    F     1.53    1.881    3.5911    10.2
   53       0      Low          1    M     1.11    2.000    3.6128    12.0
   11       1      High         1    M     1.08    1.903    3.5051     9.6
   11       0      High         1    M     1.61    1.845    3.7324    14.0
   89       1      High         1    M     1.32    1.623    3.6532    14.0
;

The following PROC CAS statements use the cox action in the phreg action set to fit a Cox regression model to these data. The table parameter names the input data table to be analyzed. The class parameter specifies that variables C1–C3 are classification variables; this parameter corresponds to the CLASS statement in the PHSELECT procedure. The model parameter specifies the model: the depVar subparameter specifies the variable Time as the failure time variable, the censor subparameter specifies the variable Status as the censoring variable, the censVals subparameter lists the value 0 as the value of Status that represents a censored observation, and the effects subparameter lists the classification variables C1–C3 and continuous variables X1–X4 as explanatory variables. The itHist subparameter in the optimization parameter list produces a table that summarizes the steps of the optimization. The outputTables parameter outputs the parameter estimates to the mycas.pe data table.

proc cas;
   phreg.cox
      table={name='getStarted'},
      class={'C1', 'C2', 'C3'},
      model={depVar='Time',
             censor='Status',
             censVals={0},
             effects={'C1', 'C2', 'C3', 'X1', 'X2', 'X3', 'X4'}},
      optimization={itHist='summary'},
      outputTables={names={parameterestimates='pe'}};
run;

The output from this analysis is displayed by default, and is presented in Output 20.1.1 through Output 20.1.8.

Output 20.1.1 displays the "Model Information" table. The cox action uses a quasi-Newton algorithm to maximize the partial likelihood to estimate the regression parameters. The classification variable C1–C3 are parameterized using GLM parameterization, which is the default.

Output 20.1.1: Model Information

Results from phreg.cox

Model Information
Data SourceGETSTARTED
Response VariableTime
Censoring VariableStatus
Censoring Values0
Optimization techniqueDual Quasi-Newton


The "Number of Observations" table, displayed in Output 20.1.2, shows the breakdown of the censored and uncensored observations. Uncensored observations are also known as event observations. All 100 observations in the data table are used in the analysis: 26 are censored observations, and 74 are uncensored.

Output 20.1.2: Number of Observations

Number of Observations
DescriptionTotalEventCensored
Number of Observations Read1007426
Number of Observations Used1007426


The classification variable C1 has four unique formatted levels, and each of the classification variables C2 and C3 has two formatted levels. They are displayed in the "Class Level Information" table in Output 20.1.3.

Output 20.1.3: Class Level Information

Class Level Information
ClassLevelsValues
C14Critical High Low Medium
C220 1
C32F M


The "Iteration History" table is shown in Output 20.1.4. The quasi-Raphson algorithm converges after 12 iterations.

Output 20.1.4: Iteration History

Iteration History
IterationEvaluationsObjective
Function
ChangeMax Gradient
04272.56284984.65.17039
13267.705942064.856907787.86724
22261.808680565.897261504.723085
32256.620595715.188084854.650619
42255.593461251.027134461.0462
52255.441425940.152035311.018105
63255.406921960.034503980.353611
73255.394617360.012304600.415741
83255.393626710.000990650.074411
93255.393392110.000234600.062435
103255.393366530.000025580.004922
113255.393362620.000003910.002273
123255.393362370.000000260.000452


Output 20.1.5 displays the final convergence status of the optimization. The GCONV relative convergence criterion is satisfied.

Output 20.1.5: Convergence Status

Convergence criterion (GCONV=1E-8) satisfied.


Output 20.1.6 displays the "Dimensions" table for this model. This table summarizes some important sizes of various model components. For example, it shows that the design matrix bold upper X has 12 columns: four columns for the effects that are associated with the classification variable C1, two columns for each of the classification variables C2 and C3, and one column for each of the continuous variables X1–X4. However, the rank of the crossproducts matrix is only 9. Because the classification variables C1– C3 use GLM parameterization, there is one singularity in the crossproducts matrix of the model for each classification variable. Consequently, only nine parameters enter the optimization.

Output 20.1.6: Dimensions in Cox Regression

Dimensions
Number of Effects7
Max Effect Columns4
Columns in Design12
Rank of Design9


The "Fit Statistics" table is shown in Output 20.1.7. The –2 log likelihood at the converged estimates is 510.72307. You can use this value to compare the model to nested model alternatives by means of a likelihood ratio test. To compare models that are not nested, you can use information criteria such as AIC (Akaike’s information criterion), AICC (Akaike’s bias-corrected information criterion), and SBC (Schwarz Bayesian information criterion). These criteria penalize the –2 log likelihood for the number of parameters.

Output 20.1.7: Fit Statistics

Fit Statistics
-2 Log Likelihood510.78672
AIC (smaller is better)528.78672
AICC (smaller is better)531.59922
SBC (smaller is better)549.52331


The "Parameter Estimates" table in Output 20.1.8 shows that a number of parameters have fairly large p-values, indicating that one or more of the model effects might not be necessary.

Output 20.1.8: Parameter Estimates

Parameter Estimates
ParameterDFEstimateStandard
Error
Chi-SquarePr > ChiSq
C1 Critical10.4004930.4895620.66920.4133
C1 High1-0.9906020.3251459.28210.0023
C1 Low1-0.6654950.3391483.85040.0497
C1 Medium00...
C2 010.4107040.3988331.06040.3031
C2 100...
C3 F1-0.1725500.3379400.26070.6096
C3 M00...
X111.9704880.52414214.13350.0002
X210.7266050.4151413.06340.0801
X310.7253900.5856581.53410.2155
X41-0.1312260.0571035.28100.0216


Finally, the "Task Timing" table in Output 20.1.9 shows the amount of time (in seconds) that the cox action spent on different tasks in the analysis.

Output 20.1.9: Task Timing

Task Timing
TaskSecondsPercent
Setup and Parsing0.0212.76%
Levelization0.014.54%
Model Initialization0.001.41%
SSCP Computation0.000.47%
Model Fitting0.1371.93%
Cleanup0.002.53%
Total0.19100.00%


Output 20.1.8 shows that the full model has some nonsignificant effects. You can perform forward selection on these data by using the following statements. Effects that provide the best improvement for the default selection criterion, SBC, are added until no more effects can improve the selection criterion. The method subparameter in the selection parameter enables you to choose the selection method, and the details subparameter produces all tables that are related to model selection. The ODS TRACE command displays the full pathnames of the output tables in the SAS log.

ods trace on;
proc cas;
   phreg.cox
       table={name='getStarted'},
       class={'C1', 'C2', 'C3'},
       model={depVar='Time',
              censor='Status',
              censVals={0},
              effects={'C1', 'C2', 'C3', 'X1', 'X2', 'X3', 'X4'}},
       selection={method='forward', details='all'};
run;

The model selection tables are shown in Output 20.1.10 through Output 20.1.12. Results from the selected model are shown in Output 20.1.13 and Output 20.1.14.

The "Selection Information" table in Output 20.1.10 summarizes the settings for the model selection. At each step, an effect is added to the model only if it produces the most significant improvement in the SBC. The forward selection stops three steps after the smallest SBC is obtained, or when all effects have been added to the model.

Output 20.1.10: Selection Information

Results from phreg.cox

Selection Information
DescriptionValue
Selection MethodForward
Select CriterionSBC
Stop CriterionSBC
Effect Hierarchy EnforcedNone
Stop Horizon3


For each step of the selection process, the details=all subparameter displays the effects that are candidates for entering the model along with their selection criterion (SBC). Output 20.1.11 displays this table for the first step; the other steps are not shown here.

Output 20.1.11: Step1 Entry Candidates

Results from phreg.cox
 
Forward Selection: Step 1
Effect Entered: X1

Entry Candidates
RankEffectSBC
1X1536.7462
2X4539.8497
3C2544.9948
4X3548.2815
5X2548.9490
6C3549.1132
7C1551.8649


The details=all subparameter also displays the dimensions, global test, fit statistics, and parameter estimates at each step of the selection process; these details are not shown here.

When the selection procedure is complete, the "Selection Summary" table in Output 20.1.12 shows the effects that were added to the model and the value of their selection criterion (and the choose and stop criteria, if they are specified). In Step 1, effect X1 made the most significant contribution to the model among the candidate effects, according to the SBC statistic. In Step 2, X4 made the most significant contribution when an effect was added to a model that contains X1. In the three subsequent steps, no effect that would reduce the SBC could be added to the model, so variable selection stopped because the stop horizon indicates that at most three steps beyond the minimum SBC value are to be taken (see Output 20.1.10) .

In Output 20.1.12, the "Selection Summary" table is followed by three small tables that summarize why the process stopped and which model is selected.

Output 20.1.12: Selection Summary Information

Results from phreg.cox
 
Selection Details

Selection Summary
StepEffect
Entered
Number
Effects In
SBC
1X11536.7462
2X42535.1652*
3C13538.2917
4X24539.2661
5X35542.4842
* Optimal Value Of Criterion

Selection stopped at a local minimum of the STOP criterion.

The model at step 2 is selected.

Selected Effects:X1 X4


Output 20.1.13 displays information about the selected model. Notice that the –2 log-likelihood value in the "Fit Statistics" table is larger than the value for the full model in Output 20.1.7. This result is expected because the selected model contains only a subset of the parameters. Because the selected model is more parsimonious than the full model, the discrepancy between the –2 log likelihood and the information criteria is less severe than previously noted.

Output 20.1.13: Fit Statistics

Results from phreg.cox
 
Selected Model

Dimensions
Number of Effects2
Max Effect Columns1
Columns in Design2
Rank of Design2

Fit Statistics
-2 Log Likelihood526.74445
AIC (smaller is better)530.74445
AICC (smaller is better)530.91346
SBC (smaller is better)535.35258


The parameter estimates of the selected model are shown in Output 20.1.14. Notice that the effects are listed in the "Parameter Estimates" table in the order in which they were specified in the model parameter and not in the order in which they were added to the model.

Output 20.1.14: Parameter Estimates

Parameter Estimates
ParameterDFEstimateStandard
Error
Chi-SquarePr > ChiSq
X111.6053060.5138119.76130.0018
X41-0.1233040.0466976.97230.0083


Cox 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 phreg action set, and then uses the cox action to fit a Cox regression model to the getStarted data table. The table parameter names the input data table to be analyzed. The class parameter specifies that the variables C1–C3 are classification variables; this parameter corresponds to the CLASS statement in the PHSELECT procedure. The model parameter specifies the model: the depVar subparameter specifies the variable Time as the response variable, the censor subparameter specifies the variable Status as the censoring variable, the censVals subparameter lists the value 0 as the value of Status that represents a censored observation, and the effects subparameter lists the three classification variables C1–C3 and the four continuous explanatory variables X1–X4. The itHist subparameter in the optimization parameter list produces a table that summarizes the steps of the optimization. The outputTables parameter outputs the fitted parameter estimates to the mycas.pe data table.

s:loadactionset{actionset="phreg"}
m=s:cox{
   table='getStarted',
   class={'C1', 'C2','C3'},
   model={depVar='Time',
          censor='Status',
          censVals={0},
          effects={'C1', 'C2', 'C3', 'X1', 'X2', 'X3', 'X4'}},
   optimization={itHist='summary'},
   outputTables={names={parameterestimates='pe'}} }

The following commands display the tables that are produced by this action call:

print(m.ModelInfo)
print(m.NObs)
print(m.ClassInfo)
print(m.IterHistory)
print(m.ConvergenceStatus)
print(m.Dimensions)
print(m.FitStatistics)
print(m.ParameterEstimates)
print(m.Timing)

The full model has a number of nonsignificant effects; see the CASL version of this example for details about the results of this analysis. You can perform forward selection on these data by using the following program. Effects that provide the best improvement for the default selection criterion, SBC, are added until no more effects can improve the selection criterion. The method subparameter in the selection parameter enables you to choose the selection method, and the details subparameter produces all tables that are related to model selection.

m=s:cox{
   table='getStarted',
   class={'C1','C2','C3'},
   model={depVar='Time',
          censor='Status',
          censVals={0},
          effects={'C1', 'C2','C3','X1', 'X2', 'X3', 'X4'}},
   selection={method='forward', details='all'} }

The following commands display some of the tables that are produced by this action call:

print(m.SelectionInfo)
print(m["StepDetails.Step1.EntryCandidates"])
print(m["Summary.SelectionSummary"])
print(m["Summary.StopReason"])
print(m["Summary.SelectionReason"])
print(m["Summary.SelectedEffects"])
print(m["SelectedModel.Dimensions"])
print(m["SelectedModel.FitStatistics"])
print(m["SelectedModel.ParameterEstimates"])

The following command displays all the tables that are produced by this action call along with their full pathnames:

m

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

Cox 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 phreg action set, and then uses the cox action to fit a Cox regression model to the getStarted data table. The table parameter names the input data table to be analyzed. The classvars parameter specifies that variables C1–C3 are classification variables; this parameter corresponds to the CLASS statement in the PHSELECT procedure. The model parameter specifies the model: the depVar subparameter specifies the variable Time as the response variable, the censor subparameter specifies the variable Status as the censoring variable, the censVals subparameter lists the value 0 as the value of Status that represents a censored observation, and the effects subparameter lists the three classification variables C1–C4 and four continuous explanatory variables X1–X4. The itHist subparameter in the optimization parameter list produces a table that summarizes the steps of the optimization. The outputTables parameter outputs the fitted parameter estimates to the mycas.pe data table.

s.loadactionset(actionset='phreg')
m=s.cox(
   table='getStarted',
   classVars={'C1', 'C2', 'C3'},
   model={'depVar':'Time',
          'censor':'Status',
          'censVals':{0},
          'effects':['C1', 'C2', 'C3', 'X1', 'X2', 'X3', 'X4']},
   optimization={'itHist':'summary'},
   outputTables={'names':{'parameterestimates':'pe'}} )

The following commands display the tables that are produced by this action call:

print(m.ModelInfo)
print(m.NObs)
print(m.ClassInfo)
print(m.IterHistory)
print(m.ConvergenceStatus)
print(m.Dimensions)
print(m.FitStatistics)
print(m.ParameterEstimates)
print(m.Timing)

The full model has many nonsignificant effects; see the CASL version of this example for details about the results of this analysis. You can perform forward selection on these data by using the following program. Effects that provide the best improvement for the default selection criterion, SBC, are added until no more effects can improve the selection criterion. The method subparameter in the selection parameter enables you to choose the selection method, and the details subparameter produces all tables that are related to model selection.

m=s.cox(
  table='getStarted',
   classVars={'C1','C2','C3'},
   model={'depVar':'Time',
          'censor':'Status',
          'censVals':{0},
          'effects':['C1', 'C2', 'C3', 'X1', 'X2', 'X3', 'X4']},
   selection={'method':'forward','details':'all'})

The following commands display some of the tables that are produced by this action call:

print(m.SelectionInfo)
print(m["StepDetails.Step1.EntryCandidates"])
print(m["Summary.SelectionSummary"])
print(m["Summary.StopReason"])
print(m["Summary.SelectionReason"])
print(m["Summary.SelectedEffects"])
print(m["SelectedModel.Dimensions"])
print(m["SelectedModel.FitStatistics"])
print(m["SelectedModel.ParameterEstimates"])

The following command displays all the tables that are produced by this action call along with their full pathnames:

print(m)

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

Cox 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 phreg action set and then uses the lcox action to fit a cox regression model to the getStarted data table. The table parameter names the input data table to be analyzed. The class parameter specifies that the variables C1–C3 are classification variables; this parameter corresponds to the CLASS statement in the PHSELECT procedure. The model parameter specifies the model:the depVar subparameter specifies the variable Time as the response variable, the censor subparameter specifies the variable Status as the censoring variable, the cenVals subparameter list the values 0 as the value of Status that represents a censored observation, and the effects subparameter lists the three classification variables C1–C4 and four continuous explanatory variables, X1–X4. The itHist subparameter in the optimization parameter list produces a table that summarizes the steps of the optimization. The outputTables parameter outputs the fitted parameter estimates to the mycas.pe data table.

m <- cas.builtins.loadActionSet(s, actionset='phreg')
m <- cas.phreg.cox(s,
   table='getStarted',
   class=list('C1','C2','C3'),
   model=list(depVar='Time',
              censor='Status',
              censVals=(0),
              effects=list('C1', 'C2','C3','X1', 'X2', 'X3', 'X4')),
   optimization=list(itHist='summary'),
   outputTables=list(names=list(parameterestimates='pe'))
)

The following commands display the tables that are produced by this action call:

print(m$ModelInfo)
print(m$NObs)
print(m$ClassInfo)
print(m$IterHistory)
print(m$ConvergenceStatus)
print(m$Dimensions)
print(m$FitStatistics)
print(m$ParameterEstimates)
print(m$Timing)

The full model has many nonsignificant effects; see the CASL version of this example for details about the results of this analysis. You can perform forward selection on these data by using the following program. Effects that provide the best improvement for the default selection criterion, the Schwarz Bayesian information criterion, SBC, are added until no more effects can improve the selection criterion. The method subparameter in the selection parameter enables you to choose the selection method, and the details subparameter produces all tables that are related to model selection.

m <- cas.phreg.cox(s,
   table='getStarted',
   class=list('C1', 'C2','C3'),
   model=list(depVar='Time',
              censor='Status',
              censVals=(0),
              effects=list('C1', 'C2','C3','X1', 'X2', 'X3', 'X4')),
   selection=list(method='forward',details='all')
)

The following commands display some of the tables that are produced by this action call:

print(m$SelectionInfo)
print(m$StepDetails.Step1.EntryCandidates)
print(m$Summary.SelectionSummary)
print(m$Summary.StopReason)
print(m$Summary.SelectionReason)
print(m$Summary.SelectedEffects)
print(m$SelectedModel.Dimensions)
print(m$SelectedModel.FitStatistics)
print(m$SelectedModel.ParameterEstimates)

The following command displays all the tables that are produced by this action call along with their full pathnames:

print(m)

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

Last updated: September 17, 2026