output: github_document

AFR

AFR is an R toolkit for regression, prediction and forecast analysis of macroeconomic, credit and financial-sector data. The package includes functions adapted for the banking sector of Kazakhstan and is designed to simplify statistical modelling, diagnostic testing and interpretation of regression results for bank analysts, financial market researchers and non-statisticians.

The package was developed by the Agency of the Republic of Kazakhstan for Regulation and Development of Financial Market (ARDFM).

Installation

You can install the released version of AFR from CRAN:

install.packages("AFR")

Then load the package:

library(AFR)

Main functionality

The package provides tools for:

Built-in datasets

macroKZ

macroKZ is a built-in quarterly dataset for macroeconomic and financial-sector analysis of Kazakhstan. It includes macroeconomic indicators, exchange rates, interest rates, oil price, real estate indicators, credit portfolio indicators, prudential coefficients, income and expense indicators, provisions and default rate.

The dataset can be loaded as follows:

data(macroKZ)

head(macroKZ)
summary(macroKZ)

Typical use cases include:

finratKZ

finratKZ is a built-in dataset of corporate borrowers. It contains financial ratios and borrower classification indicators used for credit risk analysis and regression modelling.

The dataset can be loaded as follows:

data(finratKZ)

head(finratKZ)
summary(finratKZ)

Typical use cases include:

Regression and diagnostic tools

AFR provides functions for regression analysis, model selection, time-series transformation and model diagnostics.

Examples of available tools include:

Example workflow:

library(AFR)

data(macroKZ)

model <- lm(real_gdp ~ imp + exp + poil + eurkzt + tonia_rate, data = macroKZ)

bg(model)
bp(model)
gq(model)

OGPO Insurance Scoring Dataset

AFR also provides helper functions for loading the OGPO Insurance Scoring Dataset. The dataset was prepared for a past case competition focused on insurance risk scoring and fair pricing of compulsory motor third-party liability insurance policies.

The dataset can be used for modelling claim probability, analysing policy-level and driver-level risk factors, validating scoring models and estimating business effects such as loss ratio, premium adjustment and customer retention.

Due to CRAN package size restrictions, the full OGPO datasets are not included directly in the package. They are stored externally as compressed Parquet files in GitHub Releases and are downloaded only when the user explicitly calls the corresponding loading functions. Downloaded files are cached locally and reused in subsequent calls.

ogpo_train <- load_ogpo_train()
ogpo_test_with_target <- load_ogpo_test_with_target()
ogpo_test_final <- load_ogpo_test_final()
data_dictionary <- load_ogpo_data_dictionary()

The files are cached locally in:

"~/.afr/ogpo_insurance_scoring/"

The OGPO dataset has three main parts:

Notes

The large OGPO datasets are downloaded from GitHub Releases only on explicit user request. They are not downloaded during package installation, package loading, CRAN checks or vignette building.

The built-in datasets macroKZ and finratKZ remain included directly in the package and can be loaded using the standard data() function.