migrate {migrate}R Documentation

Summarize the migration of a data frame

Description

'migrate()' summarizes the transition amount (or percentage) of a continuous variable from each beginning credit risk state category to each ending credit risk state, given a data frame input.

Usage

migrate(
  data,
  id,
  time,
  state,
  metric = NULL,
  percent = TRUE,
  verbose = TRUE,
  rating = NULL,
  date = NULL
)

Arguments

data

A data frame or data frame extension (e.g., a tibble or data.table) containing a minimum of three (3) column variables representing a time, a credit risk state, and an ID identifying the credit facility (we would expect to see most unique values in this column variable appear twice in the dataset; once at the first unique 'time' value and again at the second unique 'time' value, unless the ID only existed at one of those two times).

id

The column variable of the 'data' data frame argument that contains the unique identifier to track where a particular credit facility migrated to/from. If left null, 'migrate()' will attempt to use the first column variable from the data frame provided in the 'data' argument.

time

The column variable of in the 'data' data frame representing the time point (e.g., a Date) of each observation; this column should contain two unique values (migration from Time A to Time B)

state

The column variable of the 'data' data frame argument that contains the credit risk state values.

metric

(Optional) The column variable of type "numeric" in the 'data' data frame argument that contains the continuous metric values to weight the state migration by

percent

If 'FALSE', will calculate the migration on an absolute basis (rather than a percentage basis, which is the default)

verbose

If 'TRUE', the function returns an informational message about the transition period

rating

Deprecated; please use 'state' instead.

date

Deprecated; please use 'time' instead.

Value

A data frame containing three (3) column variables representing the unique combinations of starting & ending credit risk states and the calculated migration observed during the period.

Examples

# Return the percent migration of the number of credit facilities
migrate(
  data = mock_credit,
  id = customer_id,
  time = date,
  state = risk_rating
)

# Return the absolute migration in `principal_balance`
migrate(
  data = mock_credit,
  id = customer_id,
  time = date,
  state = risk_rating,
  metric = principal_balance,
  percent = FALSE
)


[Package migrate version 0.4.0 Index]