title: Weighted moving average for time series in R
body: <p>I'm quite new in time series and I'm wondering, is there any similar function as <code>sma()</code> from <code>smooth</code> package to fit weighted moving average (WMA) for my time serie?
  I would like to fit a WMA model with weights</p>
  
  <pre><code>weights &lt;- (1/35)*c(-3, 12, 17, 12, -3)
  </code></pre>
  
  <p>I'm able to calculate the values of WMA with <code>filter()</code> function but I would love to get output similar to <code>sma()</code> function (including e.g. residuals, BIC, ...)</p>
  
  <pre><code>Income &lt;- c(44649, 47507, 49430, 51128, 54453, 58712, 60533, 
              63091, 63563, 62857, 62481, 63685, 65596)
  Year &lt;- c(2000, 2001, 2002, 2003, 2004, 2005, 2006, 
            2007, 2008, 2009, 2010, 2011, 2012)
  df &lt;- data.frame(Year, Income)
  
  library(smooth)
  # simple moving average model
  (sma5_fit &lt;- sma(df$Income, order = 5))
  
  # weighted moving average
  wma5 &lt;- filter(df$Income, filter = (1/35)*c(-3, 12, 17, 12, -3), sides = 2)
  </code></pre>
  
  <p>Any suggestions welcomed!</p>
  
  <p><strong>EDIT:</strong>
  It would be also nice to calculate first 2 and last 2 values of weighted moving average. Now, I have to calculate them by hand with following code (weights come from Kendall's Time Series book):</p>
  
  <pre><code>n &lt;- length(Income)
  wma5[n-1] &lt;- sum(1/35 * c(2, -8, 12, 27, 2) * c(Income[(n-4):(n)]))
  wma5[n]   &lt;- sum(1/70 * c(-1, 4, -6, 4, 69) * c(Income[(n-4):(n)]))
  wma5[2]   &lt;- sum(1/35 * c(2, 27, 12, -8, 2) * c(Income[1:5]))
  wma5[1]   &lt;- sum(1/70 * c(69, 4, -6, 4, -1) * c(Income[1:5]))
  </code></pre>