International Journal of Research and Innovation in Social Science

Submission Deadline-29th November 2024
November 2024 Issue : Publication Fee: 30$ USD Submit Now
Submission Deadline-05th December 2024
Special Issue on Economics, Management, Sociology, Communication, Psychology: Publication Fee: 30$ USD Submit Now
Submission Deadline-20th November 2024
Special Issue on Education, Public Health: Publication Fee: 30$ USD Submit Now

Nexus of Cryptocurrency and Outputgap in Nigeria: A Decision Tree Regression in Machine Learning using Python Programming Language

Nexus of Cryptocurrency and Output gap in Nigeria: A Decision Tree Regression in Machine Learning using Python Programming Language.

Umeokwobi Richard and Ocheni Victor

Monetary Policy Department, Central Bank of Nigeria

DOI: https://dx.doi.org/10.47772/IJRISS.2023.701181

Received: 19 October 2023; Accepted: 26 October 2023; Published: 25 November 2023

ABSTRACT

This study examines how the output gap would react to daily bitcoin series, this is achieved through the use of decision tree regression in machine learning which is estimated in a Python programming language. The gap in literature is in three strands which are basically empirical literature, variable, and methodology. High-powered (daily) data were used in the analysis covering the scope of 2010 to 2022, where Bitcoin was used to proxy cryptocurrency. The Garch model was used to control the volatility in the bitcoin series before carrying out the decision tree regression analysis.   The work of Jia et al (2023) was used to lay the assumption of Bitcoin and the prediction of output gap in Nigeria. The result of our analysis shows that bitcoin is predicted to reduce the output gap in Nigeria, which was linked to the fact that macro variables such as inflation can be controlled based on the result. Policy implications from the result were used to conclude the paper.

Keywords: Output gap, Bitcoin, Decision Tree Regression, Machine Learning, Python

INTRODUCTION

The output gap is claimed by Billmeier (2014) to be a   widely used indicator of the economy’s cyclical position and degree of slack. The output gap is majorly used to detect cyclical positions in an economy, that is the various levels of recession and progress. The output gap is broadly used in making macro policy decisions.  Furlanetto, Gelain, and Sanjani (2014) are of the view that Economic indicators like potential growth and the output gap cannot be observed. However, they are essential factors for policymakers to consider when determining the direction of policy, whether it be in establishing interest rates or achieving fiscal balance. For economists and policymakers, the recent global shocks have been a sobering event because it has cast severe doubt on earlier projections of potential output and the output gap. The importance of financial and asset variables such as cryptocurrency is largely ignored in most estimations of potential and actual output, instead emphasizing the roles of labor, capital, technology, and occasionally trade variables. Keynes (1936) made us understand that investment is a component of growth in an economy.

Cryptocurrency, majorly proxied by Bitcoin has been classified by many authors as an investment, Qin et al (2022) describe Bitcoin as a blockchain-based cryptocurrency. According to (Ferreira,2018) bitcoin was the first cryptocurrency, it attracted a lot of media attention and was soon embraced by investors and consumers. Its value is solely determined by supply and demand, and it may be exchanged for several fiat currencies, including USD, EUR, JPY, or GBP. Seetharaman et al. (2017) believe that bitcoin is an alternative that can address the issues with both fiat currencies and gold standards. A virtual currency that can be expanded or decreased to maintain the pace of supply and has a finite supply linked to mathematical programming. According to Yermack (2015), Bitcoin lacks additional qualities that are typically found in currencies used in contemporary economies. Bitcoin must instead be held through a system of “digital wallets,” which has proven to be both expensive to manage and prone to thieves. Bohme et al. (2015), are of the view that Bitcoin is a distributed transaction log that is shared among a network of participant computers. It has methods for rewarding sincere engagement, boosting early adopters’ adoption, and preventing power monopolies.

According to Jia et al. (2023), Bitcoin is currently the most prevalent and well-known cryptocurrency. The Bitcoin network, also referred to as “Proof of Work,” has been constructed using a consensus process (POW). Regarding transportability, infrastructure, scarcity, rarity, etc., Jie et al (2023) also believed that Bitcoin is superior to gold. It is rarer than gold since the entire Bitcoin system is designed to produce only 21 million Bitcoins, and once that number is reached, no more Bitcoins will be produced.

In Nigeria, cryptocurrency has been seen as a form of savings and investment, which indirectly goes into the growth of the economy. However, it is classified as a part of the shadow market, which makes it difficult to compute during national income accounting. Therefore, the relationship with growth has not been fully estimated. This is why machine learning would be better for analyzing cryptocurrency and determining the relationship it has with other variables. This is because machine learning helps solve complex problems and make accurate decisions based on patterns and data.

Ahanaya et al (2021), empirically understudied the effect of cryptocurrency on the Nigerian economy and they made use of quantitative data sourced from the respondents through the administration of structured questionnaires. According to their study’s findings, a sizable proportion of people are now completely convinced that Bitcoin is a real, safe, and valuable form of currency.  The gap in literature would be on three strands, which are basically the empirical literature, variable, and methodology. First, much empirical literature has not investigated cryptocurrency and growth in Nigeria, papers like Onah and Umeokwobi (2022), researched liquidity management and cryptocurrency in Nigeria using Ardl methodology, Ahanaya et al (2021) have investigated the relationship between cryptocurrency and growth in Nigeria. Tunji, Ibrahim, Rashid, and Abdulganiy (2021) investigate how cryptocurrencies are affecting the Nigerian economy, they found out that there is little negative relationship between bitcoin and Nigeria’s level of economic growth. Although there are some restrictions on the usage of cryptocurrencies as a medium of exchange because of the inherent risk and official rejection in Nigeria. Acho (2021) investigated the impact on the Nigerian economy of legalizing the usage of cryptocurrency as a means of trade.

Secondly, this paper would use variables such as Bitcoin to proxy cryptocurrency and the output gap would be used to proxy growth, in other to get the difference between the actual output of an economy and its potential output. Thirdly, since cryptocurrency is basically in the shadow market and a bit complex to analyze, it impacts on growth. This paper will employ the machine learning methodology basically the decision tree regression methodology to analyze the nexus of cryptocurrency and output gap. Most complex analyses are being done with machine learning, scholars like Xianzheng, Hui, and Huaigang (2023) used neural networks to forecast equity premiums.

The volatility of the bitcoin variable would be analyzed using the garch analysis, while the output gap series were gotten by using the hp-filter. The rest of the paper is organized as follows. Section 2 presents the methodology and data. Section 3 discusses the empirical results. Section 4 concludes the paper.

METHODOLOGY AND DATA

The study seeks to examine the nexus of cryptocurrency and the output gap in Nigeria using the Garch (1,1) model in estimating the volatility, while the decision tree regression will be used in estimating the nexus. The study covered daily data ranging from January 2010 to December 2022, because this is the most recent period of global shocks that affects cryptocurrency. The data were extracted from, the Central Bank of Nigeria’s (CBN) statistical bulletin and Bloomberg.

Volatility refers to the degree of variation or fluctuation in the price or value of a financial instrument, over a specific period. It measures the rate at which the price of an asset changes, indicating the level of uncertainty or risk associated with that asset. To model volatility Engle (1982) developed the Autoregressive Conditional Heteroscedastic (ARCH) model which was further extended by Bollerslev (1986) to the Generalized Autoregressive Condition Heteroscedastic (GARCH) model.

Autoregressive Conditional Heteroskedasticity (Arch) is a model used in econometrics to analyze and predict volatility in time series data.  It is commonly used in finance to model and forecast the volatility of asset returns. The arch is often used in conjunction with other models, such as the General Autoregressive Conditional Heteroskedasticity (GARCH) model, to provide more accurate volatility forecasts.

yt=ut                                                                                (1)

ut~N(0,σt2)

                                          (2)

If we use Arch (1) model it becomes, the model becomes.

                                                      (3)

The Generalized Autoregressive Conditional Heteroskedasticity (GARCH) model is an extension of the ARCH model. It is commonly used in finance and econometrics to model and forecast volatility in time series data. The Garch model allows for more flexibility in capturing the dynamics of volatility compared to the Arch model. It can capture volatility clustering, leverage effects (asymmetric response to positive and negative shocks), and long-term persistence in volatility.

                             (4)

All parameters in the variance equation must be positive and (α+β) is expected to be less than one but it is close to 1. If the sum of the coefficients equals 1 it is called an Integrated GARCH (IGARCH) process.

The most common method for constructing a regression tree is CART, which is the Classification and Regression Tree methodology, which is also known as recursive partitioning. The method of decision tree regression starts by searching for every distinct value of all predictors, and splitting the value of a predictor that minimizes the following statistic (other regression tree models have different optimization criteria):

                                  (5)

Where ȳ1 and ȳ2 are the average values of the dependent variable in group S1 and S2 . For groups S1 and S2, the method will recursively split the predictor values within groups. In practice, the method stops when the sample size of the split groups falls below a certain threshold, e.g., 50.

Pruning can be done by penalizing the SSE with tree size, to prevent over-fitting:

SSECP=SSE+ CP* St                                                 (6)

Where St is the size of the tree (number or terminal nodes), and CP is the complexity parameter. Smaller CP is the complexity parameter. Smaller CP will lead to larger trees, and vice versa. This parameter can then be tuned by cross-validation.

EMPIRICAL RESULT

The arch test is a statistical test used to determine if there is autoregressive conditional heteroscedasticity in a time series. Majorly used to test for volatility in series.

Table 1: Arch test

Variables Arch(1)Lm stat                          P
bitcoinr 237.39 0.00

The result of the Arch test in table 1, shows that the bitcoin has an arch effect on their residuals. Therefore, we can model residual terms by Garch model. This is a statistical test used to analyze volatility in financial markets. It is termed General Autoregressive Conditional Heteroskedasticity.

Table 2: Garch statistics

Variables bitcoinr      
Past (-1) 0.02
Residual 0.11***
Garch 0.89***

note: * represents 10 percent significance, ** represents 5 percent significance, while *** represents 1 percent significance.

From table 2, it shows that the volatility of bitcoinr is not affected by their past. Bitcoinr showed not to be persistent throughout the period of analysis, this is because the residual and garch of bitcoinr is approximately one. The explanatory variables in the analysis, is explained below, basically the mean, median, maximum, minimum, and standard deviation is explained below in the tab.

Table 3: Explanatory statistics

Variables og bitcoinr
Mean 67.51 0.00
Median -2134.70 0.00
Maximum 24112.13 0.08
Minimum -18352.25 0.00
Standard dev. 10511.03 0.00
Observation 3248 3248

The descriptive statistics presented in Table 3, shows that og has the highest mean value among the variable, with a value of 67.51. The table also showed that bitcoinr has the highest median value of 0.00. The variable with the highest maximum value is og with a value of   24112.13, while bitcoinr has a maximum value of 0.08. The variable with the minimum value is og with a value of 18352.25. The standard deviation of og has a higher value compared to its mean. This means that the og time series in the model are more dispersed.

Decision tree regression would be used to analyze the cryptocurrency and output gap to predict their relationship. The decision tree algorithm will split the data based on different values of these features and make predictions at each leaf node. It can help identify patterns or trends between cryptocurrency and the output gap in Nigeria. The figure below, shows the decision tree regression table, and the various value, which each of the leaves from the nodes possess. This would base its assumption on the work of Jie et al (2023) that propounded that the entire Bitcoin system is designed to produce only 21 million Bitcoins, and once that number is reached, no more Bitcoins will be produced. This work therefore adopted the assumption of Jie et al (2023) but assumed that if bitcoin reached 10 million what would be the value of og in Nigeria.

Figure 1: Decision Tree Regression

From the decision regression tree, the predicted output gap from the 10 million volume of bitcoin shows that og would be at 6367.19 million naira at that period. This can then be used in comparison with their various maximum values.

Table 4: Comparison of maximum and decision tree regression

Variables Maximum decision tree regression
Og 24112.13 6367.19
Bitcoinr 0.08 10

The comparison between the maximum value of both variables shows that an increase in Bitcoin would not bring about an increase in og. If following what Jie et al (2023), proposed of 23 million of bitcoin, and the production of bitcoin would stop. Assuming the volume of bitcoin got to 10 million, the og in Nigeria would be at about 6367.16 which is below its maximum value of 24112.13.  In other to accurate for accuracy, the decision tree regression would be pruned in other to get a more accurate prediction of the og.

Pruning is a technique used in decision tree algorithms to prevent overfitting. It involves removing or collapsing branches that are not significant or do not contribute much to the overall accuracy of the tree. Pruning helps simplify the tree and improve its generalization ability.  In decision tree algorithms, total impurities represent the overall impurity or uncertainty in a node, while effective alpha is a parameter used in pruning to determine the level of pruning.

Figure 2: Total Impurities and effective alpha

By comparing the total impurities and effective alpha, we can decide whether to prune a particular node or not. If the total impurities are below the effective alpha, pruning can be applied to simplify the tree and improve its generalization ability.

Based on figure 2, 0.06 was chosen as the effective alpha, because this value has a lot of impurities below it, and this was used in pruning some nodes in our decision tree regression analysis. Our decision tree regression was then simplified to figure 3.

Pruning Decision Tree Regression Table

Figure 3: Pruning of Decision Tree Regression Table

After pruning the tree, our decision tree regression becomes more simplified, and it shows that the og can either have a value of 9317.59 or 9281.39 which is when bitcoin is about 10 million. The code of our programme, after predicting for the value of og, shows that og is going to have a value of 9281, when bitcoin is 10. We further compared the new value of og after pruning with the maximum of its explanatory statistics in the table below.

Table 5: Comparison of maximum and pruned decision tree regression

Variables Maximum decision tree regression
Og 24112.13 9281
Bitcoinr 0.08 10

From the above table, it could be seen that after pruning the value of og increases to 9281, when compared to the value of og before pruning which was 6367.  Though it remains that bitcoin has an inverse relationship with og based on our comparison of the value of og after pruning with its maximum value of the explanatory variable, with the assumption that bitcoin reached about 10 million.

CONCLUSION

This paper tries to investigate the nexus of cryptocurrency and og using a machine-learning approach which is coded in Python programming language. The decision tree regression is the model of the machine learning adopted. The paper used Bitcoin as a proxy for cryptocurrency, and the output gap was gotten using the H-p filter. The garch was used to control the volatility of the Bitcoin series. The series of the data are high-powered (daily) data covering the period of January 2010 to December 2022. The paper adopted from the work of Jia et al. (2023), that 23 million bitcoin is the maximum production of bitcoin worldwide. Therefore, we based our assumption that if half of that, say 10 million is produced what would be the level of output gap in Nigeria?

The decision tree regression before pruning showed that the output gap would be about 6367 million naira, but after pruning it showed to be 9281 million naira. When compared with the maximum of the explanatory variable, it showed that a bitcoin of about 10 million would drastically reduce the output gap in Nigeria. This means that, if bitcoin reduces the output gap it shows that the gap between actual and potential output will be reduced if people patronize or invest in bitcoin in Nigeria. This contraction means that investing in bitcoin would lead to a reduction in the amount of money supply in the economy that is why we are having a contraction in the output gap.

For policy implications, while bitcoin is seen as a decentralized currency, which is currently not legalized in the Nigerian economy, but the analysis through the reduction of output gap with the use of machine learning has showed that it is a potential inflation resistant currency. Though its adoption and integration into monetary policy frameworks can be complex because of its nature of being decentralize and a tool in the shadow market. The monetary policy might try to understudy the characteristics of bitcoin and try to embed it into its E-naira, since both are carried out in a blockchain. If E-naira is developed to have some characteristics of Bitcoin, maybe it can then be used as an alternative to bitcoin for reducing the output gap, which would be used in the control of inflation.

REFERENCES

  1. Acho, Y. (2021). Crypto-currency and the Nigerian economy. journal of international relations, security and economic studies (JIRSES).
  2. C.G, Oshinowo. A. D, Sanni. A. S. Arogundade. J. A, and Ogunwole. O. J. (2021). The effect of cryptocurrencies on Nigeria. IEEE-SEM. 9(3).
  3. Billmeier, A., (2014). Ghostbusting: Which output gap measure really matters? International Monetary Fund r. 4(14)
  4. Bohme, R., Christin, N., Edelman, B., & Moore, T. (2015). Bitcoin: economics, technology, and governance. Journal of Economic Perspective. 29(2).
  5. Ferreira, F. (2018). Bitcoin: an asset or a currency. instituto universitario de lisboa.
  6. Furlanetto, F., Gelain, P. & Sanjani, M.T. (2014). The output gap in the presence of financial frictions and monetary policy trade-offs. International Monetary Fund.14(8).
  7. Jia, Z., Tiwari, S., Zhou, J., Farooq, M., & Fareed, Z. (2023). Asymmetric nexus between bitcoin, gold resources, and stock market returns novel findings from quantile estimates. Resource Policy. (81).
  8. Keynes, J.M. (1936) The General Theory of Employment, Interest, and Money. John Maynard Keynes.
  9. Onah, O. A., & Umeokwobi, R.O. (2022). Critical Assessment of Liquidity Management and Cryptocurrency in Nigeria: An ARDL Analysis. Asian Journal of Economics, Finance and Management, 4(1),404–415.Retrieved from https://www.globalpresshub.com/index.php/AJEFM/article/view/1643
  10. Tunji, T., Ibrahim, S., Rashid, A., & Abdulganiy, A. (2021). Cryptocurrency and the Nigerian economy. African journal of accounting and financial research.4(3).180-193.
  11. Z, Hui.Z, & Huaigang. L (2023). Forecasting the equity premium: Do deep neural network models work? Modern Finance.1(1).1-11.
  12. Yermack, D. (2015). Is Bitcoin a real currency? an economic appraisal. handbook of digital currency.

Article Statistics

Track views and downloads to measure the impact and reach of your article.

2

PDF Downloads

106 views

Metrics

PlumX

Altmetrics

Paper Submission Deadline

GET OUR MONTHLY NEWSLETTER

Subscribe to Our Newsletter

Sign up for our newsletter, to get updates regarding the Call for Paper, Papers & Research.

    Subscribe to Our Newsletter

    Sign up for our newsletter, to get updates regarding the Call for Paper, Papers & Research.