For your choice of \(m\), \[ M_t = \frac{1}{2q+1} \sum_{i=-q}^q X_{t+i} \]
This will filter the noise out, exposing overall trend.
It could also be \[ M_t = \frac{1}{q} \sum_{i=0}^q X_{t-i} \]
set.seed(235) # set seed for RS generation (you don't need to do this)
X <- abs(round(rnorm(100)*10, 0))
library(forecast) # install.packages("forecast")
M <- ma(X, 3) # This order=3 goes from t-1 to t+1
head(cbind(X,M))
## Time Series:
## Start = 1
## End = 6
## Frequency = 1
## X M
## 1 21 NA
## 2 3 10.333333
## 3 7 9.333333
## 4 18 8.666667
## 5 1 11.000000
## 6 14 10.000000
For your choice of \(\alpha\), \((0<\alpha<1)\), let \(S_0=X_0\) and \[ S_t = \alpha X_t + (1-\alpha) S_{t-1} \hspace{10mm} \mbox{ for } t>0. \]
This can be a one step forecast: \[ \hat X_{t+1} = S_t \]
set.seed(235) # set seed for RS generation (you don't need to do this)
X <- abs(round(rnorm(100)*10, 0))
library(forecast) # install.packages("forecast")
S <- ses(X, h=10, alpha=0.2, initial='simple')
head(cbind(X, S$fitted))
## Time Series:
## Start = 1
## End = 6
## Frequency = 1
## X S$fitted
## 1 21 21.0000
## 2 3 21.0000
## 3 7 17.4000
## 4 18 15.3200
## 5 1 15.8560
## 6 14 12.8848