similar to: generating a vector of y_t = \sum_{i = 1}^t (alpha^i * x_{t - i + 1})

Displaying 20 results from an estimated 200 matches similar to: "generating a vector of y_t = \sum_{i = 1}^t (alpha^i * x_{t - i + 1})"

2004 Apr 13
1
shared mem advice
Hi, I want to write a package where I would use shared memory for some vectors Any suggestion is appreciated... I wonder if the right approach would be to modify add a modified version of the allocVector(SEXPTYPE type, int length) function specifically shared_mem_id = shmget(shared_mem_key, SHM_SIZE, IPC_CREAT);
2008 Aug 18
2
matrix row product and cumulative product
I spent a lot of time searching and came up empty handed on the following query. Is there an equivalent to rowSums that does product or cumulative product and avoids use of apply or looping? I found a rowProd in a package but it was a convenience function for apply. As part of a likelihood calculation called from optim, I?m computing products and cumulative products of rows of matrices with
2003 Mar 22
1
cumprod doesn't work with data frames (PR#2667)
Full_Name: J. Sisk Version: 1.6.1 OS: Linux (RedHat 8) Submission from: (NULL) (67.119.41.66) Suppose you make a data-frame like so: xxx <- data.frame(a=10,b=20,c=30,d=40) Then cumprod(xxx[1,]) returns > cumprod(xxx[1,]) a b c d 1 10 20 30 40 The documentation for cumprod says that it should work on "numerical objects", and this is a data-frame, but it
2006 Feb 28
2
vector math: calculating a rolling 12 row product?
I have a dataframe of numeric values with 30 ?rows? and 7 ?columns?. For each column, beginning at ?row? 12 and down to ?row? 30, I wish to calculate the ?rolling 12 row product?. I.e., within each column, I wish to multiply all the values in row 1:12, 2:13, 19:30. I wish to save the results as a new dataframe, which will have 19 rows and 7 columns.
2009 Sep 16
2
Generalized cumsum?
Is there anything like cumsum and cumprod but which allows you to apply an arbitrary function instead of sum and product? In other words, I want a function cumfunc(x, f) that returns a vector, so that for all n up to the length of x cumapply(x,f)[n] = f(x[1:n]) This would give cumsum and cumprod as special cases when f=sum or f=prod. I could write such a function, but I can't see
2011 Jan 27
1
How do I fix this ?
Just when I think I'm starting to learn .... Statement z1 works, statement z doesn't. Why doesn't z work and what do I do to fix it ? Clearly the problem is with the first NA, but I would think it's handled through the loop vectorization. y1 <- rnorm(20, 0, .013) y1 [1] -0.0068630836 -0.0101106230 -0.0169663344 -0.0066314769 0.0075063818 [6] -0.0033548024 0.0015647863
2010 Jul 09
3
apply is slower than for loop?
I thought the "apply" functions are faster than for loops, but my most recent test shows that apply actually takes a significantly longer than a for loop. Am I missing something? It doesn't matter much if I do column wise calculations rather than row wise ## Example of how apply is SLOWER than for loop: #rm(list=ls()) ## DEFINE VARIABLES mu=0.05 ; sigma=0.20 ; dt=.25 ; T=50 ;
2009 Oct 13
7
lapply() reccursively
Hi all, I was wondering whether it is possible to use the lapply() function to alter the value of the input, something in the spirit of : a1<-runif(100) a2<-function(i){ a1[i]<-a1[i-1]*a1[i];a1[i] } a3<-lapply(2:100,a2) Something akin to a for() loop, but using the lapply() infrastructure. I haven't been able to get rapply() to do this. The reason is that the "real"
2006 Aug 31
2
cumulative growth rates indexed to a common starting point over n series of observations
What is the R way of computing cumulative growth rates given a series of discrete values indexed . For instance, given a matrix of 20 observations for each of 5 series (zz), what is the most straight forward technique in R for computing cumulative growth (zzcum) ? It seems for the solution I'm after might be imbedding the following cum growth rate calc as a function into a function call
2009 Jul 31
1
what meaning missing value True /False needed
This is my code i don't understand the error message: library(rgenoud) rm(list=ls()) set.seed(666) ######################################################### # As a first step, it is assumed that all input parameters are independent of ageingĀ : ######################################################### InputDim <-20 # Max number of ageings in the inputs CPIRate <- rep(0.02 , InputDim ) #
2005 Mar 10
1
R_alloc with more than 2GB (PR#7721)
Full_Name: Wolfgang Huber Version: R-devel_2005-03-10 OS: alphaev68-dec-osf4.0f Submission from: (NULL) (62.253.128.15) This report concerns allocation of large (>2^31 byte) chunks of memory with R_alloc. I suspect it is a bug/typo but please don't hate me if it's actually a feature: In R, I can happily create large matrices: > a= matrix(0, nrow=191481, ncol=3063) > dim(a) [1]
2012 May 25
1
Filling NA with cumprod?
Hello, I need to build certain interpolation logic using R. Unfortunately, I just started using R, and I'm not familiar with lots of advanced or just convenient features of the language to make this simpler. So I struggled for few days and pretty much reduced the whole exercise to the following problem, which I cannot resolve: Assume we have a vector of some values with NA: a <- c(1,
2010 Feb 26
7
question to make a vector without loop
Hello all, I want to define a vector like w[k+1]=w[k]*a/(b+k) for k=1,...,N-1 without use loop. Is it posible to do in R? Regards khazaei
2017 Jan 20
1
NaN behavior of cumsum
Hi! I noticed that cumsum behaves different than the other cumulative functions wrt. NaN values: > values <- c(1,2,NaN,1) > for ( f in c(cumsum, cumprod, cummin, cummax)) print(f(values)) [1] 1 3 NA NA [1] 1 2 NaN NaN [1] 1 1 NaN NaN [1] 1 2 NaN NaN The reason is that cumsum (in cum.c:33) contains an explicit check for ISNAN. Is that intentional? IMHO, ISNA would be better
2003 Apr 29
1
Shafer's MIX: Query on code
Thanks to Fernando Tusell and especially to Brian Ripley for their work on 'mix', leading to an apparently good package mow available on CRAN. Going through the R code for the function prelim.mix, I am wondering why the following method of calculation is used at one point: umd <- as.integer(round(exp(cumsum(log(d))))) (d is a vector containing, in effect, the numbers of levels of
2009 Oct 29
2
fast cumulative matrix multiplication
Hi all, I am looking for a function like cumprod() that works for matrix multiplication. In other words, I have matrices [M1, M2, ..., Mn], and I want to calculate [M1, M1%*%M2, M1%*%M2%*%M3, ..., M1%*%...%*%Mn] as quickly as possible. Right now I'm using a for() loop but it seems like there should be a faster way. Any help is appreciated! Thanks, Todd Schneider todd.w.schneider@gmail.com
2004 Oct 03
1
How might one write this better?
I am trying to simulate the trajectory of the pension assets of one person. In C-like syntax, it looks like this: daily.wage.growth = 1.001 # deterministic contribution.rate = 0.08 # deterministic 8% Wage = 10 # initial Asset = 0 # initial for (10,000 days) { Asset += contribution.rate * Wage
2010 Dec 19
2
Replacing the for loop for time series buid-up
Hi, is there a function that replaces the following code? n=200 boot.x[1]=odhad+boot.res[1] #(boot.x[0]=1) for (j in 1:(n-1)) { boot.x[j+1]=odhad*boot.x[j]+boot.res[j+1] } This is nested in two other loops, and I am looking for some way to improve code performance I tried sapply and cumprod but no success. Thanks Jan -- View this message in context:
2017 Oct 06
1
SIGSEGV during startup
Hi, This problem started as of r73472 ("Merged in the rest of the basic ALTREP framework."); I tested r73471 and it did not exist. I'm building R devel on Ubuntu 16.04.3 LTS (64-bit), with the following flags: CC="gcc -std=gnu99 -fsanitize=address -fno-omit-frame-pointer" CFLAGS="-fno-omit-frame-pointer -g -O2 -Wall -pedantic -mtune=native" and using
2008 Jan 31
3
Log rank test power calculations
Does anyone have any ideas how I could do a power calculation for a log rank test. I would like to know what the suggested sample sizes would be to pick a difference when the control to active are in a ratio of 80% to 20%. Thanks Dan -- ************************************************************** Daniel Brewer, Ph.D. Institute of Cancer Research Email: daniel.brewer at icr.ac.uk