[Returnanalytics-commits] r2952 - in pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Aug 31 18:30:59 CEST 2013
Author: shubhanm
Date: 2013-08-31 18:30:59 +0200 (Sat, 31 Aug 2013)
New Revision: 2952
Added:
pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/inst/
pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/QP.Norm.Rd
pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/table.EMaxDDGBM.Rd
Modified:
pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/Return.Okunev.R
pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/se.LoSharpe.R
pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/Return.Okunev.Rd
pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/se.LoSharpe.Rd
Log:
Clean Return.Okunev.R
Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/Return.Okunev.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/Return.Okunev.R 2013-08-31 14:03:26 UTC (rev 2951)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/Return.Okunev.R 2013-08-31 16:30:59 UTC (rev 2952)
@@ -1,40 +1,23 @@
-#' Okunev and White Return Model
-#'
-#' The objective is to determine the true underlying return by removing the
+#'@title OW Return Model
+#'@description The objective is to determine the true underlying return by removing the
#' autocorrelation structure in the original return series without making any assumptions
#' regarding the actual time series properties of the underlying process. We are
#' implicitly assuming by this approach that the autocorrelations that arise in reported
-#' returns are entirely due to the smoothing behavior funds engage in when reporting
+#'returns are entirely due to the smoothing behavior funds engage in when reporting
#' results. In fact, the method may be adopted to produce any desired
#' level of autocorrelation at any lag and is not limited to simply eliminating all
-#' autocorrelations.It can be be said as the general form of Geltner Return Model
-#'
+#'autocorrelations.It can be be said as the general form of Geltner Return Model
#'@details
-#' Given a sample of historical returns \eqn{R(1),R(2), . . .,R(T)},
-#' the method assumes the fund manager smooths returns in the following manner:
+#'Given a sample of historical returns \eqn{R(1),R(2), . . .,R(T)},the method assumes the fund manager smooths returns in the following manner:
#' \deqn{ r(0,t) = \sum \beta (i) r(0,t-i) + (1- \alpha)r(m,t) }
#' Where :\deqn{ \sum \beta (i) = (1- \alpha) }
#' \bold{r(0,t)} : is the observed (reported) return at time t (with 0 adjustments to reported returns),
-#' \bold{r(m,t)} : is the true underlying (unreported) return at
-#' time t (determined by making m adjustments to reported returns).
+#'\bold{r(m,t)} : is the true underlying (unreported) return at time t (determined by making m adjustments to reported returns).
#'
-#' To remove the \bold{first m orders} of autocorrelation from a given return
-#' series we would proceed in a manner very similar to that detailed in
-#' \bold{\code{\link{Return.Geltner}} \cr}. We would initially remove the first order
-#' autocorrelation, then proceed to eliminate the second order autocorrelation
-#' through the iteration process. In general, to remove any order, m,
-#' autocorrelations from a given return series we would make the following
-#' transformation to returns:
-#' autocorrelation structure in the original return series without making any
-#' assumptions regarding the actual time series properties of the underlying
-#' process. We are implicitly assuming by this approach that the autocorrelations
-#' that arise in reported returns are entirely due to the smoothing behavior funds
-#' engage in when reporting results. In fact, the method may be adopted to produce
-#' any desired level of autocorrelation at any lag and is not limited to simply
-#' eliminating all autocorrelations.
-#'
+#'To remove the \bold{first m orders} of autocorrelation from a given return series we would proceed in a manner very similar to that detailed in \bold{ \code{\link{Return.Geltner}} \cr}. We would initially remove the first order autocorrelation, then proceed to eliminate the second order autocorrelation through the iteration process. In general, to remove any order, m, autocorrelations from a given return series we would make the following transformation to returns:
+#' autocorrelation structure in the original return series without making any assumptions regarding the actual time series properties of the underlying process. We are implicitly assuming by this approach that the autocorrelations that arise in reported returns are entirely due to the smoothing behavior funds engage in when reporting results. In fact, the method may be adopted to produce any desired level of autocorrelation at any lag and is not limited to simply eliminating all autocorrelations.
#' @param
-#' R : an xts, vector, matrix, data frame, timeSeries or zoo object of
+#' Ra : an xts, vector, matrix, data frame, timeSeries or zoo object of
#' asset returns
#' @param
#' q : order of autocorrelation coefficient lag factors
@@ -49,33 +32,57 @@
#' @examples
#'
#' data(managers)
-#' Return.Okunev(managers)
+#' head(Return.Okunev(managers[,1:3]),n=3)
#'
#'
#' @export
-Return.Okunev<-function(R,q=3)
+Return.Okunev<-function(Ra,q=3)
{
- column.okunev=R
- column.okunev <- column.okunev[!is.na(column.okunev)]
- for(i in 1:q)
+ R = checkData(Ra, method="xts")
+ # Get dimensions and labels
+ columns.a = ncol(R)
+ columnnames.a = colnames(R)
+ clean.okunev <- function(column.R) {
+ # compute the lagged return series
+
+ lagR = na.omit(lag(column.R,1))
+ # compute the first order autocorrelation
+ column.R= (column.R-(lagR*quad(lagR,0)))/(1-quad(lagR,0))
+ return(column.R)
+ }
+
+ quad <- function(R,d)
{
- lagR = lag(column.okunev, k=i)
- column.okunev= (column.okunev-(lagR*quad(lagR,0)))/(1-quad(lagR,0))
+ coeff = as.numeric(acf(as.numeric(R), plot = FALSE)[1:2][[1]])
+ b=-(1+coeff[2]-2*d*coeff[1])
+ c=(coeff[1]-d)
+ ans= (-b-sqrt(b*b-4*c*c))/(2*c)
+ #a <- a[!is.na(a)]
+ return(c(ans))
}
- return(c(column.okunev))
+
+
+ for(column.a in 1:columns.a) { # for each asset passed in as R
+ # clean the data and get rid of NAs
+ column.okunev=R[,column.a]
+ for(i in 1:q)
+ {
+ column.okunev <- clean.okunev(column.okunev)
+ column.okunev=na.omit(column.okunev)
+ }
+ if(column.a == 1) { okunev = column.okunev }
+ else { okunev = cbind (okunev, column.okunev) }
+
+ }
+
+ #return(c(column.okunev))
+ colnames(okunev) = columnnames.a
+
+ # RESULTS:
+ return(reclass(okunev,match.to=Ra))
+
}
-#helper function for Return.Okunev, not exported
-quad <- function(R,d)
-{
- coeff = as.numeric(acf(as.numeric(R, plot = FALSE)[1:2][[1]]))
- b=-(1+coeff[2]-2*d*coeff[1])
- c=(coeff[1]-d)
- ans= (-b-sqrt(b*b-4*c*c))/(2*c)
- #a <- a[!is.na(a)]
- return(c(ans))
-}
-
###############################################################################
# R (http://r-project.org/) Econometrics for Performance and Risk Analysis
#
Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/se.LoSharpe.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/se.LoSharpe.R 2013-08-31 14:03:26 UTC (rev 2951)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/se.LoSharpe.R 2013-08-31 16:30:59 UTC (rev 2952)
@@ -34,7 +34,7 @@
#' @examples
#'
#' data(edhec)
-#' head(se.LoSharpe(edhec,0,3)
+#' se.LoSharpe(edhec,0,3)
#' @rdname se.LoSharpe
#' @export
se.LoSharpe <-
Added: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/QP.Norm.Rd
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/QP.Norm.Rd (rev 0)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/QP.Norm.Rd 2013-08-31 16:30:59 UTC (rev 2952)
@@ -0,0 +1,22 @@
+\name{QP.Norm}
+\alias{QP.Norm}
+\title{QP function for calculation of Sharpe Ratio}
+\usage{
+ QP.Norm(R, tau, scale = NA)
+}
+\arguments{
+ \item{R}{an xts, vector, matrix, data frame, timeSeries
+ or zoo object of asset returns}
+
+ \item{tau}{Time Scale Translations Factor}
+
+ \item{scale}{number of periods in a year (daily scale =
+ 252, monthly scale =}
+}
+\description{
+ QP function for calculation of Sharpe Ratio
+}
+\seealso{
+ \code{\link{CalmarRatio.Norm}}, \cr
+}
+
Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/Return.Okunev.Rd
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/Return.Okunev.Rd 2013-08-31 14:03:26 UTC (rev 2951)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/Return.Okunev.Rd 2013-08-31 16:30:59 UTC (rev 2952)
@@ -1,79 +1,78 @@
-\name{Return.Okunev}
-\alias{Return.Okunev}
-\title{Okunev and White Return Model}
-\usage{
- Return.Okunev(R, q = 3)
-}
-\arguments{
- \item{R}{: an xts, vector, matrix, data frame, timeSeries
- or zoo object of asset returns}
-
- \item{q}{: order of autocorrelation coefficient lag
- factors}
-}
-\description{
- The objective is to determine the true underlying return
- by removing the autocorrelation structure in the original
- return series without making any assumptions regarding
- the actual time series properties of the underlying
- process. We are implicitly assuming by this approach that
- the autocorrelations that arise in reported returns are
- entirely due to the smoothing behavior funds engage in
- when reporting results. In fact, the method may be
- adopted to produce any desired level of autocorrelation
- at any lag and is not limited to simply eliminating all
- autocorrelations.It can be be said as the general form of
- Geltner Return Model
-}
-\details{
- Given a sample of historical returns \eqn{R(1),R(2), . .
- .,R(T)}, the method assumes the fund manager smooths
- returns in the following manner: \deqn{ r(0,t) = \sum
- \beta (i) r(0,t-i) + (1- \alpha)r(m,t) } Where :\deqn{
- \sum \beta (i) = (1- \alpha) } \bold{r(0,t)} : is the
- observed (reported) return at time t (with 0 adjustments
- to reported returns), \bold{r(m,t)} : is the true
- underlying (unreported) return at time t (determined by
- making m adjustments to reported returns).
-
- To remove the \bold{first m orders} of autocorrelation
- from a given return series we would proceed in a manner
- very similar to that detailed in
- \bold{\code{\link{Return.Geltner}} \cr}. We would
- initially remove the first order autocorrelation, then
- proceed to eliminate the second order autocorrelation
- through the iteration process. In general, to remove any
- order, m, autocorrelations from a given return series we
- would make the following transformation to returns:
- autocorrelation structure in the original return series
- without making any assumptions regarding the actual time
- series properties of the underlying process. We are
- implicitly assuming by this approach that the
- autocorrelations that arise in reported returns are
- entirely due to the smoothing behavior funds engage in
- when reporting results. In fact, the method may be
- adopted to produce any desired level of autocorrelation
- at any lag and is not limited to simply eliminating all
- autocorrelations.
-}
-\examples{
-data(managers)
-Return.Okunev(managers)
-}
-\author{
- Peter Carl, Brian Peterson, Shubhankit Mohan
-}
-\references{
- Okunev, John and White, Derek R., \emph{ Hedge Fund Risk
- Factors and Value at Risk of Credit Trading Strategies}
- (October 2003). Available at SSRN:
- \url{http://ssrn.com/abstract=460641}
-}
-\seealso{
- \code{\link{Return.Geltner}} \cr
-}
-\keyword{distribution}
-\keyword{models}
-\keyword{multivariate}
-\keyword{ts}
-
+\name{Return.Okunev}
+\alias{Return.Okunev}
+\title{OW Return Model}
+\usage{
+ Return.Okunev(Ra, q = 3)
+}
+\arguments{
+ \item{Ra}{: an xts, vector, matrix, data frame,
+ timeSeries or zoo object of asset returns}
+
+ \item{q}{: order of autocorrelation coefficient lag
+ factors}
+}
+\description{
+ The objective is to determine the true underlying return
+ by removing the autocorrelation structure in the original
+ return series without making any assumptions regarding
+ the actual time series properties of the underlying
+ process. We are implicitly assuming by this approach that
+ the autocorrelations that arise in reported returns are
+ entirely due to the smoothing behavior funds engage in
+ when reporting results. In fact, the method may be
+ adopted to produce any desired level of autocorrelation
+ at any lag and is not limited to simply eliminating all
+ autocorrelations.It can be be said as the general form of
+ Geltner Return Model
+}
+\details{
+ Given a sample of historical returns \eqn{R(1),R(2), . .
+ .,R(T)},the method assumes the fund manager smooths
+ returns in the following manner: \deqn{ r(0,t) = \sum
+ \beta (i) r(0,t-i) + (1- \alpha)r(m,t) } Where :\deqn{
+ \sum \beta (i) = (1- \alpha) } \bold{r(0,t)} : is the
+ observed (reported) return at time t (with 0 adjustments
+ to reported returns), \bold{r(m,t)} : is the true
+ underlying (unreported) return at time t (determined by
+ making m adjustments to reported returns).
+
+ To remove the \bold{first m orders} of autocorrelation
+ from a given return series we would proceed in a manner
+ very similar to that detailed in \bold{
+ \code{\link{Return.Geltner}} \cr}. We would initially
+ remove the first order autocorrelation, then proceed to
+ eliminate the second order autocorrelation through the
+ iteration process. In general, to remove any order, m,
+ autocorrelations from a given return series we would make
+ the following transformation to returns: autocorrelation
+ structure in the original return series without making
+ any assumptions regarding the actual time series
+ properties of the underlying process. We are implicitly
+ assuming by this approach that the autocorrelations that
+ arise in reported returns are entirely due to the
+ smoothing behavior funds engage in when reporting
+ results. In fact, the method may be adopted to produce
+ any desired level of autocorrelation at any lag and is
+ not limited to simply eliminating all autocorrelations.
+}
+\examples{
+data(managers)
+head(Return.Okunev(managers[,1:3]),n=3)
+}
+\author{
+ Peter Carl, Brian Peterson, Shubhankit Mohan
+}
+\references{
+ Okunev, John and White, Derek R., \emph{ Hedge Fund Risk
+ Factors and Value at Risk of Credit Trading Strategies}
+ (October 2003). Available at SSRN:
+ \url{http://ssrn.com/abstract=460641}
+}
+\seealso{
+ \code{\link{Return.Geltner}} \cr
+}
+\keyword{distribution}
+\keyword{models}
+\keyword{multivariate}
+\keyword{ts}
+
Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/se.LoSharpe.Rd
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/se.LoSharpe.Rd 2013-08-31 14:03:26 UTC (rev 2951)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/se.LoSharpe.Rd 2013-08-31 16:30:59 UTC (rev 2952)
@@ -48,7 +48,7 @@
}
\examples{
data(edhec)
-head(se.LoSharpe(edhec,0,3)
+se.LoSharpe(edhec,0,3)
}
\author{
Brian G. Peterson, Peter Carl, Shubhankit Mohan
Added: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/table.EMaxDDGBM.Rd
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/table.EMaxDDGBM.Rd (rev 0)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/man/table.EMaxDDGBM.Rd 2013-08-31 16:30:59 UTC (rev 2952)
@@ -0,0 +1,57 @@
+\name{table.EMaxDDGBM}
+\alias{table.EMaxDDGBM}
+\title{Expected Drawdown using Brownian Motion Assumptions}
+\usage{
+ table.EMaxDDGBM(R, digits = 4)
+}
+\arguments{
+ \item{R}{an xts, vector, matrix, data frame, timeSeries
+ or zoo object of asset returns}
+
+ \item{digits}{significant number}
+}
+\description{
+ Works on the model specified by Maddon-Ismail which
+ investigates the behavior of this statistic for a
+ Brownian motion with drift.
+}
+\details{
+ If X(t) is a random process on [0, T ], the maximum
+ drawdown at time T , D(T), is defined by where \deqn{D(T)
+ = sup [X(s) - X(t)]} where s belongs to [0,t] and s
+ belongs to [0,T] Informally, this is the largest drop
+ from a peak to a bottom. In this paper, we investigate
+ the behavior of this statistic for a Brownian motion with
+ drift. In particular, we give an infinite series
+ representation of its distribution, and consider its
+ expected value. When the drift is zero, we give an
+ analytic expression for the expected value, and for
+ non-zero drift, we give an infinite series
+ representation. For all cases, we compute the limiting
+ \bold{(\eqn{T tends to \infty})} behavior, which can be
+ logarithmic (\eqn{\mu} > 0), square root (\eqn{\mu} = 0),
+ or linear (\eqn{\mu} < 0).
+}
+\examples{
+library(PerformanceAnalytics)
+data(edhec)
+table.EMaxDDGBM(edhec)
+}
+\author{
+ Shubhankit Mohan
+}
+\references{
+ Magdon-Ismail, M., Atiya, A., Pratap, A., and Yaser S.
+ Abu-Mostafa: On the Maximum Drawdown of a Browninan
+ Motion, Journal of Applied Probability 41, pp. 147-161,
+ 2004
+ \url{http://alumnus.caltech.edu/~amir/drawdown-jrnl.pdf}
+}
+\keyword{Assumptions}
+\keyword{Brownian}
+\keyword{Drawdown}
+\keyword{Expected}
+\keyword{models}
+\keyword{Motion}
+\keyword{Using}
+
More information about the Returnanalytics-commits
mailing list