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).
You can install the released version of AFR from
CRAN:
install.packages("AFR")Then load the package:
library(AFR)The package provides tools for:
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 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:
AFR provides functions for regression analysis, model
selection, time-series transformation and model diagnostics.
Examples of available tools include:
checkdata() for preliminary data checks;check_betas() for analysing regression coefficients
across models;corsel() for multicollinearity analysis;bg() for the Breusch-Godfrey autocorrelation test;bp() for the Breusch-Pagan heteroskedasticity
test;gq() for the Goldfeld-Quandt heteroskedasticity
test;HP() for the Hodrick-Prescott filter;difflog(), pct1() and pct4()
for time-series transformations;reg_test() and regsel_f() for regression
testing and model selection.Example workflow:
library(AFR)
data(macroKZ)
model <- lm(real_gdp ~ imp + exp + poil + eurkzt + tonia_rate, data = macroKZ)
bg(model)
bp(model)
gq(model)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:
load_ogpo_train() loads the training dataset;load_ogpo_test_with_target() loads the test dataset
with known target values;load_ogpo_test_final() loads the final scoring
dataset;load_ogpo_data_dictionary() loads the data dictionary
included in the package.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.