FOREST Procedure

Residual Sum of Squares Importance Method

The residual sum of squares (RSS) for regression trees is defined as

normal upper R normal upper S normal upper S equals sigma-summation Underscript lamda Endscripts sigma-summation Underscript i element-of lamda Endscripts left-parenthesis y Subscript i Baseline minus ModifyingAbove y With caret Subscript lamda Superscript upper T Baseline right-parenthesis squared

where

  • i is an observation on leaf lamda

  • y Subscript i is the predicted value of the response variable of observation i

  • ModifyingAbove y With caret Subscript lamda Superscript upper T is the actual value of the response variable on leaf lamda

The residual sum of squares (RSS) for classification trees is defined as

normal upper R normal upper S normal upper S equals sigma-summation Underscript lamda Endscripts sigma-summation Underscript normal upper Phi Endscripts upper N Subscript normal upper Phi Superscript lamda Baseline left-bracket sigma-summation Underscript tau not-equals normal upper Phi Endscripts left-parenthesis upper P Subscript tau Superscript lamda Baseline right-parenthesis squared plus left-parenthesis 1 minus upper P Subscript normal upper Phi Superscript lamda Baseline right-parenthesis squared right-bracket

where

  • normal upper Phi is the actual response level

  • upper N Subscript normal upper Phi Superscript lamda is the number of observations on leaf lamda that have response level normal upper Phi

  • upper P Subscript tau Superscript lamda is the posterior probability for the response level tau on leaf lamda

  • upper P Subscript normal upper Phi Superscript lamda is the posterior probability for the actual response level normal upper Phi on leaf lamda

For a single tree in the forest, the RSS-based metric measures variable importance based on the change in RSS when a split is found at a node. The change for variable v is

normal upper Delta Subscript d Superscript v Baseline equals normal upper R normal upper S normal upper S Subscript d Baseline minus sigma-summation Underscript i Endscripts normal upper R normal upper S normal upper S Subscript i Superscript d

where

  • d denotes the node

  • i denotes the index of a child that this node includes

  • normal upper R normal upper S normal upper S Subscript d is the RSS if the node is treated as a leaf

  • normal upper R normal upper S normal upper S Subscript i Superscript d is the RSS of the node after it has been split

If the change in RSS is negative (which is possible when you use the validation set), then the change is set to 0.

The RSS-based importance for a single variable, v, in a single tree is then defined as

sigma-summation Underscript d equals 1 Overscript upper D Endscripts normal upper Delta Subscript d Superscript v

where D is the total number of nodes in which v was used as the splitting variable.

The RSS variable importance for the forest is the average of the RSS variable importance across all trees in the forest.

Variable Interaction Importance

In some cases, interactions of variables are of more interest than a single variable. When you specify the VII= option in the PROC FOREST statement, the procedure computes variable interaction importance as follows.

The two-way interaction importance for variables v and w is

sigma-summation Underscript d comma e Endscripts StartFraction normal upper Delta Subscript d Superscript v Baseline plus normal upper Delta Subscript e Superscript w Baseline Over normal upper Delta Subscript d Superscript v Baseline EndFraction

where

  • d and e denote nodes, where node d is the parent of node e

  • v and w are variables, where v is the splitting variable for node d and w is the splitting variable for node e

  • This summation is across all parent-child node combinations with respect to the variables v and w.

The three-way interaction importance for variables v, w, and x is

sigma-summation Underscript d comma e comma f Endscripts StartFraction normal upper Delta Subscript d Superscript v Baseline plus normal upper Delta Subscript e Superscript w Baseline plus normal upper Delta Subscript f Superscript x Baseline Over normal upper Delta Subscript d Superscript v Baseline plus normal upper Delta Subscript e Superscript w Baseline EndFraction

where

  • d, e, and f denote nodes, where node d is the parent of node e, which is the parent of node f

  • v, w, and x are variables, where v is the splitting variable for node d, w is the splitting variable for node e, and x is the splitting variable for node f

  • This summation is across all parent-child-grandchild node combinations with respect to the variables v, w, and x.

When comparing variable importance values, you should compare a two-way interaction only with another two-way interaction, or a three-way interaction only with another three-way interaction. Comparing a two-way interaction to a three-way interaction is not meaningful, because the values for the importance are not on the same scale.

In addition to calculating the variable interaction importance, you can also generate SAS DATA step code to create interaction variables and save the code to a file by using the VIICODE statement. When you run the generated SAS DATA step code on the original data or on new data, interaction variables are created.

Created interaction variables are of the form upper W plus upper V, upper W minus upper V, or upper W times upper V, where the values used in the calculations come from the variables whose interactions are determined to be important. The values used are as follows:

  • For continuous variables, the raw value of the variable is used.

  • For categorical variables, the proportion of observations in the training set that is assigned to a specific branch is used.

Last updated: August 06, 2026