Tutorials › Exam SRM - Statistics for Risk Modeling › Building A Linear Predictor

Exam SRM · Exponential-Family Models · Tutorial 285 of 926

Building A Linear Predictor

Build and calculate linear predictors from model coefficients and observation-level predictor values, including indicator and interaction terms.

Intermediate 10 min read

What You'll Learn

  • Write a linear predictor as an intercept plus coefficient-weighted predictor values
  • Represent predictors and coefficients with a design matrix and vector
  • Encode categorical predictors using indicator columns and a stated reference category
  • Construct interaction columns from the predictor values for each observation
  • Calculate and check linear predictors for individual observations
  • Identify common errors involving intercepts, coding, and arithmetic

Why Build a Linear Predictor?

A model often uses several characteristics of an observation to summarize how its conditional response changes across observations. The linear predictor is the part of the model that combines those characteristics linearly, weighting each predictor by a coefficient and adding an intercept. Constructing it correctly requires care: a category may need indicator columns, an interaction needs its own column, and every coefficient must be paired with the right predictor value.

This tutorial focuses on constructing and evaluating that combination. It does not determine which response distribution or link function should be chosen for a particular problem. Those are separate modeling decisions. The construction here is aligned with the SOA Exam SRM (Statistics for Risk Modeling) syllabus.

Definition: For observation \(i\) and \(p\) predictor columns, a linear predictor is $$ \eta_i=\beta_0+\beta_1x_{i1}+\beta_2x_{i2}+\cdots+\beta_px_{ip}. $$ Here, \(\beta_0\) is the intercept, \(\beta_j\) is the coefficient of predictor column \(j\), and \(x_{ij}\) is observation \(i\)'s value in that column. If a model includes an interaction or a transformed predictor, that term is represented by its own predictor column.

The word linear refers to the form in the coefficients: each coefficient is multiplied by a known predictor value, and the products are added. A predictor column itself need not be an untransformed measurement. For example, a column can contain the square of a measurement, an indicator for membership in a category, or the product of two measurements. The model is still linear in its coefficients when each coefficient enters as a first power in this sum.

From a Formula to a Design Matrix

For \(n\) observations, put the predictor values for observation \(i\) in a row vector and stack the rows into a design matrix. Include a column of ones for the intercept. The coefficient vector contains the intercept followed by the coefficients in the same order as the remaining columns.

$$ \mathbf{X}= \begin{bmatrix} 1 & x_{11} & x_{12} & \cdots & x_{1p}\\ 1 & x_{21} & x_{22} & \cdots & x_{2p}\\ \vdots & \vdots & \vdots & \ddots & \vdots\\ 1 & x_{n1} & x_{n2} & \cdots & x_{np} \end{bmatrix}, \qquad \boldsymbol{\beta}= \begin{bmatrix} \beta_0\\ \beta_1\\ \vdots\\ \beta_p \end{bmatrix}, \qquad \boldsymbol{\eta}=\mathbf{X}\boldsymbol{\beta}. $$

The \(i\)th component of \(\boldsymbol{\eta}\) is the linear predictor for observation \(i\). Matrix notation is not a different model; it is a compact way to perform the same additions and multiplications for many observations. The order of columns in \(\mathbf{X}\) must match the order of coefficients in \(\boldsymbol{\beta}\).

Why the matrix formula holds: Row \(i\) of \(\mathbf{X}\) is \((1,x_{i1},\ldots,x_{ip})\). Multiplying that row by \(\boldsymbol{\beta}\) gives \(1\beta_0+x_{i1}\beta_1+\cdots+x_{ip}\beta_p\), which is exactly the defined \(\eta_i\). Stacking these row-by-row products gives \(\mathbf{X}\boldsymbol{\beta}=\boldsymbol{\eta}\).

The intercept is included by the column of ones: its contribution to every row is \(1\cdot\beta_0=\beta_0\). If an intercept is intended, omitting that column omits the intercept from the calculation. Conversely, adding a second constant column duplicates the same contribution and changes the model specification.

Numeric Predictors, Indicators, and Interactions

A numeric predictor column should use the units stated in the model. If the model defines \(x\) in thousands of dollars, an observed value of $24,000 is entered as \(24\), not \(24{,}000\). Centering or rescaling a predictor is also possible, but the defined version—not the raw measurement—must be used consistently.

A categorical predictor with \(K\) categories is commonly represented by \(K-1\) indicator columns when an intercept is present. One category is the reference category. Each indicator is 1 when the observation belongs to its named category and 0 otherwise; the reference category has 0 in all those indicator columns. This convention allows the intercept to represent the reference category's baseline when other numeric predictors equal zero. Different coding choices are possible, but the coding and coefficient interpretation must agree.

An interaction represents a term whose contribution depends on multiple predictor values. For numeric predictors \(x\) and \(z\), an \(xz\) interaction column contains their product for each observation. For a numeric predictor \(x\) and a 0-or-1 indicator \(g\), the column \(xg\) is zero when \(g=0\) and equals \(x\) when \(g=1\). The product column has a separate coefficient; it does not replace either of the original predictor columns.

Worked Example: Evaluating an Intercept, a Numeric Predictor, and an Indicator

A hypothetical insurer uses the predictor \(\eta_i=-0.4+0.08x_i+0.3r_i\), where \(x_i\) is the number of years above age 40 and \(r_i=1\) for a renewal policy and \(r_i=0\) otherwise. Calculate \(\eta_i\) for a renewal policyholder aged 45. No response distribution, interest rate, or mortality assumption is specified or needed for this predictor calculation.

Method. Substitute the defined predictor values into the formula. Age 45 is 5 years above 40, so \(x_i=45-40=5\). The policy is a renewal, so \(r_i=1\).

The three contributions are \(\beta_0=-0.4\), \(0.08x_i=(0.08)(5)=0.40\), and \(0.3r_i=(0.3)(1)=0.30\). Therefore,

$$ \eta_i=-0.4+0.40+0.30=0.30. $$

Check. The numeric and indicator contributions sum to \(0.70\), which offsets the intercept of \(-0.40\) to give \(0.30\). A common mistake is to substitute the person's age, 45, for \(x_i\), even though the model defines \(x_i\) as years above age 40. That incorrect substitution would give \(-0.4+(0.08)(45)+0.3=3.5\), not \(0.30\).

Worked Example: Building and Multiplying a Design Matrix

A hypothetical maintenance model uses mileage \(x\), measured in thousands of miles, and region, with North as the reference category. Let \(S=1\) for South and \(W=1\) for West, and let the model include a South-by-mileage interaction. For three vehicles, the data are: North with \(x=2\), South with \(x=3\), and West with \(x=1\). The coefficient vector, in column order, is \(\boldsymbol{\beta}=(0.5,0.2,-0.3,0.4,0.1)^\mathsf{T}\), corresponding to columns \(1,x,S,W,xS\). Find all three predictors. No response distribution is assumed for this calculation.

Method. For each row, record the intercept column \(1\), the mileage, the two region indicators, and the product \(xS\). North is the reference, so both region indicators are 0 for a North vehicle.

$$ \mathbf{X}= \begin{bmatrix} 1&2&0&0&0\\ 1&3&1&0&3\\ 1&1&0&1&0 \end{bmatrix}, \qquad \boldsymbol{\beta}= \begin{bmatrix} 0.5\\0.2\\-0.3\\0.4\\0.1 \end{bmatrix}. $$

For North, the interaction is \(xS=(2)(0)=0\), so \(\eta_1=(1)(0.5)+(2)(0.2)+(0)(-0.3)+(0)(0.4)+(0)(0.1)=0.5+0.4=0.9\).

For South, \(xS=(3)(1)=3\), so \(\eta_2=(1)(0.5)+(3)(0.2)+(1)(-0.3)+(0)(0.4)+(3)(0.1)=0.5+0.6-0.3+0+0.3=1.1\).

For West, \(xS=(1)(0)=0\), so \(\eta_3=(1)(0.5)+(1)(0.2)+(0)(-0.3)+(1)(0.4)+(0)(0.1)=0.5+0.2+0.4=1.1\).

Check. The South indicator and interaction are active only for the South vehicle; the West indicator is active only for the West vehicle. The matrix product therefore gives \(\boldsymbol{\eta}=(0.9,1.1,1.1)^\mathsf{T}\). A common mistake is to enter \(xS=1\) for every South observation instead of multiplying the actual mileage by the indicator.

A Predictor Used on a Model Scale

A linear predictor can be used on a scale associated with a model's conditional distribution. For example, a Poisson model may specify that the logarithm of the conditional mean equals the linear predictor. In that case, after calculating \(\eta_i\), the corresponding mean is obtained by exponentiating it. This example uses that stated relationship only to illustrate why an arithmetic error in the predictor carries through to the mean.

Worked Example: Checking an Interaction in a Poisson Predictor

A hypothetical count model assumes \(Y_i\mid z_i,g_i\sim\operatorname{Poisson}(\lambda_i)\), with conditional mean \(\lambda_i\), and specifies \(\log(\lambda_i)=\eta_i=0.2+0.4z_i-0.5g_i+0.2z_ig_i\). For \(z_i=2\) and \(g_i=1\), calculate the interaction column, \(\eta_i\), and \(\lambda_i\). The distribution and its parameter are stated as Poisson with conditional mean \(\lambda_i\); no interest rate or mortality assumption is involved.

Method. First calculate the product column, \(z_ig_i=(2)(1)=2\). Then substitute every value, including that product, into the predictor:

$$ \eta_i=0.2+(0.4)(2)-(0.5)(1)+(0.2)(2) =0.2+0.8-0.5+0.4 =0.9. $$

Because the model states \(\log(\lambda_i)=\eta_i\), exponentiate the calculated predictor: \(\lambda_i=e^{0.9}\approx2.4596\). The conditional mean is therefore approximately \(2.4596\) counts. The interaction column is \(2\), not \(1\), because it is the product of the two stated predictor values.

Check. Substituting the resulting mean back into the model scale gives \(\log(2.4596)\approx0.9000\), allowing for rounding. A common arithmetic error is to report \(\eta_i=1.1\); the displayed terms add to \(0.9\). That incorrect predictor would instead give \(e^{1.1}\approx3.0042\), so checking the sum before exponentiating is essential. The mean is rounded to four decimal places.

A Reliable Construction Process

For a model with several predictor terms, a short, explicit workflow reduces errors. It is especially useful when the problem supplies a formula but asks for a design matrix, or gives a matrix and asks for a particular observation's predictor.

1
List the model columns.
Write the intercept and each numeric, indicator, transformed, or interaction term in a fixed order.
2
Translate each observation into those columns.
Use the units and category coding specified in the model. Calculate product or transformation columns from the observed values.
3
Align coefficients with columns.
Check that the coefficient vector follows exactly the same order as the design-matrix columns.
4
Multiply and add row by row.
For each observation, calculate the intercept contribution and every coefficient-times-column contribution before summing.
5
Check the result on the specified scale.
Confirm the arithmetic and, if the model states a relationship to another scale, apply that relationship only after \(\eta_i\) is correct.

Common Construction Errors

Linear-predictor calculations are simple sums, but errors in interpreting the model can be more consequential than arithmetic mistakes. The following checks address frequent sources of error.

  • Using the wrong units. If a predictor is defined in thousands, convert the measurement before entering it. Do not use a raw dollar amount where the model calls for thousands of dollars.
  • Misreading an indicator. An indicator is 1 when its stated condition holds and 0 otherwise. It is not the category's label or an arbitrary category code.
  • Forgetting a product column. If the model includes \(xz\), calculate \(xz\) for each observation and multiply it by its own coefficient. Do not silently omit the interaction or treat it as another name for \(x\) or \(z\).
  • Misaligning a matrix and coefficient vector. A correct set of columns paired with coefficients in the wrong order produces a different predictor. Label columns and coefficients before multiplying.
  • Confusing the predictor with a response-scale quantity. The value \(\eta_i\) is the linear combination defined by the model. If a model specifies a transformation between \(\eta_i\) and a conditional mean, apply that transformation separately and only as stated.

In actuarial applications, predictors may encode policy characteristics, exposure measures, or features of a hypothetical risk classification. The arithmetic does not make a model appropriate by itself: the variables, coding, and model form must still match the question and available data. But once those are specified, the design matrix provides a systematic way to calculate each observation's predictor and to audit the calculation.

Check Your Understanding

For each problem, identify the relevant columns and calculate the requested predictor quantities.

  1. A model uses \(\eta_i=0.6-0.15x_i\). For an observation with \(x_i=4\), calculate \(\eta_i\). (Answer: \(\eta_i=0.0000\))
  2. A hypothetical policy model uses \(\eta_i=-0.2+0.5t_i+0.7r_i\), where \(t_i\) is measured in years and \(r_i=1\) for a renewal policy. For \(t_i=1.5\) and \(r_i=1\), calculate the predictor. (Answer: \(\eta_i=1.25\))
  3. A predictor is \(\eta_i=0.1+0.3x_i-0.2g_i+0.4x_ig_i\), with \(x_i=2\) and \(g_i=1\). Calculate the interaction column and predictor. (Answer: \(x_ig_i=2\) and \(\eta_i=1.3\))
  4. A model has columns \(1,x,S,W\) and coefficients \((0.2,-0.1,0.5,-0.3)\), where North is the reference, \(S=1\) for South, and \(W=1\) for West. For a West observation with \(x=4\), calculate its design-matrix row and predictor. (Answer: row \((1,4,0,1)\) and \(\eta_i=-0.5\))
  5. A hypothetical count model assumes \(Y_i\mid x_i,g_i\sim\operatorname{Poisson}(\lambda_i)\) and \(\log(\lambda_i)=\eta_i=-0.3+0.25x_i+0.4g_i\). For \(x_i=3\) and \(g_i=1\), calculate \(\eta_i\) and \(\lambda_i\), rounding the mean to four decimal places. (Answer: \(\eta_i=0.85\) and \(\lambda_i\approx2.3396\))
Clinical Biostats