Tutorials › Exam PA - Predictive Analytics › Create PCA Scores from Telematics Data

Exam PA · End-to-End Case Analysis · Tutorial 885 of 966

Create PCA Scores from Telematics Data

Standardize telematics features, interpret principal components and their scores, and decide whether the retained components are appropriate predictors for a claim model.

Advanced 12 min read

What You'll Learn

  • Explain why PCA is usually applied to standardized telematics features measured on different scales
  • Calculate eigenvalues, component directions, scores, and proportions of variance explained in simple cases
  • Interpret component directions in the context of driving behavior
  • Explain why retaining components by explained variance alone can discard outcome-relevant information
  • Apply a training-set PCA transformation consistently when creating scores for model use

Why Create PCA Scores from Telematics Data?

A telematics file may contain several related measurements: hard-braking frequency, rapid-acceleration frequency, speeding time, and night-driving share. Including all of them as separate predictors can make a model difficult to summarize, particularly when the measurements are strongly correlated. Principal component analysis (PCA) provides a way to replace correlated numeric features with new, uncorrelated scores that summarize directions of variation in those features.

PCA is an unsupervised feature-creation method: it uses the feature values, not the claim outcome, to choose the component directions. That distinction matters. A component explaining a large share of feature variation is not automatically a useful predictor of claim frequency or severity. This tutorial is aligned with the SOA Exam PA (Predictive Analytics) syllabus.

Definition: For a set of numeric features, a principal component is a linear combination of the features chosen to capture variation. The first principal component has the greatest possible variance among linear combinations with coefficient vector of length one. Each later component has the greatest remaining variance subject to being perpendicular to the earlier component directions.

Standardization, Components, and Scores

PCA is sensitive to scale. If one feature is measured in seconds and another in a proportion from zero to one, the feature with the larger numerical scale can dominate a PCA based on the covariance matrix. When the features use different units or have substantially different scales, standardize each feature using its training-set mean and standard deviation:

$$ z_{ij}=\frac{x_{ij}-\bar{x}_j}{s_j} $$

Here \(x_{ij}\) is observation \(i\)'s value for feature \(j\), \(\bar{x}_j\) is the training-set mean, and \(s_j\) is the training-set standard deviation. PCA on these standardized features is based on their correlation matrix. If features are already on comparable scales and their variance differences are meaningful, standardizing automatically may not be appropriate; the choice should reflect the intended analysis.

Let \(Z\) denote the matrix of standardized observations and \(R\) their correlation matrix. PCA finds unit-length eigenvectors of \(R\). The eigenvalue for a component is the variance of its scores. The score for an observation is its standardized feature vector projected onto the component direction.

$$ R\mathbf{v}_k=\lambda_k\mathbf{v}_k,\qquad \|\mathbf{v}_k\|=1,\qquad \text{score}_{ik}=\mathbf{z}_i^\mathsf{T}\mathbf{v}_k $$

The entries of \(\mathbf{v}_k\) are the component coefficients, often called loadings in applied work. More precisely, software such as R's prcomp reports these eigenvectors as rotation. Some sources use “loadings” for correlations between original features and component scores instead, so check the convention when interpreting a table.

The total variance in the standardized features is the sum of the eigenvalues, which equals the number of features. The proportion of variance explained by component \(k\) is its eigenvalue divided by that total. A component's sign is arbitrary: multiplying all its coefficients and scores by \(-1\) describes the same component.

Worked PCA Calculations

Worked Example: Two Correlated Driving Measures

A hypothetical insurer has two standardized telematics features: hard-braking frequency \(Z_1\) and rapid-acceleration frequency \(Z_2\). Their correlation is \(0.8\). Find the principal components and the scores for a policy with standardized feature values \((1,0.5)\). Report the proportion of total feature variance explained by each component.

Method and correlation matrix. With two standardized features and correlation \(0.8\), the correlation matrix is:

$$ R= \begin{pmatrix} 1&0.8\\ 0.8&1 \end{pmatrix} $$

The unit eigenvectors are \(\mathbf{v}_1=(1,1)/\sqrt{2}\) and \(\mathbf{v}_2=(1,-1)/\sqrt{2}\). Multiplying \(R\) by the first vector gives \(1.8\mathbf{v}_1\), so \(\lambda_1=1.8\). Multiplying it by the second gives \(0.2\mathbf{v}_2\), so \(\lambda_2=0.2\).

The total standardized feature variance is \(2\). Thus the proportions explained are \(1.8/2=0.90\) and \(0.2/2=0.10\). The first component represents a shared tendency toward more hard braking and more rapid acceleration; the second represents contrast between the two measures.

Scores. For the policy with \(\mathbf{z}=(1,0.5)\), the first score is \((1+0.5)/\sqrt{2}=1.5/\sqrt{2}=1.0607\). The second is \((1-0.5)/\sqrt{2}=0.5/\sqrt{2}=0.3536\). Scores are rounded to four decimal places. The check is that the two eigenvalues add to \(2\), as required for two standardized features.

Common mistake avoided: interpreting a coefficient of \(1/\sqrt{2}\) as a percentage of variance. The component's variance is its eigenvalue; here its explained proportion is \(90\%\), not either coefficient.

Worked Example: A Common Telematics Pattern

Three standardized features—hard-braking frequency, rapid-acceleration frequency, and speeding time—have pairwise correlations of \(0.6\). Find the leading component, its variance explained, and its score for a policy with standardized values \((1,0,-0.5)\).

Method. The correlation matrix has \(1\) on the diagonal and \(0.6\) elsewhere. Each row sums to \(2.2\), so multiplying the unit vector \((1,1,1)/\sqrt{3}\) by the matrix gives \(2.2\) times that vector. Therefore the first eigenvalue is \(2.2\) and its coefficient vector is \((1,1,1)/\sqrt{3}\).

The other two eigenvalues are \(0.4\) each: any vector whose entries sum to zero is perpendicular to \((1,1,1)\), and the matrix maps such a vector to \(0.4\) times itself. The total variance is \(3\). The first component therefore explains \(2.2/3=0.7333\), or \(73.33\%\), and each remaining component explains \(0.4/3=0.1333\), or \(13.33\%\). The proportions sum to \(1\).

For the stated policy, the first score is \((1+0-0.5)/\sqrt{3}=0.5/\sqrt{3}=0.2887\), rounded to four decimal places. The positive, equal coefficients make this a summary of a shared high-versus-low pattern across the three measures. This interpretation is not a causal claim about driving behavior.

Common mistake avoided: assuming that a component explaining most variation explains nearly all the variation. Here the first component explains about \(73.33\%\), leaving about \(26.67\%\) in the other directions.

Why the Eigenvalue Calculation Works

The eigenvalue definition follows directly from the variance of a projected score. For a standardized feature vector \(\mathbf{Z}\) with covariance matrix \(R\), take a unit direction \(\mathbf{v}\). The score is \(T=\mathbf{v}^\mathsf{T}\mathbf{Z}\). Its variance is:

$$ \operatorname{Var}(T) =\operatorname{Var}(\mathbf{v}^\mathsf{T}\mathbf{Z}) =\mathbf{v}^\mathsf{T}R\mathbf{v} $$

PCA chooses the unit direction that maximizes this expression. The constrained maximum is attained at an eigenvector of \(R\) with the largest eigenvalue: if \(R\mathbf{v}=\lambda\mathbf{v}\) and \(\mathbf{v}\) has unit length, then \(\mathbf{v}^\mathsf{T}R\mathbf{v}=\lambda\). Subsequent directions are chosen perpendicular to earlier ones, in decreasing eigenvalue order. This explains why the eigenvalue is the component-score variance and why explained-variance proportions use the sum of eigenvalues as their denominator.

Variance Explained Is Not Predictive Value

Worked Example: A Low-Variance Component Can Carry the Signal

Return to the two-feature correlation matrix with correlation \(0.8\). Suppose, in a hypothetical claim study, a numeric outcome \(Y\) is related to the contrast between hard braking and rapid acceleration according to \(Y=Z_1-Z_2\). Determine what happens if a practitioner retains only enough components to explain \(90\%\) of feature variation.

Method. The first component score is \(T_1=(Z_1+Z_2)/\sqrt{2}\), with variance \(1.8\). The second is \(T_2=(Z_1-Z_2)/\sqrt{2}\), with variance \(0.2\). Thus \(Y=\sqrt{2}T_2\): the outcome is entirely determined by the second component in this constructed relationship.

The covariance between \(T_1\) and \(Y\) is zero:

$$ \operatorname{Cov}(T_1,Y) =\frac{\operatorname{Var}(Z_1)-\operatorname{Var}(Z_2) +\operatorname{Cov}(Z_2,Z_1)-\operatorname{Cov}(Z_1,Z_2)}{\sqrt{2}} =0 $$

The equality uses \(\operatorname{Var}(Z_1)=\operatorname{Var}(Z_2)=1\) and \(\operatorname{Cov}(Z_1,Z_2)=\operatorname{Cov}(Z_2,Z_1)=0.8\). Retaining only \(T_1\) keeps \(90\%\) of feature variation but discards the component that carries all the outcome relationship in this example. The check is direct: \(Y=\sqrt{2}T_2\), while \(T_1\) has zero covariance with \(Y\).

Common mistake avoided: selecting components solely by a variance threshold and then assuming the retained scores must be good predictors. PCA does not look at the outcome, so its variance ranking is not a ranking of predictive value. Compare candidate score sets using an appropriate validation design and prediction metric.

Fit the Transformation Correctly in R

For a prediction case, fit centering, scaling, and PCA using only the training observations. Apply the resulting training means, standard deviations, and component directions unchanged to validation or future observations. If the transformation is refitted using held-out observations, information from those observations has entered feature construction. In cross-validation, the PCA transformation must likewise be fitted separately within each analysis fold.

A basic R pattern for numeric features is:

$$ \texttt{fit <- prcomp(train\_features, center = TRUE, scale. = TRUE)} $$

Use fit$rotation for component directions, fit$sdev^2 for eigenvalues, and fit$x for training scores. For new data, apply the fitted transformation with predict(fit, newdata = test_features); do not independently center, scale, or recompute PCA on the test set. Before fitting, the selected columns should be numeric and handled consistently. Missing-value treatment and feature definitions must also be set without using held-out outcomes or information.

1
Define the feature set.
Use measurements available at the intended prediction time, and check that each column has a consistent meaning and unit.
2
Fit on training data.
Estimate centering, scaling, and component directions using the training partition only.
3
Choose candidate score sets.
Review component interpretations and explained variance, but consider the outcome and prediction objective when deciding which scores to evaluate.
4
Assess predictive use.
Compare models with and without the scores using a suitable validation strategy. Check whether performance and interpretation are stable enough for the case.

PCA scores can be useful when the purpose is to summarize correlated measurements, reduce the number of numeric predictors, or address redundancy. They can be less useful when stakeholders need direct explanations in terms of the original driving measures, when components are unstable across training samples, or when important predictive information lies in a low-variance direction. Retention is a modeling decision, not an automatic consequence of an arbitrary variance cutoff.

Key takeaway: Standardize features when their scales warrant it, interpret a component through its coefficients and original variables, and calculate scores using the fitted training transformation. Explained variance describes feature variation—not predictive value—so evaluate retained scores for the case's actual objective.

Check Your Understanding

Work through each item. Component signs may be reversed without changing the interpretation.

  1. Two standardized features have correlation \(0.5\). Find the eigenvalues and the proportion of total variance explained by the first component. (Answer: Eigenvalues \(1.5\) and \(0.5\); the first component explains \(1.5/2=0.75\), or \(75\%\).)
  2. Three standardized features have equal pairwise correlation \(0.4\). Find the first component's unit coefficient vector, eigenvalue, and proportion explained. (Answer: Coefficients \((1,1,1)/\sqrt{3}\); eigenvalue \(1.8\); proportion \(1.8/3=0.60\), or \(60\%\).)
  3. For two features with correlation \(0.8\), a policy has standardized values \((0.4,-0.2)\). Using the first direction \((1,1)/\sqrt{2}\), calculate its first score to four decimal places. (Answer: \((0.4-0.2)/\sqrt{2}=0.1414\).)
  4. A PCA has eigenvalues \(3.1, 0.7,\) and \(0.2\). How many components are needed to explain at least \(80\%\) of total variance? (Answer: Total variance is \(4.0\); the first explains \(3.1/4=77.5\%\), while the first two explain \(3.8/4=95\%\), so retain two to meet the threshold.)
  5. A team scales all observations together, including a held-out test set, before fitting a model. Identify the problem and the correction. (Answer: The held-out feature distribution influenced preprocessing, creating information leakage; fit the scaling and PCA on training data only, then apply those fitted transformations unchanged to held-out data.)
Clinical Biostats