(This article was first published on

okay so now we are up and plotting. Let's dive into some analysis.**The Dancing Economist**, and kindly contributed to R-bloggers)First we want to see if we can use the series so we have to see if its covariance stationary and that means that its mean is constant and also we can't be able to predict the errors.

we do this by plotting the difference of the terms to get the errors and if we have crazy up and downlines with no distinguishable pattern then we can can fit the errors to a line of some sort. thats a great and beautiful thing.

1. To do this plot type the following

*plot.ts(diff(log(GDP)),main="Logged and Diffed")*

Mission accomplished. We have an up and down picasso beauty.

We can now get fancy and smooth the series with a 2-way moving average.

fGDP(t) = ⅛GDP(t-2) + ¼GDP(t-1) + ¼GDP(t) + ¼GDP(t+1) + ⅛GDP(t+2)

To do this fancy maneuvering type the following:

*k=c(.5,1,1,1,.5)*

*k=k/sum(k)*

*fGDP=filter(GDP,sides=2,k)*

*plot(GDP)*

*lines(fGDP,col="red")*

*lines(lowess(GDP),col="blue",lty="dashed")*

that was beautiful right?

Now to test the normality via plot type in:

*dlGDP=diff(log(GDP))*

*plot(dlGDP)*

To do a formal test for normality type in:

*shapiro.test(dlGDP)*

This is called the Shapiro-Wilk normality test

*data: dlGDP*

*W = 0.9642, p-value = 5.015e-06*

the closer the W is to one the better and with an extremely small p-value we can reject the null hypothesis that the series is not normal and accept the alternative that it is!

Keep dancin' ladies and gents we have more on the way!

Steven J.

To

**leave a comment**for the author, please follow the link and comment on his blog:**The Dancing Economist**.R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...