[R-SIG-Finance] [R-sig-finance] troubles with the weights in the VaR function
genx
info at genetrix.se
Thu Apr 26 14:55:11 CEST 2007
I have the same problem with vectors of different length, most packages don't
know how to scale and adjust timeseries / vectors of different length. It
would be a welcome contribution to R Finance if any programmer out there
could solve this problem in an easy way.
Manu do a dim(vector) to check length of your vectors / matrices that you
want to compare. As an example, if i want to calculate the annualized
standard deviation (sigma) for n-periods i do the following on each vector,
this example vector is days.
sd(vector[(length(vector)-n):length(vector)]) * sqrt(252)
Kind regards
genx, Dura Mater
manu-25 wrote:
>
> hi there
>
> i have some troubles with VaR ( value at risk function)
> to be more specific, with the weights in the VaR function
>
>
> when i run the example:
> equalWeights = rep(1/4, 4)
> alpha = 0.10
> # Value at Risk:
> VaR(myAssets, equalWeights, alpha)
>
> everything is ok
>
>
>
> BUT
>
> when i read my own data set, and try to have my own weights, i have the
> following message :
>
> Erreur dans `names<-.default`(`*tmp*`, value = "VaR") :
> attribut 'names' [1] doit être de même longueur que le vecteur [0]
>
> which can be translated as:
>
> error in `names<-.default`(`*tmp*`, value = "VaR") :
> attribute 'names' [1] must have the same length as vector [0]
>
>
>
> i have no idea of what it means
> :-(
>
>
> i printed the names of my data, and it was exactely the same as the names
> in the VaR example
>
>
>
> when returning this message, R returns at the same time the computation of
> the VaR, but using the default (equal weights); in my case it is not
> possible to have different weights :-(
>
>
>
>
> did anyone face the same problem?
> if yes, how to solve it
>
>
> thx in advance
>
>
> regards
>
>
> manu
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>
>
--
View this message in context: http://www.nabble.com/troubles-with-the-weights-in-the-VaR-function-tf2785155.html#a10199718
Sent from the Rmetrics mailing list archive at Nabble.com.
More information about the R-SIG-Finance
mailing list