Thursday 4 February 2016

Canadian dollar exchange rate analysis (2007-2015)

This post is about how you can have a scientific approach to thinking or analyzing different phenomena using Bayesian Network. The only tools I used to prepare information were OpenOffice's Spreadsheet and the tools I have provided for this blog. I was looking for some data source on the web and finally found the Canadian to US dollars exchange rate in last nine years in Bank of Canada website. If you just draw the rate for 2007 to 2015, you'll have something like the following graph.

Canadian to US dollar exchange rate (data source: Bank of Canada)

Did you note the rates between September and December of 2007?!

I know by looking at it, you see the ups and downs and perhaps can have some guesses about what will happen in next few months. But let us see how a Bayesian Network can model this trend and help us to find out more from this information. 

The information I used for this analysis is base on a daily basis, now if you just simply draw a Bayesian Network, which shows the up, down or un-change state of a day based on its previous day for these years you'll have the following Bayesian Network.

up / down / no change state of Canadian dollar exchange rate

What this Bayesian Network says is almost hidden in the trend you see, like:

- No matter in which state you are, your next day's rate with a probability of 0.553 or 0.542 or 0.648 will not change. 
- If it's been a while the rate hasn't changed, then it is more likely to go down than up with ratio of 0.181/0.171=1.058
- Or If it's been a while that the rate hasn't changed, then gets down, don't panic it is more likely to go up than staying down at the chance of 0.328/0.138=2.377

So as you see you can extract much useful information from this single Bayesian Network, but we still can obtain information with the given data from the Bank of Canada.

Consider building a Bayesian Network, which shows the relation between the quarter of the year and the chances of being in up, down or not changed state. If you do this, you'll have the following network.

Bayesian Network which shows the relation of the quarter
of a year and Canadian dollar exchange rate changes

The graph has four quarter node named 1,2,3 and 4 and like the previous one three rate change symbols "up", "down" and "nchngd" (for not-changed) Now we have more information to decide what the next day's rate will be and it depends on what quarter we are in at the moment. If you want to see when the rate has most ups, look at all the arrows end to "up" node, you see in quarter two the chance of having more "up" is more than the other quarters. Or for downs, quarter one is the worst. 

Note that you can use Naive Bayesian Theorem to calculate and see how will the rate tomorrow based on the quarter and today's rate state. Since our source data is daily basis, we cal also build the second network based on months, and then we have the following:

Bayesian Network which shows the relation of the month 
of a year and Canadian dollar exchange rate changes

This one gives you a better resolution and perhaps result if you provide enough training data for your Bayesian Network.

OK, now if you write a program to build these Bayesian Networks and then based on the given training data try to estimate the next 30 days, for som runs of the application you'll have the following trends.

Trend estimation for Canadian dollar based on information in this post.

Here I have supposed in the first day we have a rate of 70 (for 0.70), and then the colors show every different runs the Bayesian Network gives us. Now you can have some analysis of these trends to have a better understanding of this crash position. Note that this model doesn't tell you why it is happening, it just helps you to see how you can do some analysis with this basic information to improve the way you look to the future.

So as you see, it is unlikely to have a better rate in 30 days, while it is more likely to have it lower than 0.70 cents.

This post is not the correct place to talk about what happens when we continuously use the Bayesian Network or if we need to update the network as we derived some new data, or how much error we have after driving a new estimation, etc. We will talk about them later.

Did you notice the point?
Consider you have some more information and not necessarily all of them financial such as:

- inflation, 
- political stability, 
- economic performance, 
- the balance of investment, 
- terrorist attacks and war, 
- elections, 
- etc ... 

And then build a very complex network based on this information, now you could have a much better estimation of tomorrow's rate. 

No comments:

Post a Comment