Re: [R] rollapply() produces NAs

2017-05-28 Thread Sepp via R-help
This is the function in plain text because it looked messy before: VaRfun <- function(x, lambda = 0.94) { #create data.frame and order returns such that the lates return is the first df <- data.frame(weight = c(1:length(x)), return = rev(x)) K <- nrow(df) constant <- (1-lambda)/(1-lambda^(K

Re: [R] rollapply() produces NAs

2017-05-28 Thread Sepp via R-help
)), FUN = VaRfun), On Sat, May 27, 2017 at 5:29 PM, Sepp via R-help wrote: > Hello, > I am fairly new to R and trying to calculate value at risk with exponentially > decreasing weights.My function works for a single vector of returns but does > not work with rollapply(), which is wh

[R] rollapply() produces NAs

2017-05-27 Thread Sepp via R-help
Hello, I am fairly new to R and trying to calculate value at risk with exponentially decreasing weights.My function works for a single vector of returns but does not work with rollapply(), which is what I want to use. The function I am working on should assig exponentially decreasing weights to