rating_to_numeric: Converts a vector of bond credit ratings to numeric values

View source: R/rating_to_numeric.R

rating_to_numericR Documentation

Converts a vector of bond credit ratings to numeric values

Description

This function takes a vector of bond credit ratings and returns a vector of their numeric equivalents or, optionally, a statistical summary of the translated values. The package currently supports long term credit ratings from Moody's, S&P, Fitch, Kroll, & DBRS/Morningstar. All mappings are stored in creditor:::cr_imp. Short term ratings are assigned the floor rounded value of their long term equivalents. By default, NA and unrecognized ratings are not assigned a value. This setting can be changed to assign the highest numeric value (23) to missing or unrated bonds.

Usage

rating_to_numeric(
  credit_rating,
  nr_as_na = TRUE,
  summary_fun = NULL,
  ...,
  summarize_numeric = FALSE
)

Arguments

credit_rating

A character vector of bond credit ratings

summary_fun

Function input to summarize vector

...

Additional arguments passed to summary_fun

summarize_numeric

Return a numeric summary value. Defaults to FALSE to return letter rating equivalent.

na_as_nr

Assign missing or unrecognized ratings highest numeric value, defaults to TRUE

Value

Returns a vector of numeric credit rating equivalents.

Examples


# convert bond credit ratings to numeric values
x <- c("AAA", "Baa2", "A(low)")
rating_to_numeric(x)

# summarize ratings
x <- c("AAA", "Baa2", "A(low)")
rating_to_numeric(x, summary_fun = weighted.mean, w = c(0.15, 0.60, 0.25))

p-will-b/creditor documentation built on March 28, 2023, 6:46 p.m.