Re: [R] Moving Average

2006-07-27 Thread Juan Antonio Breña Moral

Hi,

To make moving average, I advise you, to read a document in my web to make
forecasting,
http://www.juanantonio.info/p_research/statistics/r/forecasting.htm
http://www.juanantonio.info/p_research/statistics/r/forecasting.htm 

This scripts use the library forecast and the function pegels.
http://www-personal.buseco.monash.edu.au/~hyndman/Rlibrary/forecast/
http://www-personal.buseco.monash.edu.au/~hyndman/Rlibrary/forecast/ 

If you see the web, the author of the library has updated it, then the
function to make the prediction is ets.

http://www-personal.buseco.monash.edu.au/~hyndman/Rlibrary/forecast/forecast/ets.html
 
http://www-personal.buseco.monash.edu.au/~hyndman/Rlibrary/forecast/forecast/ets.html
 

Best Regards.

Juan Antonio Breña Moral
http://www.juanantonio.info http://www.juanantonio.info 
-- 
View this message in context: 
http://www.nabble.com/Moving-Average-tf2004135.html#a5518837
Sent from the R help forum at Nabble.com.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Moving Average

2006-07-26 Thread ricardosilva
Dear R-Users,

How can I compute simple moving averages from a time series in R?
Note that I do not want to estimate a MA model, just compute the MA's 
given a lenght (as excel does).

Thanks

Ricardo Gonçalves Silva, M. Sc.
Apoio aos Processos de Modelagem Matemática
Econometria  Inadimplência
Serasa S.A.
(11) - 6847-8889
[EMAIL PROTECTED]

**
As informações contidas nesta mensagem e no(s) arquivo(s) anexo(s) são 
endereçadas exclusivamente à(s) pessoa(s) e/ou instituição(ões) acima 
indicada(s), podendo conter dados confidenciais, os quais não podem, sob 
qualquer forma ou pretexto, ser utilizados, divulgados, alterados, 
impressos ou copiados, total ou parcialmente, por pessoas não autorizadas. 
Caso não seja o destinatário, favor providenciar sua exclusão e notificar 
o remetente imediatamente.  O uso impróprio será tratado conforme as 
normas da empresa e da legislação em vigor.
Esta mensagem expressa o posicionamento pessoal do subscritor e não 
reflete necessariamente a opinião da Serasa.
**
[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Moving Average

2006-07-26 Thread Gabor Grothendieck
See

?filter - simple and exponential are special cases
?runmean - in package caTools (the fastest)
?rollmean - in zoo package
?embed - can write your own using embed as basis
?sma - in package fSeries, also see ewma in same package

Probably other functions in other packages too.

On 7/26/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Dear R-Users,

 How can I compute simple moving averages from a time series in R?
 Note that I do not want to estimate a MA model, just compute the MA's
 given a lenght (as excel does).

 Thanks
 
 Ricardo Gonçalves Silva, M. Sc.
 Apoio aos Processos de Modelagem Matemática
 Econometria  Inadimplência
 Serasa S.A.
 (11) - 6847-8889
 [EMAIL PROTECTED]

 **
 As informações contidas nesta mensagem e no(s) arquivo(s) anexo(s) são
 endereçadas exclusivamente à(s) pessoa(s) e/ou instituição(ões) acima
 indicada(s), podendo conter dados confidenciais, os quais não podem, sob
 qualquer forma ou pretexto, ser utilizados, divulgados, alterados,
 impressos ou copiados, total ou parcialmente, por pessoas não autorizadas.
 Caso não seja o destinatário, favor providenciar sua exclusão e notificar
 o remetente imediatamente.  O uso impróprio será tratado conforme as
 normas da empresa e da legislação em vigor.
 Esta mensagem expressa o posicionamento pessoal do subscritor e não
 reflete necessariamente a opinião da Serasa.
 **
[[alternative HTML version deleted]]



 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Moving Average

2006-07-26 Thread markleeds
From: [EMAIL PROTECTED]
Date: 2006/07/26 Wed AM 09:29:27 CDT
To: r-help@stat.math.ethz.ch
Subject: [R] Moving Average

i think it was mave() in Splus. probably something similar
in R. do RSiteSearch(moving average)at an R prompt.


Dear R-Users,

How can I compute simple moving averages from a time series in R?
Note that I do not want to estimate a MA model, just compute the MA's 
given a lenght (as excel does).

Thanks

Ricardo Gonçalves Silva, M. Sc.
Apoio aos Processos de Modelagem Matemática
Econometria  Inadimplência
Serasa S.A.
(11) - 6847-8889
[EMAIL PROTECTED]

**
As informações contidas nesta mensagem e no(s) arquivo(s) anexo(s) são 
endereçadas exclusivamente à(s) pessoa(s) e/ou instituição(ões) acima 
indicada(s), podendo conter dados confidenciais, os quais não podem, sob 
qualquer forma ou pretexto, ser utilizados, divulgados, alterados, 
impressos ou copiados, total ou parcialmente, por pessoas não autorizadas. 
Caso não seja o destinatário, favor providenciar sua exclusão e notificar 
o remetente imediatamente.  O uso impróprio será tratado conforme as 
normas da empresa e da legislação em vigor.
Esta mensagem expressa o posicionamento pessoal do subscritor e não 
reflete necessariamente a opinião da Serasa.
**
   [[alternative HTML version deleted]]



__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Moving average

2005-06-16 Thread Bernard L. Dillard
Good morning all!

I am attempting to superimpose a moving-average smoother onto a graph of
daily plots.  These plots (in table[,2] below) span about 350 days and
looks very noisy.  I'd like for this smoother to plot the average of each
group of 7 consecutive days (weekly) and show a line which joins these
series of averages.  Given the definition of MA, the first and last points
will generally overlap in the average calculation.

It's probably a one-liner, but I still am having some problems with the
syntax.  The only part I have correct is the lines statement to ensure
it overlays my original graph.

Here's the code I have thus far:

y - table[,2]
plot(y,type=l,lty=3)
lines( ..)  {moving average code here to be placed here}

Any time series gurus out there?  Be gentle.  I'm an R beginner.

Thanx!

Bernard

__
R-help@stat.math.ethz.ch 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

2005-06-16 Thread Sean Davis

On Jun 16, 2005, at 8:04 AM, Bernard L. Dillard wrote:

 Good morning all!

 I am attempting to superimpose a moving-average smoother onto a graph  
 of
 daily plots.  These plots (in table[,2] below) span about 350 days and
 looks very noisy.  I'd like for this smoother to plot the average of  
 each
 group of 7 consecutive days (weekly) and show a line which joins these
 series of averages.  Given the definition of MA, the first and last  
 points
 will generally overlap in the average calculation.

 It's probably a one-liner, but I still am having some problems with the
 syntax.  The only part I have correct is the lines statement to  
 ensure
 it overlays my original graph.

 Here's the code I have thus far:

 y - table[,2]
 plot(y,type=l,lty=3)
 lines( ..)  {moving average code here to be placed here}

 Any time series gurus out there?  Be gentle.  I'm an R beginner.

R site search is your friend:

http://finzi.psych.upenn.edu/cgi-bin/namazu.cgi? 
query=moving+windowmax=20result=normalsort=scoreidxname=functionsid 
xname=docsidxname=Rhelp02a

Sean

__
R-help@stat.math.ethz.ch 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

2005-06-16 Thread ronggui
are you looking the function decompose?
see ?decompose

On Thu, 16 Jun 2005 08:04:18 -0400 (EDT)
Bernard L. Dillard [EMAIL PROTECTED] wrote:

 Good morning all!
 
 I am attempting to superimpose a moving-average smoother onto a graph of
 daily plots.  These plots (in table[,2] below) span about 350 days and
 looks very noisy.  I'd like for this smoother to plot the average of each
 group of 7 consecutive days (weekly) and show a line which joins these
 series of averages.  Given the definition of MA, the first and last points
 will generally overlap in the average calculation.
 
 It's probably a one-liner, but I still am having some problems with the
 syntax.  The only part I have correct is the lines statement to ensure
 it overlays my original graph.
 
 Here's the code I have thus far:
 
 y - table[,2]
 plot(y,type=l,lty=3)
 lines( ..)  {moving average code here to be placed here}
 
 Any time series gurus out there?  Be gentle.  I'm an R beginner.
 
 Thanx!
 
 Bernard
 
 __
 R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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

2005-06-16 Thread Achim Zeileis
On Thu, 16 Jun 2005 08:04:18 -0400 (EDT) Bernard L. Dillard wrote:

 Good morning all!
 
 I am attempting to superimpose a moving-average smoother onto a graph
 of daily plots.  These plots (in table[,2] below) span about 350 days
 and looks very noisy.  I'd like for this smoother to plot the average
 of each group of 7 consecutive days (weekly) and show a line which
 joins these series of averages.  Given the definition of MA, the first
 and last points will generally overlap in the average calculation.
 
 It's probably a one-liner, but I still am having some problems with
 the syntax.  The only part I have correct is the lines statement to
 ensure it overlays my original graph.
 
 Here's the code I have thus far:
 
 y - table[,2]
 plot(y,type=l,lty=3)
 lines( ..)  {moving average code here to be placed here}

With the zoo package you can do the following:

library(zoo)
## create data
x - rnorm(365)
## transform to regular zoo series with Date index
x - zooreg(x, start = as.Date(2004-01-01))
plot(x)

## add rolling/running/moving average with window size 7
lines(rollmean(x, 7), col = 2, lwd = 2)

## if you don't want the rolling mean but rather a weekly
## time series of means you can do
nextfri - function(x) 7 * ceiling(as.numeric(x - 1)/7) + as.Date(1)
xw - aggregate(x, nextfri, mean)
## nextfri is a function which computes for a certain Date
## the next friday. xw is then the weekly series.
lines(xw, col = 4)

Note, that the differnce between is rolling mean and the aggregated
series is due to different alignments. This can be changed by changing
the `align' argument in rollmean() or the nextfri() function in the
aggregate call.

hth,
Z


 Any time series gurus out there?  Be gentle.  I'm an R beginner.
 
 Thanx!
 
 Bernard
 
 __
 R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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 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


RE: [R] Moving average

2003-03-07 Thread Morten Sickel
Wayne Jones wrote:
Does anyone know if R has the functionality to calculate a simple moving
average. I cant seem to find it in the help menu. 

does filter() do what you need?

Morten

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Moving average

2003-03-07 Thread Morten Sickel
Sorry, a neccesary addition: filter in library ts.

Morten

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Moving average

2003-03-07 Thread Warnes, Gregory R
Or look at the 'running' function in the gregmisc package.

-Greg

 -Original Message-
 From: Huntsinger, Reid [mailto:[EMAIL PROTECTED]
 Sent: Friday, March 07, 2003 10:13 AM
 To: 'Wayne Jones'; [EMAIL PROTECTED]
 Subject: RE: [R] Moving average
 
 
 Try filter in package ts.
 
 Reid Huntsinger
 
 -Original Message-
 From: Wayne Jones [mailto:[EMAIL PROTECTED] 
 Sent: Friday, March 07, 2003 9:37 AM
 To: [EMAIL PROTECTED]
 Subject: [R] Moving average
 
 
 Hi, 
 
 Does anyone know if R has the functionality to calculate a 
 simple moving
 average. I cant seem 
 to find it in the help menu. 
 
 thanks, 
 
 Wayne
 
 
 Dr Wayne R. Jones
 Statistician / Research Analyst
 KSS Group plc
 St James's Buildings
 79 Oxford Street
 Manchester M1 6SS
 Tel: +44(0)161 609 4084
 Mob: +44(0)7810 523 713
 
 
 
 KSS Ltd
 A division of Knowledge Support Systems Group plc
 Seventh Floor  St James's Buildings  79 Oxford Street  
 Manchester  M1 6SS
 England
 Company Registration Number 2800886 (Limited) 3449594 (plc)
 Tel: +44 (0) 161 228 0040 Fax: +44 (0) 161 236 6305
 mailto:[EMAIL PROTECTED]  http://www.kssg.com
 
 
 The information in this Internet email is confidential and 
 may b... [[dropped]]
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 


LEGAL NOTICE\ Unless expressly stated otherwise, this message is... [[dropped]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help