[Returnanalytics-commits] r2215 - in pkg/PerformanceAnalytics: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Jul 27 19:52:27 CEST 2012
Author: braverock
Date: 2012-07-27 19:52:27 +0200 (Fri, 27 Jul 2012)
New Revision: 2215
Modified:
pkg/PerformanceAnalytics/R/ES.R
pkg/PerformanceAnalytics/R/PortfolioRisk.R
pkg/PerformanceAnalytics/man/ES.Rd
Log:
- remove ES portfolio kernel method for now, lay groudwork for adding it back in later
Modified: pkg/PerformanceAnalytics/R/ES.R
===================================================================
--- pkg/PerformanceAnalytics/R/ES.R 2012-07-27 17:10:06 UTC (rev 2214)
+++ pkg/PerformanceAnalytics/R/ES.R 2012-07-27 17:52:27 UTC (rev 2215)
@@ -16,7 +16,7 @@
#' @param R a vector, matrix, data frame, timeSeries or zoo object of asset
#' returns
#' @param p confidence level for calculation, default p=.95
-#' @param method one of "modified","gaussian","historical", "kernel", see
+#' @param method one of "modified","gaussian","historical", see
#' Details.
#' @param clean method for data cleaning through \code{\link{Return.clean}}.
#' Current options are "none", "boudt", or "geltner".
@@ -116,7 +116,7 @@
#' ES(edhec, clean="boudt", portfolio_method="component")
#'
ETL <- CVaR <- ES <- function (R=NULL , p=0.95, ...,
- method=c("modified","gaussian","historical", "kernel"),
+ method=c("modified","gaussian","historical"),
clean=c("none","boudt", "geltner"),
portfolio_method=c("single","component"),
weights=NULL, mu=NULL, sigma=NULL, m3=NULL, m4=NULL,
@@ -187,7 +187,7 @@
switch(method,
modified = { rES=mES.MM(w=weights, mu=mu, sigma=sigma, M3=m3 , M4=m4 , p=p) },
gaussian = { rES=GES.MM(w=weights, mu=mu, sigma=sigma, p=p) },
- historical = { rES = (ES.historical(R=R,p=p) %*% weights) } # note that this is not tested for weighting the univariate calc by the weights
+ historical = { rES = ES.historical(R=R,p=p) %*% weights }, # note that this is not tested for weighting the univariate calc by the weights,
) # end multivariate method
}
# check for unreasonable results
@@ -224,7 +224,8 @@
else return(ES.CornishFisher.portfolio(p,weights,mu,sigma,m3,m4))
},
gaussian = { return(ES.Gaussian.portfolio(p,weights,mu,sigma)) },
- historical = { return(ES.historical.portfolio(R, p,weights)) }
+ historical = { return(ES.historical.portfolio(R, p,weights)) },
+ kernel = { return(ES.kernel.portfolio(R=R,p=p,w=w)) }
)
} # end component portfolio switch
Modified: pkg/PerformanceAnalytics/R/PortfolioRisk.R
===================================================================
--- pkg/PerformanceAnalytics/R/PortfolioRisk.R 2012-07-27 17:10:06 UTC (rev 2214)
+++ pkg/PerformanceAnalytics/R/PortfolioRisk.R 2012-07-27 17:52:27 UTC (rev 2215)
@@ -290,6 +290,20 @@
return(ret)
}
+ES.kernel.portfolio= function( R, p, w )
+{#WARNING incomplete
+ VAR<-VaR.kernel.portfolio( R, p, w )
+
+ #I'm sure that using Return.portfolio probably makes more sense here...
+ T = dim(R)[1]; N = dim(R)[2];
+ portfolioreturn = c();
+ for( t in 1:T ){ portfolioreturn = c( portfolioreturn , sum(w*R[t,]) ) }
+
+ PES<-mean(portfolioreturn>VAR$VaR)
+
+
+}
+
ES.Gaussian.portfolio = function(p,w,mu,sigma)
{
alpha = .setalphaprob(p)
Modified: pkg/PerformanceAnalytics/man/ES.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/ES.Rd 2012-07-27 17:10:06 UTC (rev 2214)
+++ pkg/PerformanceAnalytics/man/ES.Rd 2012-07-27 17:52:27 UTC (rev 2215)
@@ -6,7 +6,7 @@
univariate and component, using a variety of analytical methods.}
\usage{
ETL(R = NULL, p = 0.95, ...,
- method = c("modified", "gaussian", "historical", "kernel"),
+ method = c("modified", "gaussian", "historical"),
clean = c("none", "boudt", "geltner"),
portfolio_method = c("single", "component"),
weights = NULL, mu = NULL, sigma = NULL, m3 = NULL,
@@ -19,7 +19,7 @@
\item{p}{confidence level for calculation, default p=.95}
\item{method}{one of "modified","gaussian","historical",
- "kernel", see Details.}
+ see Details.}
\item{clean}{method for data cleaning through
\code{\link{Return.clean}}. Current options are "none",
More information about the Returnanalytics-commits
mailing list