Title: | Toolkit for Regression Analysis of Kazakhstan Banking Sector Data |
---|---|
Description: | Tool is created for regression, prediction and forecast analysis of macroeconomic and credit data. The package includes functions from existing R packages adapted for banking sector of Kazakhstan. The purpose of the package is to optimize statistical functions for easier interpretation for bank analysts and non-statisticians. |
Authors: | Timur Abilkassymov [aut], Shyngys Shuneyev [aut], Alua Makhmetova [aut], Sultan Zhaparov [aut, cre] |
Maintainer: | Sultan Zhaparov <[email protected]> |
License: | GPL-2 |
Version: | 0.3.6 |
Built: | 2024-11-07 06:18:42 UTC |
Source: | CRAN |
BG test is used to test for autocorrelation in the errors of a regression model
bg( model, order = 1, order.by = NULL, type = c("Chisq", "F"), data = list(), fill = 0 )
bg( model, order = 1, order.by = NULL, type = c("Chisq", "F"), data = list(), fill = 0 )
model |
is a (generalized)linear regression model |
order |
integer. maximal order of serial correlation to be tested. |
order.by |
Either a vector z or a formula with a single explanatory variable like ~ z |
type |
the type of test statistic to be returned |
data |
an optional data frame containing the variables in the model |
fill |
starting values for the lagged residuals in the auxiliary regression. By default 0 but can also be set to NA. |
Mitchel, D. and Zeileis, A. Published 2021-11-07. lmtest package
model <- lm(real_gdp ~ imp + exp + poil + eurkzt + tonia_rate, data = macroKZ) bg(model)
model <- lm(real_gdp ~ imp + exp + poil + eurkzt + tonia_rate, data = macroKZ) bg(model)
Breusch-Pagan test is used to test against heteroskedasticity of a time-series
bp(model, varformula = NULL, studentize = TRUE, data = list())
bp(model, varformula = NULL, studentize = TRUE, data = list())
model |
is a (generalized)linear regression model |
varformula |
a formula describing only the potential explanatory variables for the variance (no dependent variable needed). By default the same explanatory variables are taken as in the main regression model. |
studentize |
logical. If set to TRUE Koenker's studentized version of the test statistic will be used. |
data |
an optional data frame containing the variables in the model |
Torsten, H., Zeileis, A., Farebrother, Richard W., Cummins, C., Millo, G., Mitchell, D., lmtest package Wang, B., 2014, bstats package
model <- lm(real_gdp ~ imp + exp + poil + eurkzt + tonia_rate, data = macroKZ) bp(model)
model <- lm(real_gdp ~ imp + exp + poil + eurkzt + tonia_rate, data = macroKZ) bp(model)
Returns the coefficients for each variable from each model.
check_betas(object, ...)
check_betas(object, ...)
object |
An object of class |
... |
Other arguments. |
check_betas
returns a data.frame
containing:
x |
model |
Hebbali, Aravind. Published 2020-02-10. olsrr package
model <- lm(real_gdp~imp+exp+usdkzt+eurkzt, data = macroKZ) check_betas(model)
model <- lm(real_gdp~imp+exp+usdkzt+eurkzt, data = macroKZ) check_betas(model)
Preliminary check of data frame for missing values, numeric format, outliers.
Missing items: The number of missing values in each column of the dataset. Numeric format: The number of non-numeric variables in each column of the dataset. Outliers: The number of outliers in each column of the dataset.
checkdata(x)
checkdata(x)
x |
is a data frame |
data(macroKZ) checkdata(macroKZ)
data(macroKZ) checkdata(macroKZ)
multicollinearity is the occurence of high interrelations among two or more independent variables in a multiple regression.
corsel(x, thrs, num)
corsel(x, thrs, num)
x |
is a numeric vector or matrix |
thrs |
threshold set to calculate correlation above |
num |
logical |
data(macroKZ) corsel(macroKZ,num=FALSE,thrs=0.65)
data(macroKZ) corsel(macroKZ,num=FALSE,thrs=0.65)
The function depicts decomposition of regressors as a stacked barplot
dec_plot(model, dataset, print_plot = TRUE)
dec_plot(model, dataset, print_plot = TRUE)
model |
An object of class |
dataset |
A dataset based on which model was built |
print_plot |
logical |
The Agency of the Republic of Kazakhstan for Regulation and Development of Financial Market (AFR)
Hebbali, Aravind. Published 2020-02-10. olssr package
data(macroKZ) model <- lm(real_gdp ~ usdkzt + eurkzt + imp+exp, data = macroKZ) dec_plot(model, macroKZ)
data(macroKZ) model <- lm(real_gdp ~ usdkzt + eurkzt + imp+exp, data = macroKZ) dec_plot(model, macroKZ)
Difference of logarithms is finding the difference between two consecutive logarithm values of a time-series
difflog(x, lag = 1, difference = 1)
difflog(x, lag = 1, difference = 1)
x |
time-series vector |
lag |
lagged period |
difference |
difference between x items |
data (macroKZ) new<-pct1(macroKZ)
data (macroKZ) new<-pct1(macroKZ)
finratKZ dataset
finratKZ
finratKZ
Dataset of 400 corporate borrowers, i.e. 200 standard (IFRS stage 1) and 200 default ones, characterized by 29 financial ratios.
Dummy variable where 0 - standard(IFRS stage 1) borrower, 1 - default borrower
Revenue growth rate
EBITDA growth rate
Capital growth rate
Current ratio
Quick ratio
Cash ratio
Working capital cycle
Debt-to-assets
Debt-to-equity
Leverage ratio (Total assets/Total equity)
EBITDA-to-debt
Interest coverage (Income statement)
Cash-to-income
Interest coverage (Cash flow statement)
Debt coverage ratio (Cash flow from operations/Total debt)
Cash flow to revenue
Cash return on assets (Cash flow from operations/Total assets)
Cash return on equity (Cash flow from operations/Total equity)
Return on assets
Return on equity
Net profit margin
Gross profit margin
Operating profit margin
Receivables turnover
Inventory turnover
Payables turnover
Total assets turnover
Fixed assets turnover
Working capital turnover
The Agency of the Republic of Kazakhstan for Regulation and Development of Financial Market
Godfrey-Quandt test is used to test against heteroskedasticity of a time-series
gq( model, point = 0.5, fraction = 0, alternative = c("greater", "two.sided", "less"), order.by = NULL, data = list() )
gq( model, point = 0.5, fraction = 0, alternative = c("greater", "two.sided", "less"), order.by = NULL, data = list() )
model |
is a (generalized)linear regression model |
point |
numerical. If point is smaller than 1 it is interpreted as percentages of data |
fraction |
numerical. The number of central observations to be omitted. |
alternative |
a character string specifying the alternative hypothesis. |
order.by |
Either a vector z or a formula with a single explanatory variable like ~ z |
data |
an optional data frame containing the variables in the model. |
Torsten, H., Zeileis, A., Farebrother, Richard W., Cummins, C., Millo, G., Mitchell, D., lmtest package Wang, B., 2014, bstats package
model <- lm(real_gdp ~ imp + exp + poil + eurkzt + tonia_rate, data = macroKZ) gq(model)
model <- lm(real_gdp ~ imp + exp + poil + eurkzt + tonia_rate, data = macroKZ) gq(model)
Hodrick-Prescott filter is a data smoothing technique that removes trending in time series data frame
HP(x, freq = NULL, type = c("lambda", "frequency"), drift = FALSE)
HP(x, freq = NULL, type = c("lambda", "frequency"), drift = FALSE)
x |
time-series vector |
freq |
integer |
type |
character, indicating the filter type |
drift |
logical |
data(macroKZ) HP(macroKZ[,2])
data(macroKZ) HP(macroKZ[,2])
macroKZ dataset
macroKZ
macroKZ
A time series data frame of 57 quarterly observations of 50 macroeconomic and 10 financial parameters for 2010-2024 period.
Real GDP
Real gross value added Agriculture
Real gross value added Mining
Real gross value added Mining
Real gross value added Manufacture
Real gross value added Electricity
Real gross value added Construction
Real gross value added Trade
Real gross value added Transportation
Real gross value added Information
Real gross value added
GDP deflator
Real population average monthly income
Real population average monthly expenses
Real population average monthly wage
Import
Export
Inflation
Real price for estate in primary market
Real price for estate in secondary market
Real price for commercial estate
Change in stock value for traded companies
Change in stock value for non-traded companies Agriculture
Change in stock value for non-traded companies Mining
Change in stock value for non-traded companies Manufacture
Change in stock value for non-traded companies Electricity
Change in stock value for non-traded companies Construction
Change in stock value for non-traded companies Trade
Change in stock value for non-traded companies Transportation
Change in stock value for non-traded companies Information
Federal Funds Rate
Return on government securities in KZT, 3 m
Return on government securities in KZT, 1 year
Return on government securities in KZT, 7 years
Return on government securities in KZT, 10 years
TONIA
Weighted average mortgage lending rate for new loans, less than a year
Weighted average mortgage lending rate for new loans, more than a year
Weighted average mortgage lending rate for new loans to non-financial organizations in KZT, less than a year
Weighted average mortgage lending rate for new loans to non-financial organizations in CKB, less than a year
Weighted average mortgage lending rate for new loans to non-financial organizations in KZT, more than a year
Weighted average mortgage lending rate for new loans to non-financial organizations in CKB, more than a year
Weighted average mortgage lending rate for consumer loans in KZT, less than a year
Weighted average mortgage lending rate for consumer loans in KZT, less than a year
USD KZT exchange rate
EUR KZT exchange rate
RUB KZT exchange rate
Price for Brent
Real price for estate in primary market in Russia
Real price for estate in secondary market in Russia
credit portfolio
k4 prudential coefficient
k1 prudential coefficient
k3 prudential coefficient
provisions
percent margin
commissionary income
commissionary expenses
operational income
other income
default rate
Bureau of National statistics, Agency for Strategic planning and reforms of the Republic of Kazakhstan
The Agency of the Republic of Kazakhstan for Regulation and Development of Financial Market
Test for normality Test for detecting violation of normality assumption.
ols_test_normality(model, ...)
ols_test_normality(model, ...)
model |
an object of class |
... |
Other arguments. |
ols_test_normality
is a list containing the
following components:
kolmogorv |
kolmogorov smirnov statistic |
shapiro |
shapiro wilk statistic |
cramer |
cramer von mises statistic |
anderson |
anderson darling statistic |
data(macroKZ) model <- lm(real_gdp ~ imp + exp + usdkzt + poil, data = macroKZ) ols_test_normality(model)
data(macroKZ) model <- lm(real_gdp ~ imp + exp + usdkzt + poil, data = macroKZ) ols_test_normality(model)
Estimates number of models generated from given number of regressors X
opt_size(model)
opt_size(model)
model |
is a linear regression model a class |
data(macroKZ) model <- lm(real_gdp ~ imp + exp + poil + eurkzt + tonia_rate, data = macroKZ) opt_size(model)
data(macroKZ) model <- lm(real_gdp ~ imp + exp + poil + eurkzt + tonia_rate, data = macroKZ) opt_size(model)
Percent change is a change between two consecutive terms,
pct1(x)
pct1(x)
x |
time-series vector(s) |
data (macroKZ) new<-pct1(macroKZ)
data (macroKZ) new<-pct1(macroKZ)
Percent change is a change between a term and its lagged value for prior period,
pct4(x)
pct4(x)
x |
time-series vector(s) |
data (macroKZ) new<-pct4(macroKZ)
data (macroKZ) new<-pct4(macroKZ)
Calculates the variation inflation factors of all predictors in regression models
pt_multi(pf, num_def, conf_level, num_years)
pt_multi(pf, num_def, conf_level, num_years)
pf |
unconditional portfolio distribution from the worst to the best credit quality |
num_def |
number of defaults in a given rating class |
conf_level |
confidence interval of PD estimates |
num_years |
number of periods used in the PD estimation |
pf <- c(10,20,30,40) num_def <- c(1,2,3,4) conf_level = 0.99 num_years = 3 pt_multi(pf, num_def, conf_level, num_years)
pf <- c(10,20,30,40) num_def <- c(1,2,3,4) conf_level = 0.99 num_years = 3 pt_multi(pf, num_def, conf_level, num_years)
Calculates probability of default according to One-period Pluto and Tasche model
pt_one(pf, num_def, ci = 0.9)
pt_one(pf, num_def, ci = 0.9)
pf |
unconditional portfolio distribution from the worst to the best credit quality |
num_def |
number of defaults in a given rating class |
ci |
condifence interval of PD estimates |
Surzhko, Denis. Published 2015-05-21. LDPD package. Archived on 2022-06-20.
pf <- c(10,20,30,40) num_def <- c(1,2,3,4) pt_one(pf, num_def, ci= 0.9)
pf <- c(10,20,30,40) num_def <- c(1,2,3,4) pt_one(pf, num_def, ci= 0.9)
The function depicts forecast and actual data.
reg_plot(model, dataset)
reg_plot(model, dataset)
model |
An object of class |
dataset |
A dataset based on which model was built. |
The Agency of the Republic of Kazakhstan for Regulation and Development of Financial Market (AFR)
data(macroKZ) model <- lm(real_gdp ~ usdkzt + eurkzt + imp + exp, data = macroKZ) reg_plot(model, macroKZ)
data(macroKZ) model <- lm(real_gdp ~ usdkzt + eurkzt + imp + exp, data = macroKZ) reg_plot(model, macroKZ)
Test for detecting violation of Gauss-Markov assumptions.
reg_test(y)
reg_test(y)
y |
A numeric vector or an object of class |
reg_test
returns an object of class "reg_test"
.
An object of class "reg_test"
is a list containing the
following components:
bp |
Breusch-Pagan statistic |
bg |
Breusch-Godfrey statistic |
dw |
Durbin-Watson statistic |
gq |
Godfrey-Quandt statistic |
data(macroKZ) model <- lm(real_gdp~ imp + exp + poil + eurkzt + usdkzt, macroKZ) reg_test(model)
data(macroKZ) model <- lm(real_gdp~ imp + exp + poil + eurkzt + usdkzt, macroKZ) reg_test(model)
The function allows to choose regressors based on multiple criteria as AIC, RMSE etc
regsel_f( model, pval = 0.3, metric = "adjr" & "aic", progress = FALSE, details = FALSE, ... )
regsel_f( model, pval = 0.3, metric = "adjr" & "aic", progress = FALSE, details = FALSE, ... )
model |
is a linear regression model |
pval |
p value; variables with p value less than |
metric |
statistical metrics used to estimate the best model |
progress |
Logical; if TRUE, will display variable selection progress. |
details |
Logical; if |
... |
other arguments |
Hebbali, Aravind. Published 2020-02-10. olssr package
data(macroKZ) model <- lm(real_gdp ~ imp + exp + poil + eurkzt + tonia_rate, data = macroKZ) regsel_f(model)
data(macroKZ) model <- lm(real_gdp ~ imp + exp + poil + eurkzt + tonia_rate, data = macroKZ) regsel_f(model)
Calculates the variation inflation factors of all predictors in regression models
vif_reg(model)
vif_reg(model)
model |
is a linear regression model |
Petrie, Adam. Published 2020-02-21. regclass package
data(macroKZ) model <- lm(real_gdp ~ imp + exp + poil + eurkzt + tonia_rate, data = macroKZ) vif_reg(model)
data(macroKZ) model <- lm(real_gdp ~ imp + exp + poil + eurkzt + tonia_rate, data = macroKZ) vif_reg(model)