Tutorials › Exam SRM - Statistics for Risk Modeling › Selecting Categorical Predictors As Blocks

Exam SRM · Subset Selection Methods · Tutorial 169 of 926

Selecting Categorical Predictors As Blocks

Learn to represent a categorical predictor with indicators, evaluate it as one block, and recognize the risks of selecting its columns separately.

Intermediate 9 min read

What You'll Learn

  • Represent a nominal factor with a reference level and the appropriate number of indicator columns
  • Define a block test for the factor’s joint contribution to a regression model
  • Calculate a partial F-statistic for adding or removing a factor as a block
  • Explain why separate column selection can depend on the chosen reference category
  • Count a factor’s fitted coefficients correctly when comparing candidate models

Why a Categorical Predictor Is Often a Block

A categorical predictor with several levels is usually represented in a regression model by several indicator columns. Those columns are not separate variables in the original data: together, they encode one characteristic, such as territory or payment method. Selecting only some of them can make the model depend on an arbitrary coding choice and can leave the factor’s meaning unclear.

The usual subset-selection approach is therefore to treat all the indicator columns for a factor as a single block. The factor enters the model with all its required columns or leaves with all of them. This preserves a consistent interpretation and lets the selection decision address whether the factor contributes overall, after accounting for the other predictors.

Definition: For a categorical predictor with \(k\) observed levels in a linear regression model that includes an intercept, choose one level as the reference and represent the other \(k-1\) levels with indicator variables. The \(k-1\) associated regression coefficients form the factor’s block. Block selection adds or removes those coefficients together.

For example, a nominal factor with four levels, such as territories North, South, East, and West, can use North as the reference. The three indicator columns identify South, East, and West. Each coefficient describes the difference from North, conditional on the other predictors. The factor requires three slopes, not one. If all \(k\) indicators and an intercept are included, their columns are linearly dependent; omitting one level avoids this redundant representation.

A different reference level gives different individual coefficient values, but a complete set of \(k-1\) contrasts spans the same model space. Thus, the fitted values from the full factor block do not depend on which level is selected as reference. Selection based on individual columns, however, can depend on that choice.

The Joint Test for a Factor

The block’s overall contribution can be tested by comparing two nested models fitted to the same observations. The reduced model contains the other predictors but omits the factor. The full model contains those same predictors plus all \(q=k-1\) indicator columns. Let \(\mathrm{SSE}_R\) and \(\mathrm{SSE}_F\) denote their residual sums of squares. Under the null hypothesis that the factor contributes no additional linear effect, the joint hypothesis is that all \(q\) factor coefficients equal zero.

Model and assumptions: For the classical partial F-test, assume a linear model \(Y=X\beta+\varepsilon\), with errors that are independent and normally distributed with mean zero and common variance \(\sigma^2\). The reduced and full models must be nested and fitted to the same response observations; their design matrices must have the stated ranks. The test evaluates the factor’s block conditional on the predictors already in the model. If these assumptions or the common-sample condition fail, this classical F reference distribution may not apply.

If the full model estimates \(p_F\) coefficients, including the intercept, its residual degrees of freedom are \(n-p_F\). The partial F-statistic for adding the block is:

$$ F=\frac{(\mathrm{SSE}_R-\mathrm{SSE}_F)/q} {\mathrm{SSE}_F/(n-p_F)}. $$

The numerator measures the reduction in residual sum of squares per added coefficient. The denominator estimates the error variance using the full model. Under the null hypothesis and the stated assumptions, the statistic follows an \(F\) distribution with \(q\) and \(n-p_F\) degrees of freedom. A selection procedure can compare this statistic with its specified entry or removal rule. A significant joint test is evidence of conditional association, not proof that the factor has a causal effect.

Why the Partial F Formula Works

The formula compares two ways of estimating the same error variance under the null hypothesis. The full model cannot have a larger SSE than the reduced model, because it includes every reduced-model term and adds \(q\) parameters. If the factor truly contributes nothing, the expected reduction in SSE is due to fitting noise. Under the normal linear-model assumptions, that reduction, divided by \(q\), estimates \(\sigma^2\); the full-model residual mean square also estimates \(\sigma^2\).

More specifically, under the null, the scaled quantities \((\mathrm{SSE}_R-\mathrm{SSE}_F)/\sigma^2\) and \(\mathrm{SSE}_F/\sigma^2\) have chi-squared distributions with \(q\) and \(n-p_F\) degrees of freedom, respectively, and are independent for nested least-squares models. Dividing each by its degrees of freedom and taking their ratio gives the stated F-statistic. This justification depends on the model assumptions; a small SSE reduction alone does not establish that a block is unimportant without considering the residual variance and degrees of freedom.

Worked Example: Testing a Four-Level Territory Factor

A hypothetical insurer models claim severity using two existing slopes and a four-level territory factor. On the same 48 claims, the model without territory has \(\mathrm{SSE}_R=120\). Adding the complete territory block gives \(\mathrm{SSE}_F=108\). Use a stipulated forward-entry rule requiring \(F\geq 2.00\). Should the factor enter?

Method. Treat territory as one block. Four levels require \(q=4-1=3\) indicator coefficients. The full model has an intercept, two existing slopes, and three territory slopes, so \(p_F=1+2+3=6\), and its residual degrees of freedom are \(48-6=42\).

The reduction in SSE is \(120-108=12\). The numerator mean square is \(12/3=4\). The full-model residual mean square is \(108/42=18/7\), approximately \(2.5714\). Therefore,

$$ F=\frac{12/3}{108/42} =\frac{4}{18/7} =\frac{14}{9} \approx 1.5556. $$

Since \(1.5556<2.00\), territory does not meet the stated entry rule. The comparison uses the factor’s joint contribution, conditional on the two existing slopes. Common mistake avoided: counting the territory factor as one coefficient would use the wrong numerator degrees of freedom. The block has three coefficients. As a check, \(108<120\), as required when the full model adds predictors, and the calculated F-statistic is positive.

Why Column-by-Column Selection Can Mislead

Testing one indicator coefficient at a time asks a narrower question than testing the factor as a block. It asks whether one particular contrast is zero, conditional on the other terms currently included. It does not directly ask whether all contrasts for the factor are zero. A factor can have a modest joint contribution spread across several contrasts even when none is individually compelling; conversely, one contrast may appear strong while the block’s overall test does not satisfy a selection rule.

There is also a coding issue. With three levels A, B, and C, using A as the reference gives indicators for B and C. Using B as the reference gives indicators for A and C. The columns and their coefficients have changed, although the complete factor model represents the same fitted-value space. A column-by-column search can retain a different-looking subset after that recoding. In contrast, a joint test of the complete factor block is invariant to a full-rank change of contrasts for that factor.

This does not mean that all indicators must always be retained in every possible modeling strategy. It means that ordinary subset selection should make a deliberate choice: if the scientific or predictive unit is the factor, compare models with the whole factor included or excluded. A procedure that selects individual contrasts is making a different, coding-sensitive modeling choice and should not be described as selecting the categorical predictor as a whole.

Worked Example: A Joint Test Is Not a Test of One Indicator

A hypothetical model for claim frequency has an intercept and two other slopes. A three-level enrollment-channel factor is represented by two indicators. On the same 32 policies, the model omitting the factor has \(\mathrm{SSE}_R=200\); the model with both indicators has \(\mathrm{SSE}_F=176\). A nonstandard column-by-column diagnostic also reports that adding indicator A alone gives \(\mathrm{SSE}=190\). Calculate the joint block statistic and the partial statistic for adding A alone. Explain why the latter does not replace the block test.

Joint block test. The factor has \(q=3-1=2\) coefficients. The full model has five coefficients in total: an intercept, two existing slopes, and two factor slopes. Its residual degrees of freedom are \(32-5=27\). The block reduces SSE by \(200-176=24\), giving a numerator mean square of \(24/2=12\). The full-model residual mean square is \(176/27\approx6.5185\). Thus,

$$ F_{\text{block}}=\frac{24/2}{176/27} =\frac{81}{44} \approx1.8409. $$

Single-indicator diagnostic. The model with A alone has an intercept, two existing slopes, and one indicator, so it has four coefficients and \(32-4=28\) residual degrees of freedom. Its SSE reduction is \(200-190=10\), and its residual mean square is \(190/28\approx6.7857\). Therefore,

$$ F_A=\frac{10}{190/28} =\frac{28}{19} \approx1.4737. $$

The first statistic tests both factor coefficients jointly; the second tests only the particular A contrast in that reduced coding. They answer different questions. Common mistake avoided: using a single-indicator test as if it tested whether the entire three-level factor matters. The check is that the joint fit reduces SSE by 24, while the single-indicator fit reduces it by only 10; both reductions are nonnegative, and each calculation uses the residual degrees of freedom for its own full model.

Counting Parameters and Applying Selection Rules

A block’s size matters to model comparisons that account for model dimension. If a selection rule penalizes the number of fitted coefficients, a \(k\)-level factor with an intercept contributes \(k-1\) slopes to that count. Calling it “one predictor” in the data description does not make its statistical cost one coefficient. Similarly, a factor’s block removal frees \(k-1\) degrees of freedom, not one.

Worked Example: Counting a Block Correctly Under an Entry Rule

A hypothetical severity model is fitted to 40 claims. The reduced model has an intercept and two slopes, with \(\mathrm{SSE}_R=150\). A five-level claim-source factor is added as a complete block, producing \(\mathrm{SSE}_F=110\). The procedure’s entry rule is \(F\geq4.00\). Determine whether the block meets that rule.

Method. Five levels require \(q=5-1=4\) factor coefficients. The full model has \(p_F=1+2+4=7\) coefficients, leaving \(40-7=33\) residual degrees of freedom. The SSE reduction is \(150-110=40\), so the numerator mean square is \(40/4=10\). The full-model residual mean square is \(110/33=10/3\). Hence,

$$ F_{\text{block}}=\frac{40/4}{110/33} =\frac{10}{10/3} =3.00. $$

Since \(3.00<4.00\), the factor does not meet the stated entry rule. If one incorrectly treated the factor as one degree of freedom, the numerator would be \(40/1=40\), producing \(F=40/(10/3)=12.00\) and the opposite decision. That is not a valid block test: it assigns four coefficients’ worth of fit improvement to one degree of freedom. The correct result is checked by confirming that four coefficients were added and that the full model has 33 residual degrees of freedom.

Practical Checks Before Selecting a Factor

Before using a categorical predictor in forward or backward subset selection, verify how it is encoded and what the selection rule treats as a candidate. In a standard reference-level representation, check that the factor’s indicators are all present in the candidate block and that the reference level is not also represented by a redundant indicator alongside an intercept. Then confirm that all compared models use the same response observations and that their coefficient counts and residual degrees of freedom are correct.

  • State the unit of selection. Is the candidate a complete factor, or an individual contrast? Do not interpret one as the other.
  • Count the block’s degrees of freedom. With \(k\) observed levels and an intercept, the usual nominal-factor block has \(k-1\) coefficients, provided the design is full rank.
  • Use a conditional comparison. The factor’s joint contribution is assessed after accounting for the other predictors in the model.
  • Check the coding. The complete factor model is invariant to a valid change of contrasts; an individually selected indicator generally is not.
  • Use the specified rule. A partial F-statistic is meaningful only in the context of the test or selection threshold being applied.

The central distinction is between a factor as a meaningful categorical predictor and the columns used to encode it. Block selection respects that distinction. It also makes the degrees-of-freedom cost explicit, which is essential for fair model comparisons and for interpreting what the selected model actually contains. This treatment of subset selection is aligned with the SOA Exam SRM (Statistics for Risk Modeling) syllabus.

Check Your Understanding

For each problem, treat the factor as a block unless the question explicitly asks about one indicator.

  1. A four-level rating band is added to a regression with an intercept and three existing slopes. How many coefficients does the block add? (Answer: 3 coefficients.)
  2. A three-level factor is added to a model fitted to 30 observations. The full model has an intercept, two existing slopes, and both factor indicators. What are the full-model residual degrees of freedom? (Answer: 25.)
  3. A two-level factor is added to a reduced model with \(\mathrm{SSE}_R=90\). The full-model SSE is 84, and the full model has 20 residual degrees of freedom. Calculate the partial F-statistic. (Answer: \(F=(6/1)/(84/20)=10/7\approx1.4286\).)
  4. A five-level factor is tested jointly. The reduced model has SSE 160, and the full model has SSE 136 with 34 residual degrees of freedom. Calculate the partial F-statistic. (Answer: \(q=4\), \(F=(24/4)/(136/34)=1.50\).)
  5. For a three-level factor, one valid coding uses indicators for B and C with A as reference. Another uses indicators for A and C with B as reference. Which comparison is invariant to this recoding: the joint test of the complete factor block, or a test of just the C indicator? (Answer: The joint test of the complete factor block is invariant; a single-indicator test is coding-dependent.)
Clinical Biostats