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 <-
You will get better help if you read the Posting Guide mentioned at the foot if
every posting including this one carefully and pay attention.
A) You need to post in plain text, as your code came through the mailing list
damaged.
B) You need to include sample data and make your code run from a
This is exactly what I want. However, with my function it produces a vector of
NAs ...
Gabor Grothendieck schrieb am 16:23 Sonntag, 28.Mai
2017:
Maybe you want this.It computes VaRfun(r[c(i-500, i-1)] for each i for
which the argument to r makes sense.
Maybe you want this.It computes VaRfun(r[c(i-500, i-1)] for each i for
which the argument to r makes sense.
rollapply(r, width = list(c(-500, -1)), 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
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
5 matches
Mail list logo