Forecasting Exchange Rate CNY USD

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

Journal of Actuarial, Finance and Risk Management (JAFRM)

Vol. 00(0), April, 2023.

Forecasting Exchange Rate for USD/CNY : A Box Jenkins


Approach with Auto Regressive Integrated Moving Average
(ARIMA) Modeling
Whitney Karundeng1, Edwin Setiawan Nugraha2,
1,2Study Program of Actuarial Science, School of Business, President University, 17550, Indonesia
*Corresponding author: whitney.karundeng@student.president.ac.id

Abstract— Currency exchange rate have an important impact on the economy and finance fields. Fluctuation of between
domestics and foreign exchange rate commonly happens because certain things. Recession, inflations, export and import activities,
political stability and government debt can be certain reasons fluctuations could happen [1]. In this study, we apply an appropriate
tool from statistics which is Box-Jenkins Approach specifically known as Auto Regressive Integrated Moving Average (ARIMA)
modeling to assest the ability of standardized exchange rate models to predict exchange rates in the short and long runs. The time
series data used is about percentage exchange rate of the Chinese Yuan Renmimbi to the US Dollar provided weekly from
February 2022 - February 2023 with a total of 54 data. Thorugh testing and research, it was found that the ARIMA model (2,2,1)
was the most accurate model among other ARIMAs for examining our data. The percentage of (Mean Absolute Percentage Error)
MAPE ARIMA (2,2,1) is 1.48%.

Keywords— Forecasting; Exchange rate; ARIMA; Box Jenkins; Stationarity; USD; Chinese Yuan; US Dollar

I. INTRODUCTION
Economic and financial activities are always confronted in our lives. Currency exchange rates brings a high influence,
especially in the finance and economic sector. In most cases, people consider that exchange rate only required under certain
conditions. In finance, the exchange rate (also known as foreign exchange rate, foreign exchange rate, FX rate, or Asgio) between
two currencies is the rate at which one currency would be exchanged for another. It is also considered the value of one country's
currency in relation to the exchange rates of other foreign currencies. This rate depends on the local demand for foreign currencies
and their local supply, the country's trade balance, the strength of its economy, and other such factors. Basically, exchange rates
go through fluctuation constantly throughout weekly because it is actively transacted [2].
Exchange rates are constantly moving, based on supply and demand. Whether one currency is in higher demand than another,
depends on the perceived value of owning it, either to pay for goods and services, or as an investment. As well as travelling
abroad, common reasons to exchange currencies include paying mortgages, funding a child's education, or preparing for retirement
overseas. On a greater scale, currencies are exchanged for other reasons, including trade - buying goods and services from another
country - and investment. There also some key that affects the exchange rates to be changeable, which is : interest rates and
inflation, trading relationship within countries, market expectations, etc [3].
The exchange rate between the Chinese Yuan (CNY) and the US Dollar (USD) is an important thing because acts as an indicator
of relative economic strength, has a direct impact on each nation’s economy by affecting the value of imports and exports [4].
Exchange rates are causes or effects. They can be both. If the exchange rate is fairly steady and not subject to much volatility and
the interest rates are higher, then it was interesting for hedge funds to take advantage of higher interest rates in the US and lower
rates in Japan. Thus, an important carry trade developed when the Fed started raising rates. So, the exchange rate in this case was
a cause. On the other hand, the exchange rate can be the effect brought about by various causes. The central bank may debase the
currency and thus a fall in the value of the currency would be an effect of the policy of the central bank. A trade deficit could also
bring about a lower value of the currency of the country in Forex markets. The question is rather a moot point since what counts
is where the exchange rate for a currency pair is. Whether changes are brought about by causes or effects becomes almost
irrelevant. What is important for investors is to stay informed about important currency pairs like the USD/CNY and try to do
prediction with a high accuracy level for currency exchange rates of USD/CNY [5].
Based on several similar studies also carried out by several parties such as Hanisah, Faezzah, Norsyafiqah, Nyoni Tabani, the
ARIMA Model is a statistical tool that is very accurate for predicting exchange rates in the future data with a minim percentage
of error rate measured [6] [7]. It is challenging to make high-quality predictions. However, many forecasting models may be built
for that purpose. A unit model and a series of time models are two examples of such models. To construct an economic model,
some of the characteristics that are thought to strongly influence. The elements that impact and influence the movement of a
certain currency must be collected before developing a model that ties these aspects to exchange rates. Autoregressive Integrated
Moving Average (ARIMA) is a time-series model that utilizes its own previous values as a descriptive variable [7].

1
Journal of Actuarial, Finance and Risk Management (JAFRM)
Vol. 00(0), April, 2023.

II. LITERATURE REVIEW

A. Time Series Data & Analysis

A time series data is a set of statistics that depends on variable time. The intentions of time series data and analysis is to
provided predict data for the future by forecasting previous data. Example of time series occurin a variety of fields, ranging from
economics, finance, engineering, and methods of analysing time series constitute an important area of statistics [8]. Measurements
may be made continuously through time or be taken at a discrete set of time points. Discrete and continuous time series difference
lies on observed variable, which is the time. There are main objectives needed for time-series analysis, which is :
(a) Description :describing data using summarize or graphical methods.
(b) Modelling : from the pastor present values in one series, can help to explain the variation in another series. All models
created are in the form of approximations.
(c) Forecasting : prediction to estimate the future values of the series.
(d) Control : good forecast result requires to take further action to maintain the series [9].

B. Stochastics Process

In probability theory and related fields, a stochastic (/stoʊˈkæstɪk/) or random process is a mathematical object usually defined
as a sequence of random variables; where the index of the sequence has the interpretation of time. Stochastic processes are widely
used as mathematical models of systems and phenomena that appear to vary in a random manner [10]. A stochastic process is a
family of random variables {𝑋𝑡 , 𝑡 ⋲ 𝑇} where 𝑇 ⊆ 𝑇0 defined on a probability space {𝛺, ℱ, 𝑃}. In time-series analysis, the T is
the parameters of time points, very often {0, ±1, ±2, … }, {1,2,3, … }, [0, ∞) or (−∞, ∞). Where stochastic processes with 𝑇 the
surface of sphere is used to represent variables indexed by their own location on the earth’s surface. In this study, the index set of
𝑇 will be the subset of ℝ [11].

C. Stationarity & Non-Stationarity Process

In mathematics, a stationary process has the property that the mean, variance and autocorrelation structure doesn’t alter when
shifted over time. Stationarity can be defined in precise mathematical terms, but for our purpose we mean a flat looking series,
without trend, constant variance over time, a constant autocorrelation structure over time and no periodic fluctuations
(seasonality). Somewhile, a time series could be non-stationary when it doesn’t have a consistent mean or distribution across time.
The application that can be done to counter non-stationary to be stationary is to perform several transformation techniques, which
are as follows:
(a) We can difference the data. That is, given the series Zt, we create the new series : 𝒀𝒊 = 𝒁𝒊 − 𝒁𝒊−𝟏
(b) The differenced data will comprise 1 less point than the original data. However, data differencing can be obtained more
than once, one difference is usually adequate.
(c) If the data conceive a trend, fitting in some type of curve to the data and then model the residuals from that fit. Since the
purpose of the fit is to simply remove long term trend, a simple fit, such as a straight line, is typically used.
(d) For non-constant variance, taking the logarithm or square root of the series may stabilize the variance. For negative data,
we can enhance a suitable constant to make all the data positive before applying the transformation. This constant can
then be subtracted from the model to obtain predicted (i.e., the fitted) values and forecasts for future points [12].

Followings are several types of stationary levels, which are as follows:


1. Weak stationarity, also known as wide-sense stationarity, has a constant mean (moment one) and the correlation and
covariance (moment two) are invariant to time. The higher-order moments change with time.
A sequence {𝑋𝑡 , 𝑡 ⋲ ℤ} called weak stationarity/second-order stationarity if :
➢ 𝐸[𝑋𝑡 ] = 𝜇, and
➢ 𝐶𝑜𝑣 (𝑋𝑡 , 𝑋𝑡+𝑘 ) = 𝛾𝑘 ,
Where 𝜇 is constant, and 𝛾𝑘 is independent to 𝑡
2. Strong stationarity. A sequence {𝑋𝑡 , 𝑡 ⋲ ℤ} is called a strong or strict stationarity if :
𝐷
➢ (𝑋𝑡1 , … , 𝑋𝑡𝑘 ) (𝑋𝑡1+ℎ , … , 𝑋𝑡𝑘+ℎ )
=
For all sets of time points 𝑡1 , … , 𝑡𝑘 and integer ℎ
3. The sequence {𝛾𝑘 , 𝑘 ⋲ ℤ} is called the autocovariance function.
γ
4. We defined ρ𝑘 = 𝑘 = Corr (𝑋𝑡 , 𝑋𝑡+𝑘 ) and call {ρ𝑘 , 𝑘 ⋲ ℤ} the autocorrelation function (ACF).
γ0
Remarks.

2
Journal of Actuarial, Finance and Risk Management (JAFRM)
Vol. 00(0), April, 2023.

(1) A strictly stationary process is weakly stationary.


(2) If the process is Gaussian, that is (𝑋𝑡1 , … , 𝑋𝑡𝑘 ) is multsssivariate normal, for points 𝑡1 , … , 𝑡𝑘 , then weak stationarity
implies strong stationarity.
(3) 𝛾0 = 𝑉𝑎𝑟(𝑋𝑡 ) > 0, assuming 𝑋𝑡 is genuinely random.
(4) By symmetry, 𝛾𝑘 = 𝛾 − 𝑘, 𝑓𝑜𝑟 𝑎𝑙𝑙 𝑘 [8].

D. Autocorrelation Function (ACF) & Partial Autocorrelation Function (PACF)

Autocorrelation function (ACF) and Partial Autocorrelation Function (PACF) are notable tools required to analyzing the time
series data. ACF measures and plots the average correlation between data points in time series and previous values of the series
measured for different lag lengths [13]. The advantages of ACF are to recognize how correlated the values in time series are with
each other. For ACF, let 𝑥𝑡 and 𝑥𝑡−ℎ for ℎ = 1, 2, 3, 𝑒𝑡𝑐. Theoritically, the ACF between 𝑥𝑡 𝑎𝑛𝑑 𝑥𝑡−ℎ can be written below :

𝑪𝒐𝒗𝒂𝒓𝒊𝒂𝒏𝒄𝒆 (𝒙𝒕 , 𝒙𝒕−𝒉 ) 𝑪𝒐𝒗𝒂𝒓𝒊𝒂𝒏𝒄𝒆(𝒙𝒕 , 𝒙𝒕−𝒉 )


=
𝑺𝒕𝒅. 𝑫𝒆𝒗. (𝒙𝒕 ) ∙ 𝑺𝒕𝒅. 𝑫𝒆𝒗. (𝒙𝒕−𝒉 ) 𝑽𝒂𝒓𝒊𝒂𝒏𝒄𝒆(𝒙𝒕 )

The denominator in the second formula occurs because the standard deviation of a stationary series is the same at all times [14].
PACF are similar to ACF, merely the distinction lies in each partial correlation control for any correlation between observations
of a shorter lag length. PACF captures a “precise” correlation between time series and a lagged version of itself. For instance,
consider a regression context in which 𝑦 is the response variable and 𝑥1 , 𝑥2 , and 𝑥3 are predictor variables. The partial correlation
between 𝑦 and 𝑥3 is the correlation between the variables determined taking into account how both 𝑦 and 𝑥3 are related to 𝑥1 and
𝑥2 .
In regression, this partial correlation could be found by correlating the residuals from two different regressions:
(1) Regression in which we predict 𝑦 from 𝑥1 and 𝑥2 ,
(2) regression in which we predict 𝑥3 from 𝑥1 and 𝑥2 . Basically, we correlate the “parts” of 𝑦 and 𝑥3 that are not predicted
by 𝑥1 and 𝑥2 .

More formally, we can define the partial correlation just described as

𝑪𝒐𝒗𝒂𝒓𝒊𝒂𝒏𝒄𝒆 (𝒚, 𝒙𝟑 |𝒙𝟏 , 𝒙𝟐 )


√𝑽𝒂𝒓𝒊𝒂𝒏𝒄𝒆(𝒚|𝒙𝟏 , 𝒙𝟐 ) ∙ 𝑽𝒂𝒓𝒊𝒂𝒏𝒄𝒆(𝒙𝟑 |𝒙𝟏 , 𝒙𝟐 )

For a time series, the partial autocorrelation between 𝑥𝑡 and 𝑥𝑡−ℎ is defined as the conditional correlation between 𝑥𝑡 and 𝑥𝑡−ℎ ,
conditional on 𝑥𝑡−ℎ+1 , … , 𝑥𝑡−1 , the set of observations that come between the time points 𝑡 and 𝑡 − ℎ.

• The 1st order partial autocorrelation will be defined to equal the 1st order autocorrelation.
• The 2nd order (lag) partial autocorrelation is

𝑪𝒐𝒗𝒂𝒓𝒊𝒂𝒏𝒄𝒆 (𝒙𝒕 , 𝒙𝒕−𝟐 |𝒙𝒕−𝟏 )


√𝑽𝒂𝒓𝒊𝒂𝒏𝒄𝒆(𝒙𝒕 |𝒙𝒕−𝟏 ) ∙ 𝑽𝒂𝒓𝒊𝒂𝒏𝒄𝒆(𝒙𝒕−𝟐 |𝒙𝒕−𝟏 )

This is the correlation between values two time periods apart conditional on knowledge of the value in between. (By the way,
the two variances in the denominator will equal each other in a stationary series.)

• The 3rd order (lag) partial autocorrelation is

𝑪𝒐𝒗𝒂𝒓𝒊𝒂𝒏𝒄𝒆 (𝒙𝒕 , 𝒙𝒕−𝟑 |𝒙𝒕−𝟏 , 𝒙𝒕−𝟐 )


√𝑽𝒂𝒓𝒊𝒂𝒏𝒄𝒆(𝒙𝒕 |𝒙𝒕−𝟏 , 𝒙𝒕−𝟐 ) ∙ 𝑽𝒂𝒓𝒊𝒂𝒏𝒄𝒆(𝒙𝒕−𝟑 |𝒙𝒕−𝟏 , 𝒙𝒕−𝟐 )

And, so on, for any lag.


Typically, matrix manipulations having to do with the covariance matrix of a multivariate distribution are used to determine
estimates of the partial autocorrelations [15].

3
Journal of Actuarial, Finance and Risk Management (JAFRM)
Vol. 00(0), April, 2023.

III. METHODOLOGY

A. Auto Regressive (AR) Models

A common approach for modeling univariate time series is the autoregressive (AR) model:

𝒀𝒕 = 𝜹 + 𝝓𝟏 𝒀𝒕−𝟏 + 𝝓𝟐 𝒀𝒕−𝟐 + ⋯ + 𝝓𝒑 𝒀𝒕−𝒑 + 𝒆𝒕

where 𝑌𝑡 is the time series, 𝐴𝑡 is white noise, and


𝒑

𝜹 = (𝟏 − ∑ 𝝓𝒊 ) 𝝁,
𝒊=𝟏
with 𝜇 denoting the process mean.

An autoregressive model is simply a linear regression of the current value of the series against one or more prior values of the
series. The value of 𝑝 is called the order of the AR model. AR models can be analyzed with one of various methods, including
standard linear least squares techniques. AR models have a straightfprward interpretation.

B. Moving Average (MA) Models

Another common approach for modeling univariate time series models is the moving average (MA) model:

𝒀𝒕 = 𝝁 + 𝒆𝒕 − 𝜽𝟏 𝒆𝒕−𝟏 − 𝜽𝟐 𝒆𝒕−𝟐 − ⋯ − 𝜽𝒒 𝒆𝒕−𝒒

where 𝑌𝑡 is the time series, μ is the mean of the series, 𝑒𝑡−𝑖 are white noise terms, and 𝜃1 , … , 𝜃𝑞 are the parameters of the
model. The value of 𝑞 is called the order of the MA model.

That is, a moving average model is conceptually a linear regression of the current value of the series against the white noise or
random shocks of one or more prior values of the series. The random shocks at each point are assumed to come from the same
distribution, typically a normal distribution, with location at zero and constant scale. The distinction in this model is that these
random shocks are propogated to future values of the time series. Fitting the MA estimates is more complicated than with AR
models because the error terms are not observable. This means that iterative non-linear fitting procedures need to be used in place
of linear least squares. MA models also have a less obvious interpretation than AR models [16].

C. Box-Jenkins Approaches

The Box-Jenkins approaches figures information utilizing three standards: autoregression, differencing, and moving average.
These three standards are known as p, d, and q, separately. Each guideline is utilized within the Box-Jenkins approaches; together,
they are collectively appeared as ARIMA (p, d, q). Box-Jenkins is a type of autoregressive integrated moving average (ARIMA)
model that fathom the strength of one dependent variable relative to other changing variables. Purposes of the model is to predict
future securities or financial market moves by examining the differences between values in the series instead of through actual
values [17].

The Box-Jenkins ARMA model is a combination of the AR and MA models, which described below :
𝒀𝒕 = 𝜹 + 𝝓𝟏 𝒀𝒕−𝟏 + 𝝓𝟐 𝒀𝒕−𝟐 + ⋯ + 𝝓𝒑 𝒀𝒕−𝒑 + 𝒆𝒕 − 𝜽𝟏 𝒆𝒕−𝟏 − 𝜽𝟐 𝒆𝒕−𝟐 − ⋯ − 𝜽𝒒 𝒆𝒕−𝒒 ,
where the terms in the equation have the same meaning as given for the AR and MA model [18].
The box-Jenkins ARIMA model is combination of the AR and MA models, but plus the differencing, which described below:
𝑾𝒕 = 𝜹 + 𝝓𝟏 𝑾𝒕−𝟏 + 𝝓𝟐 𝑾𝒕−𝟐 + ⋯ + 𝝓𝒑 𝑾𝒕−𝒑 + 𝒆𝒕 − 𝜽𝟏 𝒆𝒕−𝟏 − 𝜽𝟐 𝒆𝒕−𝟐 − ⋯ − 𝜽𝒒 𝒆𝒕−𝒒 ,
Where :
𝑊𝑡 = ∇2 𝑌𝑡 = 𝑌𝑡 − 2𝑌𝑡−1 + 𝑌𝑡−2
𝑊𝑡−1 = ∇2 𝑌𝑡−1 = 𝑌𝑡−1 − 2𝑌𝑡−2 + 𝑌𝑡−3
𝑊𝑡−2 = ∇2 𝑌𝑡−2 = 𝑌𝑡−2 − 2𝑌𝑡−3 + 𝑌𝑡−4
𝑊𝑡−𝑛 = ∇2 𝑌𝑡−𝑛 = 𝑌𝑡−𝑛 − 2𝑌𝑡−(𝑛+1) − 𝑌𝑡−(𝑛+2)

The Box-Jenkins model assumes that the time series is stationary. Box and Jenkins recommend differencing non-stationary
series one or more times to achieve stationarity. Doing so produces an ARIMA model, with the "I" standing for "Integrated". Box-
Jenkins models are quite flexible due to the inclusion of both autoregressive and moving average terms. Building good ARIMA

4
Journal of Actuarial, Finance and Risk Management (JAFRM)
Vol. 00(0), April, 2023.

models generally requires more experience than commonly used statistical methods such as regression. Here is the visualization
of the Box Jenkins approach through tabular forms.

Figure 1 : Stages in the Box-Jenkins iterative approach

D. Model Accuracy Measurements

1) Mean Absolute Error (MAE)

MAE refers to Mean Absolute Error measures the average absolute magnitude between the actual values and the predicted
values by regression model [19]. The equation of MAE can be written as :
𝒏
𝟏
𝑴𝑨𝑬 = ∑ |𝒚(𝒊) − 𝒚
̂(𝒊)|
𝒏
𝒊=𝟏
where :
𝑛 = Total numbers of observation
𝑦(𝑖) = Actual value for the ith observation
𝑦̂(𝑖) = Predicted value for the ith observation

2) Mean Square Error (MSE)

MSE refers to Mean Square Error is the sum of squared difference between the actual values that are fitted by the model, and
observed values that are divided by the number of historical points, minus the number of parameters in the model.

̂(𝒊))𝟐
∑(𝒚(𝒊) − 𝒚
𝑴𝑺𝑬 =
𝒏
where :
𝑛 = Total numbers of observation
𝑦(𝑖) = Actual value for the ith observation
𝑦̂(𝑖) = Predicted value for the ith observation

5
Journal of Actuarial, Finance and Risk Management (JAFRM)
Vol. 00(0), April, 2023.

3) Root Mean Squared Error (RMSE)

RMSE is the square root of the MSE. It is on the same scale as the observed data values.

∑𝑵 ̂(𝒊)‖𝟐
𝒊=𝟏‖𝒚(𝒊) − 𝒚
𝑹𝑴𝑺𝑬 = √
𝑵
where :
𝑁 = Total numbers of data points
𝑦(𝑖) = Actual value for the ith observation
𝑦̂(𝑖) = Predicted value for the ith observation

4) Mean Absolute Percent Error (MAPE)

MAPE is the average absolute percent difference between the values that are fitted by the model and the observed data values
[20].
𝒏
𝟏 |𝒚(𝒊) − 𝒚
̂(𝒊)|
𝑴𝑨𝑷𝑬 = ∑
𝒏 |𝒚(𝒊)|
𝒊=𝟏
where :
𝑛 = Total numbers of observation
𝑦(𝑖) = Actual value for the ith observation
𝑦̂(𝑖) = Predicted value for the ith observation

5) Akaike Information Criterion (AIC)

The AIC is a model selection measure penalizes models with many parameters, and so attempts to choose the best model
with a preference towards simpler models. The AIC is the sum of the logarithm of non-adjusted MSE multiplied by the
number of historical points and the number of model parameters and initial smoothing states that are multiplied by 2.
𝑨𝑰𝑪 = −𝟐(𝒍𝒐𝒈 − 𝒍𝒊𝒌𝒆𝒍𝒊𝒉𝒐𝒐𝒅) + 𝟐𝑲
where:
K is the number of model parameters (the number of variables in the model plus the intercept).
Log-likelihood is a measure of model fit. The higher the number, the better the fit. This is usually obtained from statistical
output [21] [22].

6
Journal of Actuarial, Finance and Risk Management (JAFRM)
Vol. 00(0), April, 2023.

IV. RESULTS AND DISCUSSIONS


A. Overview of the Yuan Exchange Rate Against the US Dollar (USD) [23]

TABLE 1
TIME SERIES DATA
Date Exchange Rate
February 14, 2022 6.3242
February 21, 2022 6.316
February 28, 2022 6.3167
March 7, 2022 111
March 14, 2022 6.3602
March 21, 2022 6.3653
March 28, 2022 6.3616
April 4, 2022 6.3641
April 11, 2022 6.3702
April 18, 2022 6.5006
April 25, 2022 6.6075
May 2, 2022 6.6655
May 9, 2022 6.7879
May 16, 2022 6.6919
May 23, 2022 6.6976
May 30, 2022 6.6593
June 6, 2022 6.7074
June 13, 2022 6.7156
June 20, 2022 6.6883
June 27, 2022 6.7
July 4, 2022 6.6942
July 11, 2022 6.7563
July 18, 2022 6.7502
July 25, 2022 6.7432
August 1, 2022 6.7611
August 8, 2022 6.7419
August 15, 2022 6.8157
August 22, 2022 6.8703
August 29, 2022 6.899
September 5, 2022 6.9255
September 12, 2022 6.9829
September 19, 2022 7.1273
September 26, 2022 7.1149
October 3, 2022 7.115
October 10, 2022 7.19
October 17, 2022 7.2423
October 24, 2022 7.2514
October 31, 2022 7.1839
November 7, 2022 7.1071
November 14, 2022 7.1189
November 21, 2022 7.1705
November 28, 2022 7.0236
December 5, 2022 6.9566
December 12, 2022 6.9721
December 19, 2022 6.9887
December 26, 2022 6.8969
January 2, 2023 6.8374
January 9, 2023 6.7018
January 16, 2023 6.7826
January 23, 2023 6.7824
January 30, 2023 6.7742
February 6, 2023 6.8083
February 13, 2023 6.8665

Exchange rate of Yuan against USD come through increment and degression phase start from February 2022 – February 2023
viewed weekly. First of all, we download the packages and tools that will be used in analyzing time series data with the code as
follows. After that, then we import the time series data.

7
Journal of Actuarial, Finance and Risk Management (JAFRM)
Vol. 00(0), April, 2023.

TABLE 2
R STUDIO CODE
rm(list=ls())
graphics.off()

library(forecast)
library(TSA)
library(tseries)
library(openxlsx)
library(ggplot2)

data <- read_excel("CNYUSD.xlsx")


df <- data.frame(date=as.Date(data$Date),price=data$Close)
head(df)

nrow(df)

Then, we create the plot for the time series data.


TABLE 3
R STUDIO CODE
p <- ggplot(df,aes(x=date, y=price))+
geom_line(color="Purple", size=1)+
theme_minimal()+
labs(x="Monthly Quarterly", y="Rate",
title="USD/CNY")+
theme(plot.title=element_text(hjust=0.5, size=15, face="bold"))
p + scale_x_date(date_labels="%d %b %Y")+
theme (axis.text.x=element_text(angle=50, hjust=1))

Figure 2 : Plot of data on the CNY exchange rate against the USD for February 2022 - 2023

B. Stationarity Testing of the Chinesse Yuan Exchange Rate Data against the USD
Initial thing to do first is check the stationarity of the data. We use Augmented Dickey Fuller (ADF) Test to determine whether
the data is stationarity or not.

TABLE 4
R STUDIO CODE
#Stationary Check
adf.test(data$Close)

#1st Differencing
df1 = diff(data$Close)
adf.test(df1)

#2nd Differencing
df2 = diff(df1)
adf.test(df2)

8
Journal of Actuarial, Finance and Risk Management (JAFRM)
Vol. 00(0), April, 2023.

TABLE 5
DATA STATIONARITY TESTING

Differencing Level Stationarity Test ADF Statistics Test p-value


0 Differencing Against the mean -1.261 0.8719
1st Diferrencing Against the mean -2.6745 0.3031
2nd Differencing Against the mean -6.1539 0.01

After carrying out the ADF Test, using the initial data a less substantial value was obtained (p-value = 0.8719 > 0.05) which
indicates that the data on the exchange rate of the Chinese Yuan against the USD is not stationary. Based on the first test, data on
the Chinese yuan exchange rate against the dollar are not stationary at the mean. To overcome the non-stationary, then we can do
differentiation process to the exchange rate data. Result of the 1 st Differencing ADF Test is still not stationary which is the p-
value 0.3031 > 0.05. So, we need to the second differentiation.
After doing the 2nd Differentencing, the results obtained are significant because the resulting p-value is 0.01 <0.05 which means
that the data is stationary because it has a constant average. It can be concluded that the results of the second derivative of the data
on the Chinese Yuan exchange rate against the USD are available for forecasting using the ARIMA Model.
TABLE 6
R STUDIO CODE
plot.ts(df2, xlab="Data Point", ylab="Rate", main="Second Differences of Chinese Yuan Renmimbi to U.S. Dollar Exchange Rate")

Figure 3 : Plot of 2nd Differencing Exchange Rate Chinese Yuan Renmimbi to USD

C. Forecasting Chinese Yuan Renmimbi to USD using ARIMA Model


Establish the ARIMA model that is suitable for the Chinese Yuan to USD data exchange rate using ACF (Auto Correlation
Function) and PACF (Partial Auto Correlation Function).
TABLE 7
R STUDIO CODE
Pacf(df2,10)
Acf(df2,10)

9
Journal of Actuarial, Finance and Risk Management (JAFRM)
Vol. 00(0), April, 2023.

Figure 4 : Plot ACF and PACF after 2nd Level of Differentiation (d = 2)

According to Figure 3.C, we can see that from the PACF Plot there is 3-line pass outside the Barlett Line and from the ACF Plot
there are 1 line pass outside the Barlett Line. So that, PACF Plot cut-off after lag 3 and ACF Plot cut-off after lag 1. Obtaining
that ARIMA (3,2,1) is the initial model for this data. Based on the data, we conducted there are several ARIMA tentative
models that can be used, which is :
1) ARIMA (3,2,1)
2) ARIMA (3,2,0)
3) ARIMA (2,2,1)
4) ARIMA (2,2,0)
5) ARIMA (1,2,1)
6) ARIMA (1,2,0)
7) ARIMA (0,2,1)
8) ARIMA (0,2,0)
TABLE 8
R STUDIO CODE
#Modelling and Summarize
model1= arima(data$Close, order=c(3,2,1))
model2= arima(data$Close, order=c(3,2,0))
model3= arima(data$Close, order=c(2,2,1))
model4= arima(data$Close, order=c(2,2,0))
model5= arima(data$Close, order=c(1,2,1))
model6= arima(data$Close, order=c(1,2,0))
model7= arima(data$Close, order=c(0,2,1))
model8= arima(data$Close, order=c(0,2,0))

library(forecast)
summary(model1)
summary(model2)
summary(model3)
summary(model4)
summary(model5)
summary(model6)
summary(model7)
summary(model8)

10
Journal of Actuarial, Finance and Risk Management (JAFRM)
Vol. 00(0), April, 2023.

TABLE 9
ESTIMATION AND TESTING OF SIGNIFICANCE OF MODEL PARAMETERS
Parameter Log
Model MSE AIC
Type Value Likelihood

1 AR (1) -0.3039
AR (2) -0.3069
0.003606 -136.02 72.01
ARIMA (3,2,1) AR (3) -0.2588
MA (1) -0.4166
2 AR (1) -0.6471
AR (2) -0.4863 0.003759 -136.01 71
ARIMA (3,2,0)
AR (3) -0.3460
3 AR (1) 0.1826
AR (2) 0.0228 0.003524 -137.97 71.98
ARIMA (2,2,1)
MA (1) -0.9617
4 AR (1) -0.5400
0.004328 -131.07 67.54
ARIMA (2,2,0) AR (2) -0.2921
5 AR (1) 0.1809
0.003531 -139.95 71.97
ARIMA (1,2,1) MA (1) -0.9554
6
AR (1) -0.4148 0.004763 -128.28 65.14
ARIMA (1,2,0)
7
MA (1) -0.8779 0.003662 -140.66 71.33
ARIMA (0,2,1)
8
0.005886 -117.16 58.58
ARIMA (0,2,0)

To get the best model for forecasting, we need to compare the value of AIC. From table 3, there are 2 ARIMA Models
that have a lower value for Mean Squared Error (MSE) and Akaike’s Information Criterion (AIC). As a result, choosen Model 3
ARIMA (2,2,1) and Model 7 ARIMA (0,2,1) as a finest model to perform a prognostic of the exchange rate of CNY to USD from
February 2022-2023 in weekly terms.
TABLE 10
R STUDIO CODE
# Residual Analysis (P-value > 0.05)
shapiro.test(residuals(model1))
Box.test(residuals(model1),type="Ljung-Box")
shapiro.test(residuals(model2))
Box.test(residuals(model2),type="Ljung-Box")
shapiro.test(residuals(model3))
Box.test(residuals(model3),type="Ljung-Box")
shapiro.test(residuals(model4))
Box.test(residuals(model4),type="Ljung-Box")
shapiro.test(residuals(model5))
Box.test(residuals(model5),type="Ljung-Box")
shapiro.test(residuals(model6))
Box.test(residuals(model6),type="Ljung-Box")
shapiro.test(residuals(model7))
Box.test(residuals(model7),type="Ljung-Box")
shapiro.test(residuals(model8))
Box.test(residuals(model8),type="Ljung-Box")

11
Journal of Actuarial, Finance and Risk Management (JAFRM)
Vol. 00(0), April, 2023.

TABLE 11
RESIDUAL ANALYSIS MODEL

Model ARIMA Type Saphiro-Wilk Test Box-Ljung Test Accepted Status


1 ARIMA (3,2,1) 0.0641 0.8555 Yes
2 ARIMA (3,2,0) 0.02812 0.4557 No
3 ARIMA (2,2,1) 0.06194 0.8939 Yes
4 ARIMA (2,2,0) 0.0951 0.3828 Yes
5 ARIMA (1,2,1) 0.05427 0.8801 Yes
6 ARIMA (1,2,0) 0.1284 0.3137 Yes
7 ARIMA (0,2,1) 0.2242 0.4225 Yes
8 ARIMA (0,2,0) 0.04816 0.001645 No

To examine residuals, we performed diagnostic testing through Shapiro-Walking Normality and Box-Ljung Test. From 8
models, there are 6 models passing criteria of this testing. the thing to consider here is the model that has the minimum MSE and
AIC values, therefore we take model 3 ARIMA (2,2,1) and model 7 ARIMA (0,2,1) which meet the requirements of a good
regressive model to do forecasting.
TABLE 12
ARIMA MODEL ACCURACY VALUE (P,D,Q) AGAINST TESTING DATA
Model ARIMA Type MSE RMSE MAE MAPE
3 ARIMA (2,2,1) 0.010820819 0.014783294 0.102013429 1.48%
5 ARIMA (0,2,1) 0.017603077 0.0191195 0.131869143 1.91%

According to the Mean Absolute Percentage Error (MAPE), Model 3 ARIMA (2,2,1) has the minim value rather than Model 5
ARIMA (0,2,1). We can conclude that, the arima model (2,2,1) is the most suitable model for the prediction of the data we use.
For the mathematically formula, we can describe ARIMA (2,2,1) in the equation described below:

𝑾𝒕 = 𝜹 + 𝝓𝟏 𝑾𝒕−𝟏 + 𝝓𝟐 𝑾𝒕−𝟐 + 𝒆𝒕 − 𝜽𝟏 𝒆𝒕−𝟏


Where :
𝑊𝑡 = ∇2 𝑌𝑡 = 𝑌𝑡 − 2𝑌𝑡−1 + 𝑌𝑡−2
𝑊𝑡−1 = ∇2 𝑌𝑡−1 = 𝑌𝑡−1 − 2𝑌𝑡−2 + 𝑌𝑡−3
𝑊𝑡−2 = ∇2 𝑌𝑡−2 = 𝑌𝑡−2 − 2𝑌𝑡−3 + 𝑌𝑡−4

𝒀𝒕 − 𝟐𝒀𝒕−𝟏 + 𝒀𝒕−𝟐 = 𝜹 + 𝝓𝟏 (𝒀𝒕−𝟏 − 𝟐𝒀𝒕−𝟐 + 𝒀𝒕−𝟑 ) + 𝝓𝟐 (𝒀𝒕−𝟐 − 𝟐𝒀𝒕−𝟑 + 𝒀𝒕−𝟒 ) + 𝒆𝒕 − 𝜽𝟏 𝒆𝒕−𝟏

𝒀𝒕 = (𝟐 + 𝟎. 𝟏𝟖𝟐𝟔)𝒀𝒕−𝟏 + (−𝟐(𝟎. 𝟏𝟖𝟐𝟔) − 𝟏 + 𝟎. 𝟎𝟐𝟐𝟖)𝒀𝒕−𝟐 + (𝟎. 𝟏𝟖𝟐𝟔 − 𝟐(𝟎. 𝟎𝟐𝟐𝟖))𝒀𝒕−𝟑 + (𝟎. 𝟎𝟐𝟐𝟖)𝒀𝒕−𝟒 + 𝒆𝒕
− (−𝟎. 𝟗𝟔𝟏𝟕)𝒆𝒕−𝟏

𝒀𝒕 = 𝟐. 𝟏𝟖𝟐𝟔𝒀𝒕−𝟏 − 𝟏. 𝟑𝟒𝟐𝟒𝒀𝒕−𝟐 + 𝟎. 𝟏𝟑𝟕𝒀𝒕−𝟑 + 𝟎. 𝟎𝟐𝟐𝟖𝒀𝒕−𝟒 + 𝒆𝒕 + 𝟎. 𝟗𝟔𝟏𝟕𝒆𝒕−𝟏

TABLE 13
R STUDIO CODE

plot(rstandard(model3),type="o")
abline(h=0)

#Visual Analysis
qqnorm(residuals(model3))
qqline(residuals(model3))

Here is the visualization plot and normal distributions of ARIMA Model (2,2,1).

12
Journal of Actuarial, Finance and Risk Management (JAFRM)
Vol. 00(0), April, 2023.

Figure 5 : Plot and Normal Distribution of ARIMA (2,2,1)


TABLE 14
R STUDIO CODE

acf(residuals(model3),100)
pacf(residuals(model3),50)

Figure 6 : ACF and PACF of ARIMA (2,2,1)


TABLE 15
R STUDIO CODE

#Forecast
frc=stats::arima(data$Close,order = c(2,2,1))
fcast=forecast(frc,h=8,level=c(90))
plot(fcast)
fcast
plot(fcast,xlab = "Data Point", ylab = "Exchange Rate", main= "Forecast using ARIMA(2,2,1)", lwd=1)

13
Journal of Actuarial, Finance and Risk Management (JAFRM)
Vol. 00(0), April, 2023.

Figure 7 : Plot of Exchange Rate of CNY/USD Prediction Result


TABLE 16
R STUDIO CODE

#Data Preparation
CNYUSD <- read_excel("CNYUSD.xlsx")
View(CNYUSD)
#Second Data
CNYUSD2 <- read_excel("CNYUSD2.xlsx")
View(CNYUSD2)
Data <- data.frame(date=as.Date(CNYUSD2$Date),price=CNYUSD2$Close)
tail(Data)
nrow(Data)
#Set Data Training
Data_training <- CNYUSD[1:53,]
#Forecast
model3=stats::arima(Data_training$Close, order = c(2,2,1)) #Best Model
fcast=forecast(model3,h=8,level=c(95))
Dfcast <- data.frame(Date=Data[54:61,1],Close=fcast$mean)
head(Dfcast)
f<- ggplot(df, aes(x=date, y=price))+
geom_line()+geom_smooth(aes(x=Date, y=Close,ymax=fcast$upper,
ymin=fcast$lower),colour="red",data=Dfcast,
stat="identity") + theme_bw()
f+scale_x_date(date_breaks = "1 month", date_labels = "%b-%Y") +
theme(axis.text.x = element_text(angle = 45, vjust=1,hjust=1))

14
Journal of Actuarial, Finance and Risk Management (JAFRM)
Vol. 00(0), April, 2023.

Figure 8 : Plot of Exchange Rate of CNY/USD Forecast Result


TABLE 17
COMPARISON OF ACTUAL DATA AND PREDICTED DATA OF MODEL 3 ARIMA (2,2,1)
Upper Predicted Actual
Date (Weekly) Lower Bound MSE RMSE MAE MAPE
Bound Data Data
20 February 2023 6.709944 6.907118 6.808531 6.9550 0.0215 0.021 0.146 2.11%
27 February 2023 6.648961 6.959016 6.803988 6.9068 0.0106 0.015 0.103 1.49%
06 March 2023 6.596569 7.000912 6.798741 6.9052 0.0113 0.015 0.106 1.54%
13 March 2023 6.548450 7.038328 6.793389 6.8861 0.0086 0.013 0.093 1.35%
20 March 2023 6.502586 7.072458 6.788022 6.8670 0.0062 0.012 0.079 1.15%
27 March 2023 6.457945 7.107360 6.782652 6.8678 0.0073 0.012 0.085 1.24%
03 April 2023 6.413947 7.140619 6.777283 6.8788 0.0103 0.015 0.102 1.48%
Results 0.010820819 0.014783294 0.102013429 1.48%

Figure 8 : Comparison plot of Exchange Rate CNY/USD

V. CONCLUSION
State that, ARIMA modeling is a capable model to do forecasting towards exchange rate of CNY to USD. ARIMA (2,2,1) as
the best and most suitable model to predict exchange rate of CNY to USD with with an error rate based on the MAPE percentage:
1.48%, which means that the accuracy of this model for predicting according to actual data is 98.52%. The forecast showed that
exchange rate of CNY to USD for the end of February to April 2023 decrease by approximately 0.5%. The most suitable formula
is ARIMA (2,2,1), the formula is given below :

𝒀𝒕 = 𝟐. 𝟏𝟖𝟐𝟔𝒀𝒕−𝟏 − 𝟏. 𝟑𝟒𝟐𝟒𝒀𝒕−𝟐 + 𝟎. 𝟏𝟑𝟕𝒀𝒕−𝟑 + 𝟎. 𝟎𝟐𝟐𝟖𝒀𝒕−𝟒 + 𝒆𝒕 + 𝟎. 𝟗𝟔𝟏𝟕𝒆𝒕−𝟏

15
Journal of Actuarial, Finance and Risk Management (JAFRM)
Vol. 00(0), April, 2023.

References

[1] Investopedia, "Currency Fluctuations: How they Affect the Economy," 4 June 2021. [Online]. Available:
https://www.investopedia.com/articles/forex/080613/effects-currency-fluctuations-economy.asp#toc-far-reaching-currency-impacts. [Accessed 5 April
2023].
[2] S. N. Roy, "CONCEPT OF FOREIGN EXCHANGE RATE," Knowgen Education Services Private Limited, 2021.
[3] H. E. Group, "What drives exchange rates?," HSBC Expat Group, [Online]. Available: https://www.expat.hsbc.com/international-banking/what-makes-
exchange-rates-move/. [Accessed 5 April 2023].
[4] A. Mullen, "What does a stronger US dollar-yuan exchange rate mean, and why is Beijing worried?," South China Morning Post, 21 October 2021.
[Online]. Available: https://www.scmp.com/economy/china-economy/article/3153177/what-does-stronger-us-dollar-yuan-exchange-rate-mean-and-why.
[Accessed 09 April 2023].
[5] W. S. F. C. SA, "U.S. Dollar Index Vs. Chinese Yuan," Seeking Alpha, 8 June 2020. [Online]. Available: https://seekingalpha.com/article/4352602-u-s-
dollar-index-vs-chinese-yuan. [Accessed 9 April 2023].
[6] T. Nyoni, "Modeling and Forecasting Naira / USD Exchange Rate In Nigeria: a Box – Jenkins ARIMA approach," Munich Personal RePEc Archive
(MPRA), Zimbabwe, 2018.
[7] F. M. D. N. M. Hanisah Hanun Muhamad Hatta, "An Application of Time Series ARIMA Forecasting Model for Predicting the Ringgit Malaysia-Dollar
Exchange Rate," Data Analysis, vol. I, no. 1, pp. 42-48, 2018.
[8] T. S. Laboratory, "University of Cambridge," [Online]. Available: http://www.statslab.cam.ac.uk/~rrw1/timeseries/t.pdf. [Accessed 5 April 2023].
[9] C. Chatfield, "Time-Series Forecasting," in Time-Series Forecasting, Washington, D.C., Chapman & Hall/CRC, 2000, pp. 12-13.
[10] Wikipedia, "Wikipedia," Wikipedia, 13 January 2017. [Online]. Available: https://en.wikipedia.org/wiki/Stochastic_process. [Accessed 10 April 2023].
[11] R. A. D. Peter J. Brockwell, "Time Series : Theory and Methods," in Time Series : Theory and Methods Second Edition, Fort Collins, Springer
Science+Business Media New York, 1991, pp. 8-9.
[12] N. I. o. S. a. Technology, "6.4.4.2. Stationarity," National Institute of Standards and Technology, [Online]. Available:
https://www.itl.nist.gov/div898/handbook/pmc/section4/pmc442.htm. [Accessed 5 April 2023].
[13] P. A. R. Limited, "Time Series Analysis: A Short Introduction to ACF, PACF and Differencing," Linkedin, 3 November 2021. [Online]. Available:
https://www.linkedin.com/pulse/time-series-analysis-short-introduction-/?trk=pulse-article. [Accessed 10 April 2023].
[14] P. S. D. o. Statistics, "1.2 Sample ACF and Properties of AR(1) Model," Penn State's Eberly College of Science, [Online]. Available:
https://online.stat.psu.edu/stat510/lesson/1/1.2. [Accessed 10 April 2023].
[15] P. S. D. o. Statistics, "2.2 Partial Autocorrelation Function (PACF)," Penn State's Eberly College of Science, [Online]. Available:
https://online.stat.psu.edu/stat510/lesson/2/2.2. [Accessed 10 April 2023].
[16] N. I. o. S. a. Technology, "6.4.4.4. Common Approaches to Univariate Time Series," National Institute of Standards and Technology, [Online]. Available:
https://www.itl.nist.gov/div898/handbook/pmc/section4/pmc444.htm. [Accessed 10 April 2023].
[17] G. Scott, "Box-Jenkins Model: Definition, Uses, Timeframes, and Forecasting," Investopedia, 30 August 2022. [Online]. Available:
https://www.investopedia.com/terms/b/box-jenkins-model.asp. [Accessed 9 April 2023].
[18] N. I. o. S. a. Technology, "6.4.4.5 Box-Jenkins Models," National Institute of Standards and Technology, [Online]. Available:
https://www.itl.nist.gov/div898/handbook/pmc/section4/pmc445.htm. [Accessed 9 April 2023].
[19] TrainDataHub, "Interpretation of Evaluation Metrics For Regression Analysis (MAE, MSE, RMSE, MAPE, R-Squared, And Adjusted R-Squared),"
Medium, 24 May 2022. [Online]. Available: https://medium.com/@ooemma83/interpretation-of-evaluation-metrics-for-regression-analysis-mae-mse-
rmse-mape-r-squared-and-5693b61a9833. [Accessed 8 April 2023].
[20] IBM Corporation, "Forecasting statistical details," IBM Corporation, 3 January 2023. [Online]. Available: https://www.ibm.com/docs/en/cognos-
analytics/11.1.0?topic=forecasting-statistical-details. [Accessed 8 April 2023].
[21] C. Delfina, "What is the interpretation of RMSE, MAE, MPE, MAPE, and MASE in testing forecasting accuracy?," Quora, Manila, 2021.
[22] S. Kumar, "What are three measures of forecasting accuracy?," Quora, Tamil Nadu, India, 2021.
[23] Y. Finance, "USD/CNY (CNY=X)," Yahoo Finance, [Online]. Available:
https://finance.yahoo.com/quote/CNY%3DX/history?period1=1644796800&period2=1676246400&interval=1wk&filter=history&frequency=1wk&incl
udeAdjustedClose=true. [Accessed 25 March 2023].

16

You might also like