-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReadMe.Rmd
92 lines (60 loc) · 1.84 KB
/
ReadMe.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
---
title: "Modeling and forecasting inflation in Sri Lanka using ARIMA models"
author: " Srinesh Heshan Fernando"
date: "2021/6/4"
output: html_document
---
```{r setup, include=FALSE}
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
```{r cars}
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)***
```{r cars 1}
Sri_Lanka <- ts(SL,start=1960,frequency=1)
str(Sri_Lanka)
```
***View trend chart***
```{r cars 2}
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.
```{r cars 2.1}
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:
```{r cars 2.5}
tsdisplay(Sri_Lanka,xlab="year",ylab="inflation rates index")
```
#differential processing
First do log smoothing, and then do differential processing:
```{r cars 3}
Srilog <- log(Sri_Lanka)
Sridiff <- diff(Srilog, differences=1)
plot.ts(Sridiff)
```
***Check the ACF and PACF ***
```{r cars 4}
```
```{r cars 5}
```
```{r cars 6}
```