user3476078
user3476078

Reputation: 137

Time Series Trend

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!

Upvotes: 1

Views: 1079

Answers (1)

horseoftheyear
horseoftheyear

Reputation: 915

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

Upvotes: 1

Related Questions