GitHunt
FE

fernandosrinesh/Modeling-and-forecasting-inflation-R-Project

Modeling and forecasting inflation in Sri Lanka using ARIMA models


title: "Modeling and forecasting inflation in Sri Lanka using ARIMA models"
author: " Srinesh Heshan Fernando"
date: "2021/6/4"
output: html_document

knitr::opts_chunk$set(echo = TRUE,warning = FALSE)

INTRODUCTION

This study is based on a data set of annual rates of inflation in Sri Lanka (LK) ranging over the period 1960 – 2019. All the data was adapted from the World Bank data sources.

Load the data

library(zoo)
library(forecast)
library(ggplot2)
library(tseries)
setwd("C:/Users/wangz/Desktop") 
md <- read.csv("data.csv",header = TRUE)
SL<- md[md$Country.Name == 'Sri Lanka',]
CN<- md[md$Country.Name == 'China',]
SL <- SL[ , !names(SL) %in% c("Country.Name", "Country.Code","Indicator.Name","Indicator.Code")]
SL <-t(SL)
rownames(SL) <- c(1960:2020)
colnames(SL) <- c("inflation rates")

Converting data to time series format (TS)

Sri_Lanka <- ts(SL,start=1960,frequency=1)
str(Sri_Lanka)

View trend chart

plot.ts(Sri_Lanka)

Stationary

The augmented Dickey Fuller (ADF) test can be used to test whether a time series is stationary or not. The Ho is that the sequence is nonstationary.

adf.test(Sri_Lanka,alternative="stationary")

As the p-value is higher than 0.05, so we can not reject the Ho, which means the
sequence is nonstationary.

#seasonality/ ACF and PACF:

tsdisplay(Sri_Lanka,xlab="year",ylab="inflation rates index") 

#differential processing

First do log smoothing, and then do differential processing:

Srilog <- log(Sri_Lanka)
Sridiff <- diff(Srilog, differences=1)
plot.ts(Sridiff)

***Check the ACF and PACF ***




fernandosrinesh/Modeling-and-forecasting-inflation-R-Project | GitHunt