This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

You can also embed plots, for example:

library("Quandl")
## Loading required package: xts
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
library("tseries")
gpc <- Quandl("FRED/GPDIC1", type="zoo")
str(gpc)
## 'zooreg' series from 1947 Q1 to 2015 Q4
##   Data: num [1:276] 223 206 200 238 263 ...
##   Index: Class 'yearqtr'  num [1:276] 1947 1947 1948 1948 1948 ...
##   Frequency: 4
par(mfrow=c(2,2))
plot(gpc,xlab="",ylab="gpc",main="gpc")

#there is exponetial trend so we transform data to log.



lgpc<-log(gpc)

par(mfrow=c(2,2))

plot(lgpc,xlab="",ylab="Log of gpc",main="Log gpc")



d.lgpc<-diff(lgpc)



par(mfrow=c(2,2))

plot(d.lgpc,xlab="",ylab="differance of Log of gpc",main="Differance of Log gpc")

adf.test(gpc)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  gpc
## Dickey-Fuller = -2.7222, Lag order = 6, p-value = 0.2718
## alternative hypothesis: stationary
kpss.test(gpc)
## Warning in kpss.test(gpc): p-value smaller than printed p-value
## 
##  KPSS Test for Level Stationarity
## 
## data:  gpc
## KPSS Level = 6.5221, Truncation lag parameter = 3, p-value = 0.01
adf.test(lgpc)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  lgpc
## Dickey-Fuller = -2.6039, Lag order = 6, p-value = 0.3216
## alternative hypothesis: stationary
kpss.test(lgpc)
## Warning in kpss.test(lgpc): p-value smaller than printed p-value
## 
##  KPSS Test for Level Stationarity
## 
## data:  lgpc
## KPSS Level = 6.8856, Truncation lag parameter = 3, p-value = 0.01
adf.test(d.lgpc)
## Warning in adf.test(d.lgpc): p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  d.lgpc
## Dickey-Fuller = -7.3938, Lag order = 6, p-value = 0.01
## alternative hypothesis: stationary
kpss.test(d.lgpc)
## Warning in kpss.test(d.lgpc): p-value greater than printed p-value
## 
##  KPSS Test for Level Stationarity
## 
## data:  d.lgpc
## KPSS Level = 0.03644, Truncation lag parameter = 3, p-value = 0.1
# for adf test . orginal modeland log model have  unit root they have stationarity . difference log model does not have.
# for kpss test log model has unit root , but orginal model and difference log model are stationarity.

#B

nya<-Quandl("YAHOO/INDEX_NYA",type="zoo")

str(nya)
## 'zoo' series from 1965-12-31 to 2016-02-24
##   Data: num [1:12625, 1:6] 529 527 528 531 532 ...
##  - attr(*, "dimnames")=List of 2
##   ..$ : NULL
##   ..$ : chr [1:6] "Open" "High" "Low" "Close" ...
##   Index:  Date[1:12625], format: "1965-12-31" "1966-01-03" "1966-01-04" "1966-01-05" ...
nya <- nya$Close

nya<-ts(nya,start=c(1965-12-31))

#there is exponetial trend so we transform data to log.

lnya<-log(nya)
str(lnya)
##  Time-Series [1:12625] from 1922 to 14546: 6.27 6.27 6.27 6.27 6.28 ...
##  - attr(*, "index")= Date[1:12625], format: "1965-12-31" "1966-01-03" ...
d.lnya<-diff(lnya)
str(d.lnya)
##  Time-Series [1:12624] from 1923 to 14546: -0.002803 0.001194 0.006195 0.001787 0.000996 ...
par(mfrow=c(2,1))

plot(nya,xlab="",ylab="nya  Index",main="nya Index")
plot(lnya,xlab="",ylab="Log of nya",main="Log nya")

plot(d.lnya,xlab="",ylab="differance of Log of nya",main="Differance of Log nya")

adf.test(nya)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  nya
## Dickey-Fuller = -2.48, Lag order = 23, p-value = 0.375
## alternative hypothesis: stationary
kpss.test(nya)
## Warning in kpss.test(nya): p-value smaller than printed p-value
## 
##  KPSS Test for Level Stationarity
## 
## data:  nya
## KPSS Level = 43.659, Truncation lag parameter = 25, p-value = 0.01
adf.test(lnya)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  lnya
## Dickey-Fuller = -2.3244, Lag order = 23, p-value = 0.4409
## alternative hypothesis: stationary
kpss.test(lnya)
## Warning in kpss.test(lnya): p-value smaller than printed p-value
## 
##  KPSS Test for Level Stationarity
## 
## data:  lnya
## KPSS Level = 48.099, Truncation lag parameter = 25, p-value = 0.01
adf.test(d.lnya)
## Warning in adf.test(d.lnya): p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  d.lnya
## Dickey-Fuller = -22.884, Lag order = 23, p-value = 0.01
## alternative hypothesis: stationary
kpss.test(d.lnya)
## Warning in kpss.test(d.lnya): p-value greater than printed p-value
## 
##  KPSS Test for Level Stationarity
## 
## data:  d.lnya
## KPSS Level = 0.10143, Truncation lag parameter = 25, p-value = 0.1
#C

library("Quandl")

DGS<-Quandl("FRED/DGS10",type="zoo")
str(DGS)
## 'zoo' series from 1962-01-02 to 2016-02-23
##   Data: num [1:13520] 4.06 4.03 3.99 4.02 4.03 4.05 4.07 4.08 4.08 4.1 ...
##   Index:  Date[1:13520], format: "1962-01-02" "1962-01-03" "1962-01-04" "1962-01-05" ...
dDGS<-diff(DGS)

par(mfrow=c(1,2))

plot(DGS,xlab="",ylab="DGS",main="DGS")

#there is no exponetial trend so we do not transform data to log.


plot(dDGS,xlab="",ylab="dDGS",main="dDGS")

adf.test(DGS)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  DGS
## Dickey-Fuller = -2.0916, Lag order = 23, p-value = 0.5396
## alternative hypothesis: stationary
kpss.test(DGS)
## Warning in kpss.test(DGS): p-value smaller than printed p-value
## 
##  KPSS Test for Level Stationarity
## 
## data:  DGS
## KPSS Level = 17.377, Truncation lag parameter = 26, p-value = 0.01
adf.test(dDGS)
## Warning in adf.test(dDGS): p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  dDGS
## Dickey-Fuller = -22.177, Lag order = 23, p-value = 0.01
## alternative hypothesis: stationary
kpss.test(dDGS)
## Warning in kpss.test(dDGS): p-value greater than printed p-value
## 
##  KPSS Test for Level Stationarity
## 
## data:  dDGS
## KPSS Level = 0.23991, Truncation lag parameter = 26, p-value = 0.1
# for adf test orginal model has unit root but difference model is stationarity.
#for kpss orginal model not stationarity but difference model is stationarity.