Home > Uganda > Least Squares Regression on Uganda’s Consumer Price Index Items Influencing Inflation Rate Part I

Least Squares Regression on Uganda’s Consumer Price Index Items Influencing Inflation Rate Part I

Views expressed hear are mine and if their mistakes please feel free to correct me. About four to five years back I was buying Petrol at around 2200, right now its 3500 Shillings. I am quite disgusted with whats going on in the country. The prices of basics are very high, the way the Government is handling the walk to work demonstrators is totally inhumane. The inflation rate as of now is predicated to hit 14%. All this is happening when at the back of my mind I know that Government wasted a lot of tax payers money on recent presidential campaigns to finance their campaigns and bribery. I have rage that continues to build as I see corrupt officers (Freedom fighters :-)) set free and time is wasted on legislations that will not build this country but fulfill personal ambitions. Okay enough of my rage.

Am blogging about this because when you look at the graph of CPI items, it seems they are just increasing not going down. I look/analyze the inflation rate in Uganda using Composite Consumer Price Index (CPI) values from the Bank of Uganda Website. From wiki inflation rate is a measure of inflation, the rate of increase of a price index (for example, a consumer price index). If we can predict CPI values that are used to calculate inflation rate, that means we are able to predict the inflation rate.

The major factors (CPI items) that decide the Uganda inflation rate as stated in the excel sheet are:-

  • Food
  • Beverages and tobacco
  • Clothing and footwear
  • Rent, Fuel and utilities
  • House hold and personal goods
  • Transport and communication.
  • Education
  • Health ,entertainment & Others

If we are able to build a linear function that can predict each of the items above based on their historical values, then we can predict the inflation rate of Uganda with an acceptable Root mean square error. For each of the CPI items above, Least squares regression will be used to find five weights that we apply to recent historical values to estimate/predicate next month CPI of the item and the Root mean square error (RMSE) from predictions.




Weights w5=0.022637182175 w4=0.100118564555 w3=-0.512433115279 w2=1.4003471128 w1=-0.887631618337 RMSE 2.58435645556

Beverages and tobacco

Beverages and tobacco

Weights w5=-0.0298913144449 w4=0.0725116912485 w3=0.0976276103987 w2=0.868294319031 w1=-0.305850948846 RMSE 1.5260998916

Clothing and footwear

Clothing and footwear

Weights w5=0.0239711496303 w4=-0.024598729962 w3=-0.151485582327 w2=1.1642440814 w1=-0.945136789909 RMSE 1.06661287832

Rent, Fuel and utilities

Rent, Fuel and utilities

Weights w5=0.156511226268 w4=0.0550308851393 w3=-0.203995309207 w2=1.00390775576 w1=-0.409702600111 RMSE 1.46182056121

H.hold and personal goods

Weights w5=-0.0963582348489 w4=0.114897496498 w3=-0.284761046831 w2=1.2779029176 w1=-0.840274448644 RMSE 0.896403337867

Transport and communication.

Transport and communication.

Weights w5=-0.0706169477501 w4=0.178402858572 w3=-0.0634676065735 w2=0.947318628322 w1=1.09095269902 RMSE 2.09112314015



Weights w5=0.138779134167 w4=0.0193111903052 w3=-0.00781772033164 w2=0.85619997931 w1=-0.00122761969614 RMSE 1.02538674821

Health ,entert. & Others

Health ,entert. & Others

Weights w5=0.169849157617 w4=-0.135560311837 w3=-0.0875331304828 w2=1.07711171275 w1=-1.90130658745 RMSE 1.0335827302

All items index

All items index

Weights w5=0.0327337947705 w4=0.0300853160046 w3=-0.367693694924 w2=1.31370438163 w1=-0.465757986242 RMSE 0.932900847743

To be able to predict the next CPI value for an Item, we take four previous values from current date and apply weights for them. e.g if we want to predict the Food CPI for march we take values Feb 2011 to Nov 2010.

2010	Nov	173.44
	Dec	173.69
2011	Jan	179.53
	Feb	183.04

The predicated Food CPI for march based on weights w5=0.022637182175 w4=0.100118564555 w3=-0.512433115279 w2=1.4003471128 w1=-0.887631618337 would be:-

183.04 * w5 + 179.53 * w4 + 173.69 * w3 + 173.44 * w2 + w1 = 175.10

After calculating the predicted CPI for every Item, them we can apply the inflation rate.
Predicting values may not give the right answer since we are only looking at values of CPI, to further bring it closer to the present value, surrounding factors e.g. currency rate have to be considered.

To be Continued…

Categories: Uganda
  1. jonathan tabs
    May 16, 2011 at 8:47 am

    please avail me with consumer price percenatges for uganda in the last five years
    * Food
    * Beverages and tobacco
    * Clothing and footwear
    * Rent, Fuel and utilities
    * House hold and personal goods
    * Transport and communication.
    * Education
    * Health ,entertainment & Others

  2. Joseph Ssenyange
    May 16, 2011 at 9:15 am

    I don’t have that data. Currently UBOS provides CPI data from 2008. Details of the data can be downloaded from http://www.ubos.org/index.php?st=pagerelations&id=138&p=related%20pages:Consumer%20price%20Index I think if you are really interested in that data dating back five years, you will have to contact UBOS.

  3. isaac
    September 2, 2011 at 2:31 pm

    Hi Joseph,

    Nice write up, great analysis. Can you upload a copy of historic CPI rates for info?


  4. Joseph Ssenyange
    September 2, 2011 at 3:08 pm

    The data I used is from the excel sheets below I got from the BOU website at that time:-



    And the python code I used to generate the graphs and weights you can get it from


  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: