Category A:

The data I have choosen was Real personal consumption expenditures per capita FRED/A794RX0Q048SBEA. The data is a Quarterly data from 1947 Q1 to 2015 Q4.

library(zoo)
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
library(Quandl)
## Loading required package: xts
library(tseries)
library(forecast)
## Loading required package: timeDate
## This is forecast 6.2
rpc<-Quandl("FRED/A794RX0Q048SBEA",api_key="5NyVfHfxdScCYsskDP59", type="zoo")
str(rpc)
## 'zooreg' series from 1947 Q1 to 2015 Q4
##   Data: num [1:276] 8378 8479 8468 8431 8437 ...
##   Index: Class 'yearqtr'  num [1:276] 1947 1947 1948 1948 1948 ...
##   Frequency: 4
head(rpc)
## 1947 Q1 1947 Q2 1947 Q3 1947 Q4 1948 Q1 1948 Q2 
##    8378    8479    8468    8431    8437    8501
plot(rpc, xlab=" Years 1947 Q1 - 2015 Q4", ylab="RPC", main="Real personal consumption expenditures per capita(Quarterly)")

acf(rpc,lag=12)

pacf(rpc,lag=12)

The plot suggests an exponential increase of the data. Therefore, we can take a log of the data (though this exponential increase gives an indication that the data is difference stationary)

lrpc<-log(rpc)
par(mfrow=c(2,1))
plot(lrpc,xlab=" Years 1947 Q1 - 2015 Q4", ylab="lrpc", main="Log Real personal consumption expenditures per capita(Quarterly)")

plot(rpc,xlab=" Years 1947 Q1 - 2015 Q4", ylab="lrpc", main="Real personal consumption expenditures per capita(Quarterly)")

Therefore, from the plots, we can get a hint that the data is not becoming stationary after log difference as well.

drpc<-diff(rpc)
par(mfrow=c(2,1))
plot(rpc,xlab=" Years 1947 Q1 - 2015 Q4", ylab="lrpc", main="Real personal consumption expenditures per capita(Quarterly)")

plot(drpc,xlab=" Years 1947 Q1 - 2015 Q4", ylab="lrpc", main="Differenced Real personal consumption expenditures per capita(Quarterly)")

ADF and KPSS test to check stationarity:

1.Log Transformed Data

adf.test(lrpc)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  lrpc
## Dickey-Fuller = -1.1924, Lag order = 6, p-value = 0.9062
## alternative hypothesis: stationary
kpss.test(lrpc, null="Trend")
## Warning in kpss.test(lrpc, null = "Trend"): p-value smaller than printed p-
## value
## 
##  KPSS Test for Trend Stationarity
## 
## data:  lrpc
## KPSS Trend = 0.66564, Truncation lag parameter = 3, p-value = 0.01

Therefore, ADF test fails to reject the null hypothesis of non-stationarity.

2. 1st differenced data:

adf.test(drpc)
## Warning in adf.test(drpc): p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  drpc
## Dickey-Fuller = -4.9702, Lag order = 6, p-value = 0.01
## alternative hypothesis: stationary
kpss.test(drpc)
## 
##  KPSS Test for Level Stationarity
## 
## data:  drpc
## KPSS Level = 0.63604, Truncation lag parameter = 3, p-value =
## 0.01936

Here, both ADF rejects the null hypothesis of non-stationarity. KPSS test still rejects the null hypothesis which says that the data should again be differenced and then it can be stationary.

Category B:

The data had been chosen was NYSE Composite Index

library(zoo)
library(Quandl)
library(tseries)
library(forecast)
sse_c <-read.csv("C:\\Users\\ASMSHAKIL\\Desktop\\YAHOO-INDEX_SSEC.csv", header=TRUE, sep=",")
sse <- ts(sse_c[,7], start=c(1997,7))
str(sse)
##  Time-Series [1:4518] from 2003 to 6520: 2903 2927 2860 2863 2867 ...
head(sse)
## [1] 2903.331 2927.175 2860.021 2862.893 2867.338 2836.571

Here, we have used only the closing data.

tsdisplay(sse,lag.max=100, xlab=" Years 1997-2016", ylab="SSEC Composite Index", main="Shanghai Composite Index(Daily)")

Seeing the plot, we can say that the data has a downward trend but does not show very strong exponential decay. But as there are fluctuations, let’s take the log and check whether it becomes stationary or not.

lsse<-log(sse)
par(mfrow=c(2,1))
plot(sse,xlab=" Years 1997-2016", ylab="SSEC Composite Index", main="Shanghai Composite Index(Daily)")
plot(lsse,xlab=" Years 1997-2016", ylab="Log SSEC Composite Index", main="Log Shanghai Composite Index(Daily)")

Even after taking the log, the trend is not ging away. Therefore, we can have a hint that the data is difference stationary. Therefore if we take the difference and plot, we can see:

dsse<- diff(sse)
par(mfrow=c(2,1))
plot(sse,xlab=" Years 1997-2016", ylab="SSEC Composite Index", main="Shanghai Composite Index(Daily)")
plot(dsse,xlab=" Years 1997-2016", ylab="Differenced SSEC Composite Index", main="Differenced Shanghai Composite Index(Daily)")

ADF and KPSS test for Stationarity:

Log transformed data:

adf.test(lsse)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  lsse
## Dickey-Fuller = -2.2461, Lag order = 16, p-value = 0.4741
## alternative hypothesis: stationary
kpss.test(lsse, null="Trend")
## Warning in kpss.test(lsse, null = "Trend"): p-value smaller than printed p-
## value
## 
##  KPSS Test for Trend Stationarity
## 
## data:  lsse
## KPSS Trend = 1.031, Truncation lag parameter = 15, p-value = 0.01

Therefore, we can see, ADF fails to reject the Null of non-stationarity where KPSS suggests that it is difference stationary.

Differenced data:

adf.test(dsse)
## Warning in adf.test(dsse): p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  dsse
## Dickey-Fuller = -14.242, Lag order = 16, p-value = 0.01
## alternative hypothesis: stationary
kpss.test(dsse, null="Trend")
## Warning in kpss.test(dsse, null = "Trend"): p-value greater than printed p-
## value
## 
##  KPSS Test for Trend Stationarity
## 
## data:  dsse
## KPSS Trend = 0.051405, Truncation lag parameter = 15, p-value =
## 0.1

Here, ADF test rejects the null and KPSS test fails to reject the null. This suggests that, the differenced series is stationary.

Category C:

The data had been chosen was Yield on BAA Corporate Bonds.

baa_1<-read.csv("C:\\Users\\ASMSHAKIL\\Desktop\\FED-RIMLPBAAR_N_M.csv", header=TRUE, sep=",")
baa<- ts(baa_1[,2])
str(baa)
##  Time-Series [1:1165] from 1 to 1165: 5.45 5.46 5.46 5.34 5.34 5.19 5.2 5.13 4.89 4.48 ...
head(baa)
## [1] 5.45 5.46 5.46 5.34 5.34 5.19
tsdisplay(baa,lag.max=100, xlab=" Years Jan 1919 - Jan 2016", ylab="Yield on BAA Corporate Bonds", main="Yield on BAA Corporate Bonds(Monthly)")

Based on the plot of the main series, there is no exponential trend (rather it looks a bit cyclical). As there are fluctuations, if we take log transformation, we get:

lbaa<-log(baa)
par(mfrow=c(2,1))
plot(baa, xlab=" Years Jan 1919 - Jan 2016", ylab="Yield on BAA Corporate Bonds", main="Yield on BAA Corporate Bonds(Monthly)")
plot(lbaa, xlab=" Years Jan 1919 - Jan 2016", ylab="Log Yield on BAA Corporate Bonds", main="Log Yield on BAA Corporate Bonds(Monthly)")

Again, log transformation didnot help much to get rid from the pattern of the timeseries.Therefore, it indicates, stationarity can be achieved by differing. If we look at the plot of differecing we see that after differencing, the data shows smewhat stationarity.

dbaa<-diff(baa)
par(mfrow=c(2,1))
plot(baa, xlab=" Years Jan 1919 - Jan 2016", ylab="Yield on BAA Corporate Bonds", main="Yield on BAA Corporate Bonds(Monthly)")
plot(dbaa, xlab=" Years Jan 1919 - Jan 2016", ylab="Differenced Yield on BAA Corporate Bonds", main="Differenced Yield on BAA Corporate Bonds(Monthly)")

ADF and KPSS Test:

Log transformed data:

adf.test(lbaa)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  lbaa
## Dickey-Fuller = -2.1529, Lag order = 10, p-value = 0.5136
## alternative hypothesis: stationary
kpss.test(lbaa, null="Trend")
## Warning in kpss.test(lbaa, null = "Trend"): p-value smaller than printed p-
## value
## 
##  KPSS Test for Trend Stationarity
## 
## data:  lbaa
## KPSS Trend = 1.5639, Truncation lag parameter = 7, p-value = 0.01

Here, ADF test fails to reject the null of non-stationarity where as KPSS test suggests, differencing is required to make the data stationary.

adf.test(dbaa)
## Warning in adf.test(dbaa): p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  dbaa
## Dickey-Fuller = -8.1346, Lag order = 10, p-value = 0.01
## alternative hypothesis: stationary
kpss.test(dbaa, null="Trend")
## Warning in kpss.test(dbaa, null = "Trend"): p-value greater than printed p-
## value
## 
##  KPSS Test for Trend Stationarity
## 
## data:  dbaa
## KPSS Trend = 0.10662, Truncation lag parameter = 7, p-value = 0.1

Now, we can see, ADF test rejects the null hypothesis of non-stationarity and KPSS test also suggests that the differenced series is stationary.