Re: [R] moving average method for time series objects

2004-09-24 Thread Kjetil Brinchmann Halvorsen
Schwarz,Paul wrote:
Dear R-Help readers,
I suspect that this question must be a FAQ, but my investigation of the archives has 
not been very revealing.  Is there an R function for calculating moving averages of 
time series objects?
 

library(gregmisc)
?running
test - ts(rnorm(100))
test2 - running(test, fun=median, width=10)
length(test2)
[1] 91
you want fun=mean
Kjetil
--
Kjetil Halvorsen.
Peace is the most effective weapon of mass construction.
  --  Mahdi Elmandjra
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] moving average method for time series objects

2004-09-24 Thread Brahm, David
Paul Schwarz [EMAIL PROTECTED] wrote:
 Is there an R function for calculating moving averages of time series
objects?

Others have replied, but here's the simple answer for a trailing 5-day
moving average, no non-standard packages needed:
R x - 1:20
R filter(x, rep(1/5,5), sides=1)

-- David Brahm ([EMAIL PROTECTED])

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] moving average method for time series objects

2004-09-24 Thread Martin Maechler
 Kjetil == Kjetil Brinchmann Halvorsen [EMAIL PROTECTED]
 on Fri, 24 Sep 2004 08:34:19 -0400 writes:

Kjetil Schwarz,Paul wrote:
 Dear R-Help readers,
 
 I suspect that this question must be a FAQ, but my
 investigation of the archives has not been very
 revealing.  Is there an R function for calculating moving
 averages of time series objects?
 
 
 
Kjetil  library(gregmisc) ?running test - ts(rnorm(100))

Kjetil  test2 - running(test, fun=median, width=10)
Kjetil length(test2) [1] 91

Kjetil you want fun=mean

Note that really for 
  - running mean, you should use  filter()
  - running median, you use   runmed()

Greg's running() function is probably appropriate for anything
else *but* these two cases...

Martin Maechler

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] moving average method for time series objects

2004-09-23 Thread Schwarz,Paul
Dear R-Help readers,

I suspect that this question must be a FAQ, but my investigation of the archives has 
not been very revealing.  Is there an R function for calculating moving averages of 
time series objects?

Thank you for your time and patience.

-Paul

Paul Schwarz, Ph.D.
Associate Director of Methodology
Gartner
Vendor Marketing Solutions, Custom Research
+1 503 241 8036 x186

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] moving average method for time series objects

2004-09-23 Thread Gabor Grothendieck
Schwarz,Paul Paul.Schwarz at gartner.com writes:

: 
: Dear R-Help readers,
: 
: I suspect that this question must be a FAQ, but my investigation of the 
archives has not been very revealing. 
: Is there an R function for calculating moving averages of time series 
objects?
: 
: Thank you for your time and patience.
: 
: -Paul

Check out:

https://stat.ethz.ch/pipermail/r-sig-finance/2004q3/000104.html

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html