Reputation: 339
I want to know how to make 'seasonal' in stl function.
I guess 'trend' is diff time series. and how to make seasonal??
in R 'stl' description is
which.cycle <- cycle(x)
z$seasonal <- tapply(z$seasonal, which.cycle, mean)[which.cycle]
and R documentation
fdrfourier Calculation of the false discovery rates (FDR) for periodic expression
backgroundData Generation of background expression set
ar1analysis Performs AR1 fitting
fourierscore Calculation of the Fourier score
AR and Fourier transform ??
Upvotes: 0
Views: 534
Reputation: 1016
A time series cannot be made seasonal, strictly speaking. I suspect you mean extracting the seasonality pattern using the stl() function in R.
Let's consider an example of a time series measuring the maximum recorded air temperature in Dublin, Ireland from 1941 to 2019.
Here is a graph of the original time series:
weatherarima <- ts(mydata$maxtp, start = c(1941,11), frequency = 12)
plot(weatherarima,type="l",ylab="Temperature in Celsius")
title("Maximum Air Temperature - Dublin")
The seasonal, trend, and random components can be extracted with stl() as follows:
stl_weather = stl(weatherarima, "periodic")
seasonal_stl_weather <- stl_weather$time.series[,1]
trend_stl_weather <- stl_weather$time.series[,2]
random_stl_weather <- stl_weather$time.series[,3]
plot(as.ts(seasonal_stl_weather))
title("Seasonal")
plot(trend_stl_weather)
title("Trend")
plot(random_stl_weather)
title("Random")
Seasonal
Trend
Random
As can be observed, there is clear seasonality in the weather data - given the change in temperature across seasons - but this was merely extracted from the series by using stl() - not created as such.
You might find the following to be informative: Extracting Seasonality and Trend from Data: Decomposition Using R
Upvotes: 1