1

I have a time series over 10 years with no seasonal changes (only one value per year) and I try to detect a trend. I dont really understand how to do so. I read that the moving average is used in this case

What I did so far:

CharFS <- read.csv("./DataInvestigation/TEST.csv", header=TRUE, sep=";")
ma.1 <- rep(1/5,5)
ma.2 <- rep(1/25,25)  #How do I know what I should take?
ma.3 <- rep(1/81,81)
CharMA <- filter(CharFS, ma.1, sides=2)
plot(CharFS)
lines(ma.1, lty=2, col="blue")
lines(ma.2, lty=2, col="blue")
lines(ma.3, lty=2, col="blue")

However, no line shows up. I assume that ma.1,ma.2,ma.3 are wrong is but I dont know how to adjust it to my data, any ideas? Or is there a better way to get a trend when there are no seasons involved? Would it be possible with a normal plot and then add a line? This did not work either when I tried it though.

Thanks in advance!

horseoftheyear
  • 917
  • 11
  • 23
user3476078
  • 137
  • 1
  • 6

1 Answers1

1

It would be useful if you could show us the plot of your data with the moving averages lines. Or maybe provide some data. The reason they don't show up in the plot might have something to do with range of the data you use. What is the mean of CharFS? Try to plot CharFS and then add a horizontal line for the mean of the time series.

With regard to trends in time series data: basically when you have a trend in the data you will see that the data moves in a certain direction (e.g. GDP figures) and does not revolve around a certain mean (e.g. GDP growth). See the two examples that I have plotted below.

Since you're using R this might be a helpful resource using time series data: Little Book of R for Time Series

enter image description here enter image description here

horseoftheyear
  • 917
  • 11
  • 23
  • I read the manual and instead of applying a filter I used **CharSMA2 <- SMA(CharFSTime,n=2)** I get a new line, but I dont see a way on how to say how good this trend is predicted? – user3476078 Apr 16 '14 at 16:14
  • Without a plot or reproducible example it is kind of hard for me to say something sensible about it. – horseoftheyear Apr 16 '14 at 16:27
  • I am new to this site and apparently u can only upload pictures with enough reputation points.. – user3476078 Apr 16 '14 at 16:32
  • Forgot about that. You can include a link if I'm correct, so you can http://imgur.com/ to upload the plot and plot the link in a comment or update your question. I guess this is also obligatory reading material for new users: http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – horseoftheyear Apr 16 '14 at 16:34
  • The original time series can be found here http://imgur.com/R5hYDiD&0GUWUnz and the `SMA` trend here: http://imgur.com/R5hYDiD&0GUWUnz#1 Is there a way to say how good this trend fits? Or is it better to try making the `filter`option work? – user3476078 Apr 17 '14 at 07:02
  • As I said, 10 years with only 10 observations is rather short for a time series. From the graph it doesn't look like there is a trend in the data. So fitting the filter isn't really needed, although the SMA trend does capture the movement in the graph well. I would recommend running some formal tests for stationarity. See here for some guidance: http://stats.stackexchange.com/questions/27332/how-to-know-if-a-time-series-is-stationary-or-non-stationary – horseoftheyear Apr 17 '14 at 07:20