performanceanalytics

PerformanceAnalytics Numbers to Percent %

点点圈 提交于 2019-12-09 03:46:11
问题 I want to know if it is possible to make the table output in this R package a % instead of a numeric. table.AnnualizedReturns(indOver, Rf=0) SP500 Annualized Return 0.0732 Annualized Std Dev 0.1951 Annualized Sharpe (Rf=0%) 0.3752 So the 1st one 0.0732 I would like to see as 0.07% 回答1: The return value from that function is a data frame, so the question is how to make a column of a data frame print with a percentage sign. Reproducible example follows. > require(PerformanceAnalytics) > data

CAPM.beta rollapply

喜欢而已 提交于 2019-12-08 13:31:41
问题 I have already successfully calculated my rolling correlations in my xts object with x <- cbind(market_return,stock_returns) rollcor_3year <- rollapplyr( x, width=width_cor,function(x) cor(x[,1],x[,-1], use="pairwise.complete.obs"),by.column=FALSE) The correlation was later used to calculate rolling Betas. Now I found the function CAPM.beta from the PerformanceAnalytics package and I wonder why I cannot use beta <- rollapplyr(x,width=width_cor,function(x) CAPM.beta(x[,1],x[,-1]),by.column

R calculating a stock's beta (using PerformanceAnalytics CAPM.beta() function or lm() function producing unexpected results)

≯℡__Kan透↙ 提交于 2019-12-07 17:14:04
问题 I am trying to quantify a stock's beta (bench marked vs. SPY) in R using the PerformanceAnalytics CAPM.beta() function and the results aren't even close to the values I am seeing online at Yahoo/Google Finance. The code: require(PerformanceAnalytics) start_date <- "2013-08-24" acad <- getSymbols("ACAD", from = start_date, auto.assign = F) spy <- getSymbols("SPY", from = start_date, auto.assign = F) CAPM.beta(acad[,6], spy[,6]) For the above example, Yahoo/Finviz/Google all list ACAD's beta at

PerformanceAnalytics Numbers to Percent %

喜欢而已 提交于 2019-12-02 06:06:41
I want to know if it is possible to make the table output in this R package a % instead of a numeric. table.AnnualizedReturns(indOver, Rf=0) SP500 Annualized Return 0.0732 Annualized Std Dev 0.1951 Annualized Sharpe (Rf=0%) 0.3752 So the 1st one 0.0732 I would like to see as 0.07% The return value from that function is a data frame, so the question is how to make a column of a data frame print with a percentage sign. Reproducible example follows. > require(PerformanceAnalytics) > data(managers) > tb = table.AnnualizedReturns(managers[,1],Rf=0) > tb HAM1 Annualized Return 0.1375 Annualized Std

Using rollapply function for VaR calculation using R

橙三吉。 提交于 2019-12-02 00:23:49
I did the following for calculating Value at Risk (VaR) over 20 period rolling window: require(PerformanceAnalytics); require(zoo) data(edhec) class(edhec) # [1] "xts" "zoo" class(edhec$CTAGlobal) # "NULL" var1<-rollapply(edhec,width=20,FUN=function(edhec) VaR(R=edhec,p=.95,method="modified"),by.column=TRUE) It produces the desired output, and then I tried the same on another data: data(managers) class(managers) # [1] "xts" "zoo" class(managers$HAM4) # [1] "xts" "zoo" var2<-rollapply(managers,width=20,FUN=function(managers) VaR(R=managers,p=.95,method="modified"),by.column=TRUE) But I am

Estimation of rolling Value at Risk (VaR) using R

不想你离开。 提交于 2019-12-01 02:09:25
问题 I need to perform rolling VaR estimation of daily stock returns. At first I did the following: library(PerformanceAnalytics) data(edhec) sample<-edhec[,1:5] var605<-rollapply(as.zoo(sample),width=60,FUN=function(x) VaR(R=x,p=.95,method="modified",invert=T),by.column=TRUE,fill=NA) It performs the computation and returns a zoo object but gives a series of warnings as follows: VaR calculation produces unreliable result (inverse risk) for column: 1 : -0.00030977098532231 Then, I tried the same