# 信貸遷移風險

PD =違約概率

LGD =違約損失

RWA =風險加權資產

EL =預期損失

If you have the data in two different tables, doing this in base R is quite easy. For example:

set.seed(1L)

N <- 100L
current <- data.frame(
ID = 1:100,
Rating = sample(1:5, N, replace = TRUE),
ECap = runif(N, 0, 1e6)
)

previous <- data.frame(
ID = 25:124,
Rating = sample(1:5, N, replace = TRUE),
ECap = runif(N, 0, 1e6)
)

merged <- merge(previous, current, by = 'ID')
# Change in ECap
merged$$ECap_delta <- merged$$ECap.y - merged$$ECap.x # Rating migrations table(merged$$Rating.y, merged\$Rating.x)


You'll also want to look at ID that are added or removed from the two sets.

The same steps can be done in SQL or Python as well.

You're right that Economic Capital (ECap) is related to Expected Loss, they both tell us something about the different the loss distribution. However, there is no function that takes you from one to the other directly.

• The Expected Loss is the expected value of the loss distribution $$F$$, i.e. $$\mathrm{E}(L) = \mathrm{E}(\mathrm{Loss})$$
• The ECap is an upper percentile $$\alpha$$ of the loss distribution, analogous to the Value at Risk, mathematically: $$\mathrm{ECap} = \inf\{x \in \mathbb{R} : F(x) > \alpha\}$$.