Displaying 1 result from an estimated 1 matches for "charrec".
Did you mean:
charred
2011 Nov 27
1
generating a vector of y_t = \sum_{i = 1}^t (alpha^i * x_{t - i + 1})
...## Bench mark the recursion functions
loopRec <- function(x, alpha){
n <- length(x)
y <- double(n)
for(i in 1:n){
y[i] <- sum(cumprod(rep(alpha, i)) * rev(x[1:i]))
}
y
}
loopRec(c(1, 2, 3), 0.5)
## This is a crazy solution, but worth giving it a try.
charRec <- function(x, alpha){
n <- length(x)
exp.mat <- matrix(rep(x, each = n), nc = n, byrow = TRUE)
up.mat <- matrix(eval(parse(text = paste("c(",
paste(paste(paste("rep(0, ", 0:(n - 1), ")", sep = ""),...