As the number of cyber-attacks continues to grow on a daily basis, so does the delay in threat detection. For instance, in 2015, the Office of Personnel Management (OPM) discovered that approximately 21.5 million individual records of Federal employees and contractors had been stolen. On average, the time between an attack and its discovery is more than 200 days. In the case of the OPM breach, the attack had been going on for almost a year. Currently, cyber analysts inspect numerous potential incidents on a daily basis, but have neither the time nor the resources available to perform such a task. `anomalyDetection`

aims to curtail the time frame in which cyber-attacks go unnoticed and to aid in the discovery of these attacks among the millions of daily logged events, while minimizing the number of false positives and negatives. By incorporating a tabular vector approach along with multivariate analysis functionality, `anomalyDetection`

provides cyber analysts the ability to effectively and efficiently identify time periods associated with suspected anomalies for further evaluation.

`anomalyDetection`

provides 13 functions to aid in the detection of potential cyber anomalies:

Function | Purpose |
---|---|

`tabulated_state_vector` |
Employs a tabulated vector approach to transform security log data into unique counts of data attributes based on time blocks. |

`block_inspect` |
Creates a list where the original data has been divided into blocks denoted in the state vector. |

`mc_adjust` |
Handles issues with multi-collinearity. |

`mahalanobis_distance` |
Calculates the distance between the elements in data and the mean vector of the data for outlier detection. |

`bd_row` |
Indicates which variables in data are driving the Mahalanobis distance for a specific row, relative to the mean vector of the data. |

`horns_curve` |
Computes Horn’s Parallel Analysis to determine the factors to retain within a factor analysis. |

`factor_analysis` |
Reduces the structure of the data by relating the correlation between variables to a set of factors, using the eigen-decomposition of the correlation matrix. |

`factor_analysis_results` |
Provides easy access to factor analysis results. |

`kaisers_index` |
Computes scores designed to assess the quality of a factor analysis solution. It measures the tendency towards unifactoriality for both a given row and the entire matrix as a whole. |

`principal_components` |
Relates the data to a set of a components through the eigen-decomposition of the correlation matrix, where each component explains some variance of the data. |

`principal_components_results` |
Provides easy access to principal component analysis results. |

`get_all_factors` |
finds all factor pairs for a given integer. |

`anomalyDetection`

also incorporates the pipe operator (`%>%`

) from the magrittr package for streamlining function composition. To illustrate the functionality of `anomalyDetection`

we will use the `security_logs`

data that mimics common information that appears in security logs and comes with `anomalyDetection`

.

```
# we'll use tidyverse for some common manipulations
library(tidyverse)
library(anomalyDetection)
security_logs
## # A tibble: 300 × 10
## Device_Vendor Device_Product Device_Action Src_IP
## <chr> <chr> <chr> <chr>
## 1 McAfee NSP Attempt 223.70.128.61
## 2 CISCO ASA Failure 174.110.206.174
## 3 IBM SNIPS Success 174.110.206.174
## 4 McAfee NSP Success 227.12.127.87
## 5 Juniper SRX Success 28.9.24.154
## 6 McAfee NSP Success 28.9.24.154
## 7 McAfee NSP Attempt 28.9.24.154
## 8 McAfee ePO Attempt 223.70.128.61
## 9 McAfee ePO Attempt 174.110.206.174
## 10 CISCO ASA Attempt 227.12.127.87
## # ... with 290 more rows, and 6 more variables: Dst_IP <chr>,
## # Src_Port <int>, Dst_Port <int>, Protocol <chr>, Country_Src <chr>,
## # Bytes_TRF <int>
```

To apply the statistical methods that we’ll see in the sections that follow, we employ the tabulated vector approach. This approach transforms the security log data into unique counts of data attributes based on pre-defined time blocks. Therefore, as each time block is generated, the categorical fields are separated by their levels and a count of occurrences for each level are recorded into a vector. All numerical fields, such as bytes in and bytes out, are recorded as a summation within the time block. The result is what we call a “state vector matrix”.

Thus, for our `security_logs`

data we can create our state vector matrix based on our data being divided into 10 time blocks. What results is the summary of instances for each categorical level in our data for each time block. Consequently, row one represents the first time block and there were 2 instances of CISCO as the device vendor, 1 instances of IBM, etc.

```
tabulate_state_vector(security_logs, 10)
## # A tibble: 30 × 43
## CISCO IBM Juniper McAfee `Palo Alto Networks` NA1 ASA Firewall
## <int> <int> <int> <int> <int> <int> <int> <int>
## 1 2 1 1 6 0 0 2 0
## 2 0 2 4 2 2 0 0 2
## 3 2 4 2 2 0 0 2 0
## 4 5 1 2 1 1 0 5 1
## 5 3 1 1 3 2 0 3 2
## 6 2 1 2 4 1 0 2 1
## 7 2 2 1 3 2 0 2 2
## 8 3 3 1 3 0 0 3 0
## 9 0 1 4 3 2 0 0 2
## 10 2 2 2 4 0 0 2 0
## # ... with 20 more rows, and 35 more variables: NSP <int>, SNIPS <int>,
## # SRX <int>, ePO <int>, NA2 <int>, Attempt <int>, Failure <int>,
## # Success <int>, NA3 <int>, `174.110.206.174` <int>,
## # `223.70.128.61` <int>, `227.12.127.87` <int>, `28.9.24.154` <int>,
## # `89.130.69.91` <int>, NA4 <int>, `145.114.4.203` <int>,
## # `151.194.233.198` <int>, `219.142.109.8` <int>, `32.73.26.223` <int>,
## # `56.137.121.203` <int>, NA5 <int>, TCP <int>, UDP <int>, NA6 <int>,
## # China <int>, India <int>, Korea <int>, Netherlands <int>,
## # Russia <int>, US <int>, `United Kingdom` <int>, NA7 <int>,
## # Src_Port <int>, Dst_Port <int>, Bytes_TRF <int>
```

Prior to proceeding with any multivariate statistical analyses we should inspect the state vector for multicollinearity, to avoid issues such as matrix singularity, rank deficiency, and strong correlation values, and remove any columns that pose an issue. We can use `mc_adjust`

to handle issues with multi-collinearity by first removing any columns whose variance is close to or less than a minimum level of variance (`min_var`

). Then, it removes linearly dependent columns. Finally, it removes any columns that have a high absolute correlation value equal to or greater than `max_cor`

.

```
(state_vec <- security_logs %>%
tabulate_state_vector(10) %>%
mc_adjust())
## # A tibble: 30 × 26
## CISCO IBM Juniper McAfee `Palo Alto Networks` NSP Attempt Failure
## <int> <int> <int> <int> <int> <int> <int> <int>
## 1 2 1 1 6 0 4 5 1
## 2 0 2 4 2 2 0 4 2
## 3 2 4 2 2 0 0 3 3
## 4 5 1 2 1 1 0 0 5
## 5 3 1 1 3 2 2 3 3
## 6 2 1 2 4 1 3 4 1
## 7 2 2 1 3 2 3 3 3
## 8 3 3 1 3 0 1 6 2
## 9 0 1 4 3 2 2 4 4
## 10 2 2 2 4 0 1 3 0
## # ... with 20 more rows, and 18 more variables: `174.110.206.174` <int>,
## # `223.70.128.61` <int>, `227.12.127.87` <int>, `28.9.24.154` <int>,
## # `145.114.4.203` <int>, `151.194.233.198` <int>, `219.142.109.8` <int>,
## # `32.73.26.223` <int>, TCP <int>, China <int>, India <int>,
## # Korea <int>, Netherlands <int>, Russia <int>, US <int>,
## # Src_Port <int>, Dst_Port <int>, Bytes_TRF <int>
```

By default, `mc_adjust`

removes *all* columns that violate the variance, dependency, and correlation thresholds. Alternatively, we can use `action = "select"`

as an argument, which provides interactivity where the user can select the variables that violate the correlation threshold that they would like to remove.

With our data adjusted for multicollinearity we can now proceed with multivariate analyses to identify anomalies. First we’ll use the `mahalanobis_distance`

function to compare the distance between each observation by its distance from the data mean, independent of scale. This is computed as

\[MD = \sqrt{(x - \bar{x})C^{-1}(x-\bar{x})} \tag{1}\]

where \(x\) is a vector of \(p\) observations, \(x=(x_1, \dots, x_p)\), \(\bar{x}\) is the mean vector of the data, \(\bar{x}=(\bar{x}_1, \dots, \bar{x}_p)\), and \(C^{-1}\) is the inverse data covariance matrix.

Here, we include `output = "both"`

to return both the Mahalanobis distance and the absolute breakdown distances and `normalize = TRUE`

so that we can compare relative magnitudes across our data.

```
state_vec %>%
mahalanobis_distance("both", normalize = TRUE) %>%
as_tibble
## # A tibble: 30 × 27
## MD CISCO_BD IBM_BD Juniper_BD McAfee_BD
## <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 0.4548549 0.005536981 0.013005457 0.016020254 0.021822626
## 2 4.3843800 0.024664733 0.005573767 0.044055697 0.008985787
## 3 0.3604990 0.005536981 0.042732214 0.004005063 0.008985787
## 4 0.8456773 0.050839552 0.013005457 0.004005063 0.016687890
## 5 3.3541552 0.020637838 0.013005457 0.016020254 0.001283684
## 6 1.0900685 0.005536981 0.013005457 0.004005063 0.006418419
## 7 0.6769589 0.005536981 0.005573767 0.016020254 0.001283684
## 8 0.6968981 0.020637838 0.024152991 0.016020254 0.001283684
## 9 0.9910764 0.024664733 0.013005457 0.044055697 0.001283684
## 10 5.7822485 0.005536981 0.005573767 0.004005063 0.006418419
## # ... with 20 more rows, and 22 more variables: `Palo Alto
## # Networks_BD` <dbl>, NSP_BD <dbl>, Attempt_BD <dbl>, Failure_BD <dbl>,
## # `174.110.206.174_BD` <dbl>, `223.70.128.61_BD` <dbl>,
## # `227.12.127.87_BD` <dbl>, `28.9.24.154_BD` <dbl>,
## # `145.114.4.203_BD` <dbl>, `151.194.233.198_BD` <dbl>,
## # `219.142.109.8_BD` <dbl>, `32.73.26.223_BD` <dbl>, TCP_BD <dbl>,
## # China_BD <dbl>, India_BD <dbl>, Korea_BD <dbl>, Netherlands_BD <dbl>,
## # Russia_BD <dbl>, US_BD <dbl>, Src_Port_BD <dbl>, Dst_Port_BD <dbl>,
## # Bytes_TRF_BD <dbl>
```

We can use this information in a modified heatmap visualization to identify outlier values across our security log attributes and time blocks. The larger and brighter the dot the more significant the outlier is and deserves attention.

```
state_vec %>%
mahalanobis_distance("both", normalize = TRUE) %>%
as_tibble %>%
mutate(Block = 1:n()) %>%
gather(Variable, BD, -c(MD, Block)) %>%
ggplot(aes(factor(Block), Variable, color = MD, size = BD)) +
geom_point()
```

We can build onto this with the `bd_row`

to identify which security log attributes in the data are driving the Mahalanobis distance. `bd_row`

measures the relative contribution of each variable, \(x_i\), to \(MD\) by computing

\[BD_i = \Bigg|\frac{x_i - \bar{x}_i}{\sqrt{C_{ii}}} \Bigg| \tag{2}\]

where \(C_{ii}\) is the variance of \(x_i\). Furthermore, `bd_row`

will look at a specified row and rank-order the columns by those that are driving the Mahalanobis distance. For example, the plot above identified block 17 as having the largest Mahalanobis distance suggesting some abnormal activity may be occuring during that time block. We can drill down into that block and look at the top 10 security log attributes that are driving the Mahalanobis distance as these may be areas that require further investigation.

```
state_vec %>%
mahalanobis_distance("bd", normalize = TRUE) %>%
bd_row(17, 10)
## Src_Port_BD Bytes_TRF_BD Dst_Port_BD 32.73.26.223_BD
## 3.2733887 2.1016995 1.3575754 1.3398650
## 223.70.128.61_BD McAfee_BD IBM_BD Korea_BD
## 1.2376147 1.0828415 1.0372208 0.9979392
## Russia_BD Juniper_BD
## 0.9937290 0.8478386
```

Next, we can use factor analysis by first exploring the factor loadings (correlations between the columns of the state vector matrix and the suggested factors) and then comparing the factor scores against one another for anomaly detection. Factor analysis is another dimensionality reduction technique designed to identify underlying structure of the data. Factor analysis relates the correlations between variables through a set of factors to link together seemingly unrelated variables. The basic factor analysis model is

\[ X= Λf+e \tag{3}\]

where \(X\) is the vector of responses \(X = (x_1, \dots, x_p)\), \(f\) are the common factors \(f = (f_1, \dots, f_q)\), \(e\) is the unique factors \(e = (e_1, \dots, e_p)\), and \(Λ\) is the factor loadings. For the desired results, `anomalyDetection`

uses the correlation matrix. Factor loadings are correlations between the factors and the original data and can thus range from -1 to 1, which indicate how much that factor affects each variable. Values close to 0 imply a weak effect on the variable.

A factor loadings matrix can be computed to understand how each original data variable is related to the resultant factors. This can be computed as

\[ Λ = \bigg[\sqrt{λ_1}*e_1,\dots,\sqrt{λ_p}*e_p \bigg] \tag{4}\] where \(λ_1\) is the eigenvalue for each factor, \(e_i\) is the eigenvector for each factor, and \(p\) is the number of columns. Factor scores are used to examine the behavior of the observations relative to each factor and can be used to identify anomaly detection. Factor scores are calculated as

\[ \hat{f} ̂= X_s R^{-1} Λ \tag{5}\]

where \(X_s\) is the standardized observations, \(R^{-1}\) is the inverse of the correlation matrix, and $ $ is the factor loadings matrix. To simplify the results for interpretation, the factor loadings can undergo an orthogonal or oblique rotation. Orthogonal rotations assume independence between the factors while oblique rotations allow the factors to correlate. `anomalyDetection`

utilizes the most common rotation option known as varimax. Varimax rotates the factors orthogonally to maximize the variance of the squared factor loadings which forces large factors to increase and small ones to decrease, providing easier interpretation.

To begin using factor analysis, the dimensions of the reduced state vector matrix are first passed to the `horns_curve`

function to find the recommended set of eigenvalues.

```
horns_curve(state_vec)
## [1] 3.413379217 2.915474604 2.554115750 2.256719278 2.001067720
## [6] 1.780663565 1.580910010 1.410048519 1.247361636 1.104130151
## [11] 0.968079883 0.846912992 0.733072794 0.634208441 0.541600629
## [16] 0.451886199 0.373596369 0.306166193 0.245773367 0.190619696
## [21] 0.143541737 0.103389457 0.069773709 0.043551302 0.022697721
## [26] 0.008409727
```

Next, the dimensionality is determined by finding the eigenvalues of the correlation matrix of the state vector matrix and retaining only those factors whose eigenvalues are greater than or equal to those produced by `horns_curve`

. We use `factor_analysis`

to reduce the state vector matrix into resultant factors. The `factor_analysis`

function generates a list containing five outputs:

`fa_loadings`

: numerical matrix with the original factor loadings`fa_scores`

: numerical matrix with the row scores for each factor`fa_loadings_rotated`

: numerical matrix with the varimax rotated factor loadings`fa_scores_rotated`

: numerical matrix with the row scores for each varimax rotated factor`num_factors`

: numeric vector identifying the number of factors

```
state_vec %>%
horns_curve() %>%
factor_analysis(state_vec, hc_points = .) %>%
str
## List of 5
## $ fa_loadings : num [1:26, 1:12] -0.3012 -0.3106 0.0128 0.7003 -0.1624 ...
## $ fa_scores : num [1:30, 1:12] 1.377 -0.677 -0.494 -1.356 0.558 ...
## $ fa_loadings_rotated: num [1:26, 1:12] -0.375 -0.167 -0.204 0.833 -0.184 ...
## $ fa_scores_rotated : num [1:30, 1:12] 1.872 -0.914 -1.096 -1.481 -0.201 ...
## $ num_factors : int 12
```

For easy access to these results we can use the `factor_analysis_results`

parsing function. The `factor_analysis_results`

will parse the results either by their list name or by location. For instance to extract the rotated factor scores you can use `factor_analysis_results(data, results = fa_scores_rotated)`

or `factor_analysis_results(data, results = 4)`

as demonstrated below.

```
state_vec %>%
horns_curve() %>%
factor_analysis(state_vec, hc_points = .) %>%
factor_analysis_results(4) %>%
as_tibble
## # A tibble: 30 × 12
## V1 V2 V3 V4 V5 V6
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1.87213106 0.1160018 -0.932756096 -0.49761881 -0.05951385 -0.1378172
## 2 -0.91353766 -0.5845927 2.293779441 0.23861431 -0.65706417 -0.2195791
## 3 -1.09637501 -1.5142712 0.318868180 0.51558583 0.50214841 -0.8778730
## 4 -1.48063194 2.5561361 -1.105201880 0.06094348 -0.60779252 0.2881919
## 5 -0.20122344 -0.3763629 -0.913310110 1.81546753 -0.98002131 0.9012263
## 6 0.75745062 0.3144349 -0.302600591 0.66702799 1.19720196 1.8496055
## 7 0.59008899 0.9130094 0.552940355 -0.09866971 1.71017031 -1.0044785
## 8 -0.71107596 -1.4453147 -2.113142341 -1.42822734 -0.96160484 -0.6119127
## 9 -0.08578748 0.6386426 2.123170502 0.49493775 -0.68690707 -0.4812421
## 10 0.14955216 0.4253572 0.008289596 1.63929012 -0.37477679 -2.1123358
## # ... with 20 more rows, and 6 more variables: V7 <dbl>, V8 <dbl>,
## # V9 <dbl>, V10 <dbl>, V11 <dbl>, V12 <dbl>
```

To evaluate the quality for a factor analysis solution Kaiser proposed the Index of Factorial Simplicity (IFS). The IFS is computed as

\[ IFS = \frac{∑_i\big[q ∑_sv_js^4-(∑_sv_{js}^2)^2\big]}{∑_i\big[(q-1)(∑_sv_{js}^2)^2 \big]} \tag{6}\]

where \(q\) is the number of factors, \(j\) the row index, \(s\) the column index, and \(v_{js}\) is the value in the loadings matrix. Furthermore, Kaiser created the following evaluations of the score produced by the IFS as shown below:

- In the .90s: Marvelous
- In the .80s: Meritorious
- In the .70s: Middling
- In the .60s: Mediocre
- In the .50s: Miserable
- < .50: Unacceptable

Thus, to assess the quality of our factor analysis results we apply `kaisers_index`

to the rotated factor loadings and as the results show below our output value of 0.702 suggests that our results are “middling”.

```
state_vec %>%
horns_curve() %>%
factor_analysis(data = state_vec, hc_points = .) %>%
factor_analysis_results(fa_loadings_rotated) %>%
kaisers_index()
## [1] 0.7428623
```

We can visualize the factor analysis results to show the correlation between the columns of the reduced state vector to the rotated factor loadings. Strong negative correlations are depicted as red while strong positive correlations are shown as blue. This helps to identify which factors are correlated with each security log data attribute. Furthermore, this helps to identify two or more security log data attributes that appear to have relationships with their occurrences. For example, this shows that Russia is highly correlated with IP address 223.70.128. If there is an abnormally large amount of instances with Russian occurrances this would be the logical IP address to start investigating.

```
fa_loadings <- state_vec %>%
horns_curve() %>%
factor_analysis(state_vec, hc_points = .) %>%
factor_analysis_results(fa_loadings_rotated)
row.names(fa_loadings) <- colnames(state_vec)
gplots::heatmap.2(fa_loadings, dendrogram = 'both', trace = 'none',
density.info = 'none', breaks = seq(-1, 1, by = .25),
col = RColorBrewer::brewer.pal(8, 'RdBu'))
```

We can also visualize the rotated factor score plots to see which time blocks appear to be outliers and deserve closer attention.

```
state_vec %>%
horns_curve() %>%
factor_analysis(state_vec, hc_points = .) %>%
factor_analysis_results(fa_scores_rotated) %>%
as_tibble() %>%
mutate(Block = 1:n()) %>%
gather(Factor, Score, -Block) %>%
mutate(Absolute_Score = abs(Score)) %>%
ggplot(aes(Factor, Absolute_Score, label = Block)) +
geom_text() +
geom_boxplot(outlier.shape = NA)
```

This allows us to look across the factors and identify outlier blocks that may require further intra-block analysis. If we assume that an absolute rotated factor score \(\geq\) 2 represents our outlier cut-off then we see that time blocks 4, 13, 15, 17, 24, 26, and 27 require further investigation. We saw block 17 being highlighted with the `mahalanobis_distance`

earlier but these other time blocks were not as obvious so by performing and comparing these multiple anomaly detection approaches we can gain greater insights and confirmation.

An alternative, yet similar approach to factor analysis is principal component analysis. The goal in factor analysis is to explain the covariances or correlations between the variables. By contrast, the goal of principal component analysis is to explain as much of the total variance in the variables as possible. Thus, The first principal component of a set of features \(X_1, X_2,\dots,X_p\) is the normalized linear combination of the features

\[ Z_1 = \phi_{11}X_1 + \phi_{21}X_2 + \cdots + \phi_{p1}X_p \tag{7}\]

that has the largest variance. By *normalized*, we mean that \(\sum^p_{j=1} \phi^2_{j1} = 1\). We refer to the elements \(\phi_{11},\dots,\phi_{p1}\) as the loadings of the first principal component; together, the loadings make up the principal component loading vector, \(\phi_1 = (\phi_{11}, \phi_{21}, \dots, \phi_{p1})^T\). The loadings are constrained so that their sum of squares is equal to one, since otherwise setting these elements to be arbitrarily large in absolute value could result in an arbitrarily large variance. After the first principal component \(Z_1\) of the features has been determined, we can find the second principal component \(Z_2\). The second principal component is the linear combination of \(X_1,\dots,X_p\) that has maximal variance out of all linear combinations that are uncorrelated with \(Z_1\). The second principal component scores \(z_{12}, z_{22},\dots,z_{n2}\) take the form

\[z_{12} = \phi_{12}x_{i1} + \phi_{22}x_{i2} + \cdots + \phi_{p2}x_{ip} \tag{8} \]

where \(\phi_2\) is the second principal loading vector, with elements \(\phi_{12}, \phi_{22}, \dots, \phi_{p2}\). This continues until all principal components have been computed. To perform a principal components analysis we use `principal_components`

which will create a list containing:

`pca_sdev`

: the standard deviations of the principal components (i.e., the square roots of the eigenvalues of the covariance/correlation matrix, though the calculation is actually done with the singular values of the data matrix).`pca_loadings`

: the matrix of variable loadings (i.e., a matrix whose columns contain the eigenvectors).`pca_rotated`

: the value of the rotated data (the centered, and scaled if requested, data multiplied by the rotation matrix) is returned.`pca_center`

: the centering used.`pca_scale`

: a logical response indicating whether scaling was used.

```
principal_components(state_vec) %>% str
## List of 5
## $ pca_sdev : num [1:26] 25832.61 461.67 138.36 2.35 2.18 ...
## $ pca_loadings: num [1:26, 1:26] -1.29e-05 1.27e-05 -4.41e-06 -5.97e-06 1.06e-05 ...
## ..- attr(*, "dimnames")=List of 2
## .. ..$ : chr [1:26] "CISCO" "IBM" "Juniper" "McAfee" ...
## .. ..$ : chr [1:26] "PC1" "PC2" "PC3" "PC4" ...
## $ pca_rotated : num [1:30, 1:26] 1326 20405 1884 1556 -37890 ...
## ..- attr(*, "dimnames")=List of 2
## .. ..$ : NULL
## .. ..$ : chr [1:26] "PC1" "PC2" "PC3" "PC4" ...
## $ pca_center : Named num [1:26] 1.63 1.7 1.8 3.17 1.7 ...
## ..- attr(*, "names")= chr [1:26] "CISCO" "IBM" "Juniper" "McAfee" ...
## $ pca_scale : logi FALSE
```

For easy access to these results we can use the `principal_components_result`

parsing function. The `principal_components_result`

will parse the results either by their list name or by location. For instance to extract the computed component scores as outlined in Eq. 8 you can use `principal_components_result(data, results = pca_rotated)`

or `principal_components_result(data, results = 3)`

as demonstrated below.

```
state_vec %>%
principal_components() %>%
principal_components_result(pca_rotated) %>%
as_tibble
## # A tibble: 30 × 26
## PC1 PC2 PC3 PC4 PC5 PC6
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1326.436 -285.25432 36.72409 -3.44733723 1.9672714 2.6338413
## 2 20404.603 420.02368 236.95090 -3.59001238 -2.4572121 -2.4592367
## 3 1884.370 -229.68494 45.39949 -1.26497496 -2.5971138 -1.1600819
## 4 1555.892 171.11409 116.14891 6.06862021 -0.5868180 -1.5274882
## 5 -37890.373 -470.91899 55.73816 0.74851917 0.4237737 0.4669886
## 6 -19041.547 -307.40732 -44.48368 -0.65318192 1.9272812 3.0072747
## 7 -19117.070 130.64748 30.69727 1.85623776 -2.0745001 0.9738108
## 8 21346.072 35.75863 12.44457 -1.66565937 -2.7994737 2.5073397
## 9 -18901.619 -251.40990 55.19690 0.01965195 0.4856842 -2.9931123
## 10 -37321.917 -848.69719 -77.71486 -2.29953719 -2.9065252 -1.3523165
## # ... with 20 more rows, and 20 more variables: PC7 <dbl>, PC8 <dbl>,
## # PC9 <dbl>, PC10 <dbl>, PC11 <dbl>, PC12 <dbl>, PC13 <dbl>, PC14 <dbl>,
## # PC15 <dbl>, PC16 <dbl>, PC17 <dbl>, PC18 <dbl>, PC19 <dbl>,
## # PC20 <dbl>, PC21 <dbl>, PC22 <dbl>, PC23 <dbl>, PC24 <dbl>,
## # PC25 <dbl>, PC26 <dbl>
```

We could then follow up the principal component analysis with similar visualization activities as performed post factor analysis to identify potential anomalies.