Re: [R] Moving average

2014-12-31 Thread Achim Zeileis
you !! Rolf *From:* jim holtman [mailto:jholt...@gmail.com] *Sent:* Sunday, December 28, 2014 4:45 PM *To:* Rolf Edberg *Cc:* R mailing list *Subject:* Re: [R] Moving average could not read the data you posted; try 'dput' next time. If it is just a 2 day moving average, try the 'filter

Re: [R] Moving average

2014-12-30 Thread jim holtman
] *Sent:* Sunday, December 28, 2014 4:45 PM *To:* Rolf Edberg *Cc:* R mailing list *Subject:* Re: [R] Moving average could not read the data you posted; try 'dput' next time. If it is just a 2 day moving average, try the 'filter' function: x - 1:20 x [1] 1 2 3 4 5 6 7 8 9

[R] Moving average

2014-12-28 Thread Rolf Edberg
How do I add a new column with 2-days moving average (from r-adamant(https://github.com/TotallyBullshit/radamant)) on IBM prices in a csv-file (ibm.csv) and then save all in a new csv file(ibm2.csv)? Prices Date Open High Low Close Volume Adj Close* Dec 26, 2014 162.27

Re: [R] Moving average

2014-12-28 Thread jim holtman
could not read the data you posted; try 'dput' next time. If it is just a 2 day moving average, try the 'filter' function: x - 1:20 x [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 filter(x, c(.5,.5)) Time Series: Start = 1 End = 20 Frequency = 1 [1] 1.5 2.5 3.5 4.5

Re: [R] Moving Average Non Uniform Vectors

2014-03-28 Thread Luca Cerone
Thanks Jim, this partially helps (I wasn't aware of the functions you used, which are good to know). I have two main doubts about your solution though. First of all, in my application x is large ~25 elements and I have to repeat this for ~1000 different y vectors; moreover the range of x is

Re: [R] Moving Average Non Uniform Vectors

2014-03-28 Thread jim holtman
If you don't need a 'running average', there are other 'smoothers' you can look at. Try 'supsmu': set.seed(1) x = c(0,1, 3,3.4, 5, 10, 11.23) y = x**2 + rnorm(length(x)) rbind(x, y) [,1] [,2] [,3] [,4] [,5] [,6] [,7] x 0.000 1.00 3.00 3.4

[R] Moving Average Non Uniform Vectors

2014-03-27 Thread Luca Cerone
Dear all, I have a vector x and a vector y = f(x). e.g. x = c(0,1, 3,3.4, 5, 10, 11.23) y = x**2 + rnorm(length(x)) I would like to apply a moving average to y, knowing that the x values are not uniformly spaced. How can I do this in R? What alternatives I have to filter out the noise from Y??

Re: [R] Moving Average Non Uniform Vectors

2014-03-27 Thread jim holtman
Here is one way. I took your data and applied the 'approx' function to get evenly spaced values and then 'filter' to create a moving average of a window of size 5. set.seed(1) x = c(0,1, 3,3.4, 5, 10, 11.23) y = x**2 + rnorm(length(x)) rbind(x, y) # create 'even' spacing using the 'approx'

Re: [R] Moving average with loess

2012-03-09 Thread Downey, Patrick
: Thursday, March 08, 2012 6:43 PM To: r-help@r-project.org Subject: [R] Moving average with loess Hello All, I just have a very simple question. I recently switching from Matlab to R, so cannot figure out some of the easy tasks in the new environment. Is there any weighted local regression smoothing

[R] Moving average with loess

2012-03-08 Thread Faryabi, Robert (NIH/NCI) [F]
Hello All, I just have a very simple question. I recently switching from Matlab to R, so cannot figure out some of the easy tasks in the new environment. Is there any weighted local regression smoothing in R? Basically, I want to have weighted moving average. All the functions that I know of

[R] moving average TTR

2011-10-13 Thread Laura
Hello, I used the TTR package in R to calculate moving averages. I have a monthly time series and I would like to calculate the moving average over 10 years with an offset of 1 year. It should be something like sma.365 - SMA(data, n=120) Does anyone know how to include in offset? Thanks a

Re: [R] moving average TTR

2011-10-13 Thread R. Michael Weylandt
I believe the lag() function can be used to rig this up. Something like sma.365 - SMA(lag(data, 12), n=120) # Untested, but seems right Michael On Thu, Oct 13, 2011 at 6:31 AM, Laura janna...@web.de wrote: Hello, I used the TTR package in R to calculate moving averages. I have a monthly

[R] Moving average in a data table

2011-06-25 Thread Roman Naumenko
Hi, I'm trying to figure out common approach on calculating MA on a dataset that contains column time. After digging around, I believe functions rollmean and rollaply should be used. However I don't quite understand the requirements for the underlying data. Should it be zoo object type?

Re: [R] Moving average in a data table

2011-06-25 Thread Gabor Grothendieck
On Sat, Jun 25, 2011 at 3:15 PM, Roman Naumenko ro...@naumenko.ca wrote: Hi, I'm trying to figure out common approach on calculating MA on a dataset that contains column time. After digging around, I believe functions rollmean and rollaply should be used. However I don't quite understand

Re: [R] moving average with gaps in time series

2010-12-20 Thread Josef . Kardos
@r-project.org Subject Re: [R] moving average with gaps in time series Hi Josef, is there any particular reason why you want to use your own function? Have a look at the stats functions or special timeseries functions for R. I am sure you will find something that calculates an ordinary

[R] moving average with gaps in time series

2010-12-16 Thread Josef . Kardos
I have a time series with interval of 2.5 minutes, or 24 observations per hour. I am trying to find a 1 hr moving average, looking backward, so that moving average at n = mean(n-23 : n) The time series has about 1.5 million rows, with occasional gaps due to poor data quality. I only want to

[R] moving average with gaps in time series

2010-12-16 Thread Carl Witthoft
I'm not completely sure what your test setup does, but wouldn't it be simpler to take a moving average at every point, but set the window dynamically to be over the previous hour? In pseudocode, for the j-th sample: meanval[j] - mean(Value[ DateTime[(DateTime-DateTime[j])0

Re: [R] moving average with gaps in time series

2010-12-16 Thread Jannis
Hi Josef, is there any particular reason why you want to use your own function? Have a look at the stats functions or special timeseries functions for R. I am sure you will find something that calculates an ordinary moving average (and a bunch of fancier stuff). 'filter' (stats) for example

[R] Moving average in R

2010-08-15 Thread suman dhara
Hi, I want to fit moving average trend in R. In google, I see that it is in the package 'TTR'. But, I can't install this package. I have used the following code: install.packages(TTR) But, it says there is no package called 'TTR'. Can you help me? Regards, Suman Dhara [[alternative

Re: [R] Moving average in R

2010-08-15 Thread Tim Gruene
Dear Suman, you can download the TTR package through the Packages-link on http://cran.r-project.org/ and install it with R CMD INSTALL TTR_0.20-2.tar.gz (or the appropriate name if you use the MacOS X or Windows binary). Tim On Sun, Aug 15, 2010 at 02:59:18PM +0530, suman dhara wrote:

Re: [R] moving average on irregular time series

2010-06-04 Thread Gustaf Rydevik
Dear William and Gabor, Both solutions worked, and my problem is now solved. Many thanks to both of you! regards, Gustaf On Thu, Jun 3, 2010 at 10:23 AM, Gustaf Rydevik gustaf.ryde...@gmail.com wrote: Hi all, I wonder if there is any way to calculate a moving average on an irregular

Re: [R] moving average on irregular time series

2010-06-04 Thread Gabor Grothendieck
On Thu, Jun 3, 2010 at 8:04 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Replace the non-events with NA and then use na.locf from the zoo package to move the last event date up to give lastEvent. Then simply select those rows whose lastEvent date is at least 14 days ago or if the row

[R] moving average on irregular time series

2010-06-03 Thread Gustaf Rydevik
Hi all, I wonder if there is any way to calculate a moving average on an irregular time series, or use the rollapply function in zoo? I have a set of dates where I want to check if there has been an event 14 days prior to each time point in order to mark these timepoints for removal, and can't

Re: [R] moving average on irregular time series

2010-06-03 Thread William Dunlap
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Gustaf Rydevik Sent: Thursday, June 03, 2010 7:24 AM To: r-help@r-project.org Subject: [R] moving average on irregular time series Hi all, I wonder if there is any way

Re: [R] moving average on irregular time series

2010-06-03 Thread Gabor Grothendieck
Replace the non-events with NA and then use na.locf from the zoo package to move the last event date up to give lastEvent. Then simply select those rows whose lastEvent date is at least 14 days ago or if the row itself is an Event: library(zoo) # na.locf lastEvent - with(exData,

[R] Moving Average Model

2010-03-09 Thread testuser
Using the forecast package in R, auto.arima returns a model of type (0,0,3) with coefficients. To forecast the value at any point of time t, I can use the coefficients along with the white noise values e(t). How can we get the value for white noise? -- View this message in context:

Re: [R] Moving Average Model

2010-03-09 Thread David Winsemius
On Mar 9, 2010, at 1:54 PM, testuser wrote: Using the forecast package in R, auto.arima returns a model of type (0,0,3) with coefficients. To forecast the value at any point of time t, I can use the coefficients along with the white noise values e(t). How can we get the value for white

Re: [R] Moving Average Model

2010-03-09 Thread David Winsemius
On Mar 9, 2010, at 2:42 PM, David Winsemius wrote: On Mar 9, 2010, at 1:54 PM, testuser wrote: Using the forecast package in R, auto.arima returns a model of type (0,0,3) with coefficients. To forecast the value at any point of time t, I can use the coefficients along with the white

[R] Moving Average on Defined Intervals

2009-07-30 Thread Hadassa Brunschwig
Hi all I have been looking (in the help archives) for a function which does a moving average. Nothing new, I know. But I am looking for a function which is very flexible: The user should be able to input a vector of breaks which define the bins (and not just the number of observations in a bin).

[R] Moving Average on Defined Intervals

2009-07-30 Thread Hadassa Brunschwig
Hi all I have been looking (in the help archives) for a function which does a moving average. Nothing new, I know. But I am looking for a function which is very flexible: The user should be able to input a vector of breaks which define the bins (and not just the number of observations in a bin).

Re: [R] Moving Average on Defined Intervals

2009-07-30 Thread Alain Zuur
Hadassa Brunschwig-2 wrote: Hi all I have been looking (in the help archives) for a function which does a moving average. Nothing new, I know. But I am looking for a function which is very flexible: The user should be able to input a vector of breaks which define the bins (and not just

Re: [R] Moving Average on Defined Intervals

2009-07-30 Thread Gabor Grothendieck
See ?cut and ?tapply for your first problem. Those together with ?rollappy in the zoo package can likely handle your second problem. In the future please read the last line to every message on r-help before posting. On Thu, Jul 30, 2009 at 6:15 AM, Hadassa

Re: [R] Moving Average

2009-02-26 Thread Gabor Grothendieck
See rollapply in zoo or filter or embed in the core of R. On Thu, Feb 26, 2009 at 7:07 AM, mau...@alice.it wrote: I am looking for some help at removing low-frequency components from a signal, through Moving Average on a sliding window. I understand thiis is a smoothing procedure that I

Re: [R] Moving Average

2009-02-26 Thread David Winsemius
I saw Gabor's reply but have a clarification to request. You say you want to remove low frequency components but then you request smoothing functions. The term smoothing implies removal of high-frequency components of a series. If smoothing really is your goal then additional R resource

[R] R: Moving Average

2009-02-26 Thread mauede
. slightly more than 16 - maximum scale for the 3-rd detail level). Thank you so much, Maura -Messaggio originale- Da: David Winsemius [mailto:dwinsem...@comcast.net] Inviato: gio 26/02/2009 14.54 A: mau...@alice.it Cc: r-help@r-project.org Oggetto: Re: [R] Moving Average I saw

Re: [R] Moving Average

2009-02-26 Thread Ted Harding
On 26-Feb-09 13:54:51, David Winsemius wrote: I saw Gabor's reply but have a clarification to request. You say you want to remove low frequency components but then you request smoothing functions. The term smoothing implies removal of high-frequency components of a series. If you produce

Re: [R] Moving Average

2009-02-26 Thread stephen sefick
I wrote a little code using Fourier filtering if you would like to take a look at this: library(StreamMetabolism) library(mFilter) x - read.production(file.choose()) #contiguous.zoo(data.frame(x[,RM202DO.Conc], coredata(x[,RM202DO.Conc]))) #contiguous.zoo(data.frame(x[,RM61DO.Conc],

Re: [R] Moving Average

2009-02-26 Thread David Winsemius
On Feb 26, 2009, at 9:54 AM, (Ted Harding) wrote: On 26-Feb-09 13:54:51, David Winsemius wrote: I saw Gabor's reply but have a clarification to request. You say you want to remove low frequency components but then you request smoothing functions. The term smoothing implies removal of

Re: [R] Moving Average

2009-02-26 Thread Carl Witthoft
Along similar lines, I wrote a toy script to apply any function you want in a windowed sense. Be warned that it's about 1 times slower than loess(). # my own boxcar tool, just because. # use bfunc to specify what function to apply to the windowed # region. # basically must be valid

[R] Moving Average Question

2008-08-14 Thread William Pepe
Dear all. I have data that looks like this: Biller Cycle Jan Feb Mar Apr May JuneAB 1 100 150 150 200 300 450JL 2 650 600 750 700 850 800JL3 700 740 680 690 700 580IR1 455 400 405 410 505 550IR4 600 650 700 750 650 680IR5 100 150 120

Re: [R] Moving Average Question

2008-08-14 Thread stephen sefick
look at zoo and roll mean On Thu, Aug 14, 2008 at 3:52 PM, William Pepe [EMAIL PROTECTED] wrote: Dear all. I have data that looks like this: Biller Cycle Jan Feb Mar Apr May JuneAB 1 100 150 150 200 300 450JL 2 650 600 750 700 850 800JL3 700 740 680 690 700 580IR

[R] moving average and NA values

2007-12-10 Thread Cornelis de Gier
The S-plus function moving.ave(data, span = 2) calculates the moving average, but it does not have an argument to tell it how to deal with NA values, so it will return NA for all averages as shown below. Is there an R or S moving average function which is able to omit some NA values in the

Re: [R] moving average and NA values

2007-12-10 Thread Gabor Grothendieck
rollapply in the zoo package can do that: library(zoo) x - zoo(1:10) x[5] - NA rollapply(x, 3, mean, na.rm = TRUE) 2 3 4 5 6 7 8 9 2.0 3.0 3.5 5.0 6.5 7.0 8.0 9.0 xm - rollapply(x, 3, mean, na.rm = TRUE) xm 2 3 4 5 6 7 8 9 2.0 3.0 3.5 5.0 6.5 7.0 8.0 9.0