Displaying 20 results from an estimated 4000 matches similar to: "apply a function to a rolling subset of a vector"
2009 Nov 27
2
How to compute Rolling analysis of Standard Deviation using ZOO package?
Hello:
I want to get a rolling estimation of the stdev of my data.
Searching the document, I found the function "rollapply" in the zoo package.
For example, my series is "c", and i want get a period of 10 days,
so i write the command below:
roll.sd = rollapply( c, 10, sd, na.pad = TRUE, align = 'right' )
but there is an error in it ,and the computing cannot be
2005 Apr 02
1
Survey of "moving window" statistical functions - still looking f or fast mad function
Hi,
First, let me thank Jaroslaw for making this survey. I find it quite
illuminating.
Now the questions:
* the #1 solution below (based on cumsum) is numerically unstable.
Specifically if you do the runmean on a positive vector you can easily
get negative numbers due to rounding errors. Does anyone see a
modification which is free of this deficiency?
* is it possible to optimize the
2003 Nov 05
2
Multiple comparisons with a glm
I've never seen anything written about multiple comparisons,
as in the multcomp package or with TukeyHSD, but using a glm.
Do such procedures exist? Are they sensible?
Are there any packages in R that implement such comparisons?
Thank you.
--
Ken Knoblauch
Inserm U371
Cerveau et Vision
18 avenue du Doyen Lepine
69675 Bron cedex
France
Tel: +33 (0)4 72 91 34 77
Fax: +33 (0)4 72 91 34 61
2004 May 17
0
adding a line to a single panel of a lattice plot
I'm struggling to find a way to add a line (abline, lline or lmline) to
a single panel of a lattice plot. In one panel, there is an outlier
and I'd like to include a second lmline fit to the data without this
point. I've looked through nine pages of the archives on lattice
and it wasn't obvious (to me) what additional search keyword to add
to hone in on this, although I would
2004 Jun 15
1
AIC in glm.nb and glm(...family=negative.binomial(.))
Can anyone explain to me why the AIC values are so different when
using glm.nb and glm with a negative.binomial family, from the MASS
library? I'm using R 1.8.1 with Mac 0S 10.3.4.
>library(MASS)
> dfr <- data.frame(c=rnbinom(100,size=2,mu=rep(c(10,20,100,1000),rep(25,4))),
+ f=factor(rep(seq(1,4),rep(25,4))))
> AIC(nb1 <- glm.nb(c~f, data=dfr))
[1] 1047
>
2005 Apr 04
1
help with kolmogorov smirnov test
What does 'with ties in' mean?
with some identical elements (par ex., au moins une paire ex-equo)
HTH
____________________
Ken Knoblauch
Inserm U371, Cerveau et Vision
Department of Cognitive Neurosciences
18 avenue du Doyen Lepine
69675 Bron cedex
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: 06 84 10 64 10
http://www.lyon.inserm.fr/371/
2004 Dec 13
3
Moving standard deviation?
Is there a simple function in R to get a moving standard deviation
(i.e. for the last x samples)?
My goal is to plot bollinger bands around a moving average for price
data. I use kernel smoothing for the moving average.
cheers and thanks!
over and out
-- doktora
2005 Mar 09
3
problem using uniroot with integrate
Hi,
I'm trying to calculate the value of the variable, dp, below, in the
argument to the integral of dnorm(x-dp) * pnorm(x)^(m-1). This
corresponds to the estimate of the sensitivity of an observer in an
m-alternative forced choice experiment, given the probability of
a correct response, Pc, a Gaussian assumption for the noise and
no bias. The function that I wrote below gives me an error:
2007 Feb 06
0
convolve: request for "usual" behaviour + some improvements + some fixes
To add to the wish-list for "convolve":
For modeling processes that decay exponentially in time, e.g.,
fluorescence, it is desirable to have a function that convolves an
arbitrary vector with an exponential using an iterative method.
In the TIMP package (which won't be on CRAN till R 2.5.0 is official, but
is for now at www.nat.vu.nl/~kate/TIMP) we implemented this
special-purpose
2009 Mar 31
4
what is the preferred method to create a package local variable?
for the moment, I'm using:
.onAttach <- function(libname, pkgname) {
.bbg.db.conn <<- dbConnect(dbDriver("PostgreSQL"), user="blah","blah")
}
.onUnload <- function(libpath) {
dbDisconnect(.bbg.db.conn)
}
which results in a hidden global variable in the global environment.
I would prefer to make the assignment only in the package namespace.
1999 Nov 18
1
convolve bug?
I have been experimenting with convolve().
What I know about convolution I learned from engineering (they call this
stuff linear systems theory), not statistics, so maybe this is all just a
matter of different conventions. BUT I notice very weird things with
convolve().
1. First example, from the classic Bracewell The Fourier transform and its
applications, chap 3 (p.32 in 2nd edition):
{2 2 3 3
2012 Mar 15
4
replicating C example from the Extensions Manual problem
Dear R People:
Here is something that I am sure is very simple. I'm just trying to
re-create the C convolution example in the Extensions manual. Here is
the subroutine:
void convolve(double *a, int *na, double *b, int *nb, double *ab)
{
R_len_t i, j, nab = *na + *nb - 1;
for(i = 0; i < nab; i++)
ab[i] = 0.0;
for(i = 0; i < *na; i++)
for(j = 0; j < *nb; j++)
ab[i + j] += a[i] *
2011 Aug 11
1
.C and .Call: convolve example not working
Dear R users,
I want to call C code via the .C or .Call interface. This works fine
with integer values but using doubles the array received in C will be
set to zeros.
I have tried the convolve examples (Writing R extensions, chapter 5.2)
and still the resulting array consists of zeros.
My code (shortened for my purposes. Original did not work either):
2004 Oct 08
1
Survey of "moving window" statistical functions - still looking f or fast mad function
Hi,
Lately I run into a problem that my code R code is spending hours performing
simple moving window statistical operations. As a result I did searched
archives for alternative (faster) ways of performing: mean, max, median and
mad operation over moving window (size 81) on a vector with about 30K
points. And performed some timing for several ways that were suggested, and
few ways I come up
2005 Jul 20
2
Issues with convolve
We obtained some disturbing results from convolve() (inaccuracies and negative
probabilities). We'll try to make the context clear in as few lines as
possible...
Our function panjer() (code below) basically computes recursively the
probability mass function of a compound Poisson distribution. When the
Poisson parameter lambda is very large, the starting value of the recursive
scheme ---
2005 Oct 26
1
Borland C++ and [R] dyn.load() for windows
Hi,
I compiled a C program file on Borland C++ 5.5 compiler to get one dll output
(as instructed in the file readme.package).
The C program file is just the example on page 31 of "writing R extensions":
void convolve(double *a, int *na, double *b, int *nb, double *ab)
{
int i, j, nab = *na + *nb - 1;
for(i = 0; i < nab; i++)
ab[i] = 0.0;
for(i = 0; i < *na; i++)
for(j = 0; j
2007 Feb 02
1
Inaccuracy in ?convolve
Hi,
Man page for 'convolve' says:
conj: logical; if 'TRUE', take the complex _conjugate_ before
back-transforming (default, and used for usual convolution).
The complex conjugate of 'x', of 'y', of both?
In fact it seems that it takes the complex conjugate of 'y' only which
is OK but might be worth mentioning because (1) conj=TRUE is the
2003 Aug 13
1
Problems with addition in big POSIX dates
Have you noticed any problems with big dates (>=1/1/2040) in R?
Here is the bit of code that I'm having trouble with:
> test.date <- strptime("1/1/2040",format="%m/%d/%Y")
>
> unlist(test.date)
sec min hour mday mon year wday yday isdst
0 0 0 1 0 140 0 0 0
>
> date.plus.one <- as.POSIXct(test.date) +
2013 Jun 23
1
stats::convolve documentation enhancement
Hi,
the function stats::convolve does not mention efficient usage of the
underlying FFT algorithm, such as
(a) if type="circular", then length(x)=length(y) should have many
factors (e.g. length(x) = length(y) = 2^n)
(b) if type="open" or "filter", then length(x)+length(y)-1 should have
many factors (e.g. length(x)+length(y)-1 = 2^n)
In particular the latter may
2006 Jul 27
3
deparse(substitute(foo))
I see that plot.default uses deparse(substitute(x)) to extract the
character name of an argument and put it on the vertical axis.
Hence:
foo <- 1:10
plot( foo )
will put the label "foo" on the vertical axis.
However, for a function that takes a "..." list as an input, I can only
extract the first argument name:
x <- 1:10
y <- 10:20
foo <- function(...) {