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
]
*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
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
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
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
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
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??
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'
: 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
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
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
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
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?
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
@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
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
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
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
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
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:
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
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
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
-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
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,
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:
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
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
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).
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).
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
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
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
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
. 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
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
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],
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
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
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
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
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
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
43 matches
Mail list logo