Data Numerik

Data yang digunakan berasal dari dataset Credit Card Approvals.

# Data Numerik
data <- data.frame(
  Age = c(30.83, 58.67, 24.50, 27.83, 20.17),
  Debt = c(0.000, 4.460, 0.500, 1.540, 5.625),
  YearsEmployed = c(1.25, 3.04, 1.50, 3.75, 1.71),
  CreditScore = c(1, 6, 0, 5, 0),
  Income = c(0, 560, 824, 3, 120)
)

# Eigenvalues dan Eigenvectors
eig <- eigen(cov(data))
cat("Eigenvalues:\n")
## Eigenvalues:
eig$values
## [1] 1.382143e+05 2.172113e+02 5.765169e+00 3.545135e+00 4.286618e-14
cat("Eigenvectors:\n")
## Eigenvectors:
eig$vectors
##               [,1]        [,2]          [,3]         [,4]          [,5]
## [1,] -0.0121749037  0.98507331  0.0365068867  0.160449916  0.0490450495
## [2,]  0.0001172116  0.04567763 -0.9967524262 -0.036765620 -0.0551944813
## [3,]  0.0004260572  0.03739143 -0.0284640607 -0.489255540  0.8708734198
## [4,]  0.0004344344  0.16125859  0.0658889109 -0.856461725 -0.4859294621
## [5,] -0.9999256911 -0.01190272 -0.0005448422 -0.002538487 -0.0004436838
# Variance-Covariance Matrix
cov_matrix <- cov(data)
cat("Variance-Covariance Matrix:\n")
## Variance-Covariance Matrix:
cov_matrix
##                       Age       Debt YearsEmployed CreditScore       Income
## Age            231.361400   9.345663      6.999375       33.30   1680.07250
## Debt             9.345663   6.187675      0.605225        1.34    -16.31375
## YearsEmployed    6.999375   0.605225      1.182050        2.81    -58.97500
## CreditScore     33.300000   1.340000      2.810000        8.30    -60.45000
## Income        1680.072500 -16.313750    -58.975000      -60.45 138193.80000
# Correlation Matrix
cor_matrix <- cor(data)
cat("Correlation Matrix:\n")
## Correlation Matrix:
cor_matrix
##                     Age        Debt YearsEmployed CreditScore      Income
## Age           1.0000000  0.24700224     0.4232489  0.75990576  0.29712438
## Debt          0.2470022  1.00000000     0.2237872  0.18698295 -0.01764192
## YearsEmployed 0.4232489  0.22378717     1.0000000  0.89711754 -0.14591695
## CreditScore   0.7599058  0.18698295     0.8971175  1.00000000 -0.05644338
## Income        0.2971244 -0.01764192    -0.1459170 -0.05644338  1.00000000
#knitr::opts_chunk$set(echo = TRUE)