[Returnanalytics-commits] r3513 - pkg/PerformanceAnalytics/vignettes
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Aug 24 16:50:13 CEST 2014
Author: rossbennett34
Date: 2014-08-24 16:50:13 +0200 (Sun, 24 Aug 2014)
New Revision: 3513
Added:
pkg/PerformanceAnalytics/vignettes/portfolio_returns.pdf
Modified:
pkg/PerformanceAnalytics/vignettes/portfolio_returns.Rnw
Log:
revisions to portfolio returns vignette
Modified: pkg/PerformanceAnalytics/vignettes/portfolio_returns.Rnw
===================================================================
--- pkg/PerformanceAnalytics/vignettes/portfolio_returns.Rnw 2014-08-24 13:40:36 UTC (rev 3512)
+++ pkg/PerformanceAnalytics/vignettes/portfolio_returns.Rnw 2014-08-24 14:50:13 UTC (rev 3513)
@@ -1,15 +1,23 @@
\documentclass{article}
\usepackage{amsmath}
\usepackage{verbatim}
+\usepackage{Rd}
+%\VignetteIndexEntry{Portfolio Returns}
+%\VignetteDepends{PerformanceAnalytics}
+%\VignetteKeywords{returns, performance, portfolio}
+%\VignettePackage{PerformanceAnalytics}
\begin{document}
-\section{Basic definitions}
+\begin{abstract}
+This vignette provides an overview of calculating portfolio returns through time with an emphasis on the math used to develop the \verb"Return.portfolio" function in \pkg{PerformanceAnalytics}. We first introduce some basic definitions, then give simple examples of computing portfolio returns in a prices and shares framework as well as a returns and weights framework. We then introduce \verb"Return.portfolio" and demonstrate the function with a few examples.
+\end{abstract}
-Suppose we have a portfolio of $N$ assets.
+\tableofcontents
-The value of asset $i$ in the portfolio is defined as
+\section{Basic definitions}
+Suppose we have a portfolio of $N$ assets. The value of asset $i$, $V_i$, in the portfolio is defined as
\begin{eqnarray*}
V_i = \lambda_i * P_i
\end{eqnarray*}
@@ -20,13 +28,12 @@
P_i \text{ is the price of asset $i$}\\
\end{eqnarray*}
-The total portfolio value is defined as
+The total portfolio value, $V_p$, is defined as
\begin{eqnarray*}
V_P = \sum_{i=1}^N V_i
\end{eqnarray*}
-The weight of asset $i$ in the portfolio is defined as
-
+The weight of asset $i$, $w_i$, in the portfolio is defined as
\begin{eqnarray*}
w_i = V_i / V_P
\end{eqnarray*}
@@ -37,14 +44,17 @@
V_P \text{ is the total value of the portfolio}\\
\end{eqnarray*}
-The portfolio return at time $t$ is defined as
+The portfolio return at time $t$, $R_t$, is defined as
+\begin{eqnarray*}
+R_t = \frac{V_{p_{t}} - V_{p_{{t-1}}}}{V_{p_{{t-1}}}}
+\end{eqnarray*}
\begin{eqnarray*}
-R_t = \frac{V_t - V_{t-1}}{V_{t-1}}
+V_{p_{t}} \text{ is the portfolio value at time $t$}\\
\end{eqnarray*}
\section{Simple Example: Prices and Shares Framework}
-Suppose we have a portfolio of $N = 2$ assets, asset A and asset B. The prices for assets A and B are given as:
+Suppose we have a portfolio of $N = 2$ assets, asset A and asset B. The prices for assets A and B are given as
<<>>=
prices = cbind(c(5, 7, 6, 7),
@@ -117,12 +127,11 @@
weights
@
-We have shown that calculating portfolio weights, values, and returns is simple in a prices and shares framework. However, calculating these metrics becomes more of a challenge in a weights and returns framework.
+We have shown that calculating portfolio weights, values, and returns is simple in a prices and shares framework. However, calculating these metrics becomes more challenging in a weights and returns framework.
\section{Example: Weights and Returns Framework}
-For this example, we will use the monthly returns during 1997 of the first 5 assets in the edhec dataset.
-
+We will use the monthly returns during 1997 of the first 5 assets in the edhec dataset for the following example.
<<>>=
library(PerformanceAnalytics)
data(edhec)
@@ -134,7 +143,7 @@
Suppose that on 1996-12-31 we wish to form an equal weight portfolio such that the weight for asset $i$ is given as:
\begin{equation*}
-w_i = frac{1 / N} \quad \text{for } i \in 1, \hdots, N
+w_i = \frac{1}{N} \quad \text{for } i \in 1, \hdots, N
\end{equation*}
where $N$ is equal to the number of assets.
@@ -150,8 +159,7 @@
Case 1: The beginning of period $t$ is a rebalancing event. For example, the rebalance weights at the end of \verb"1996-12-31" take effect at the beginning of \verb"1997-01-31". This means that the beginning of \verb"1997-01-31" is considered a rebalance event.
-The beginning of period value for asset $i$ at time $t$ is given as:
-
+The beginning of period value for asset $i$ at time $t$ is given as
\begin{equation*}
V_{{bop}_{t,i}} = w_i * V_{t-1}
\end{equation*}
@@ -163,17 +171,15 @@
V_{{bop}_{t,i}} = V_{{eop}_{t-1,i}}
\end{equation*}
-where $V_{{eop}_{t,i}}$ is the end of period value for asset $i$ from the prior period.
+where $V_{{eop}_{t-1,i}}$ is the end of period value for asset $i$ from the prior period.
-The end of period value for asset $i$ at time $t$ is given as:
+The end of period value for asset $i$ at time $t$ is given as
\begin{equation*}
V_{{eop}_{t,i}} = (1 + R_{t,i}) * V_{{bop}_{t,i}}
\end{equation*}
-Here we demonstrate this and compute values for the periods 1 and 2.
+Here we demonstrate this and compute values for the periods 1 and 2. For the first period, $t=1$, we need an initial value for the portfolio value. Let $V_0 = 1$ denote the initial portfolio value. Note that the initial portfolio value can be any arbitrary number. Here we use $V_0 = 1$ for simplicity.
-For the first period, $t=1$, we need an initial value for the portfolio value. Let $V_0 = 1$ denote the initial portfolio value. Note that the initial portfolio value can be any arbitrary number. Here we use $V_0 = 1$ for simplicity.
-
<<>>=
V_0 = 1
bop_value = eop_value = matrix(0, 2, ncol(R))
@@ -193,14 +199,14 @@
eop_value[t,] = coredata(1 + R[t,]) * bop_value[t,]
@
-It is easily seen that the values for the rest of the time periods can be computed by iterating over $ t \in 1, \hdots, T$ where $T=12$ in this example.
+It is seen that the values for the rest of the time periods can be computed by iterating over $ t \in 1, \hdots, T$ where $T=12$ in this example.
-The weight of asset $i$ at time $t$ is calculated as:
+The weight of asset $i$ at time $t$ is calculated as
\begin{equation*}
w_{t,i} = \frac{V_{t,i}}{\sum_{i=0}^N V_{t,i}}
\end{equation*}
-Here we compute the beginning and end of period weights.
+Here we compute both the beginning and end of period weights.
<<>>=
bop_weights = eop_weights = matrix(0, 2, ncol(R))
for(t in 1:2){
@@ -211,8 +217,7 @@
eop_weights
@
-The portfolio returns for time $t$ are calculated as:
-
+The portfolio returns at time $t$ are calculated as
\begin{equation*}
R_{P_t} = \frac{V_t - V_{t-1}}{V_{t-1}}
\end{equation*}
@@ -223,9 +228,7 @@
R_P
@
-
-The contribution of asset $i$ at time $t$ is calculated as:
-
+The contribution of asset $i$ at time $t$ is calculated as
\begin{equation*}
contribution_{t,i} = \frac{V_{{eop}_{t,i}} - V_{{bop}_{t,i}}}{\sum_{i=1}^N V_{{bop}_{t,i}}}
\end{equation*}
@@ -238,7 +241,7 @@
contribution
@
-Note that contribution can also be calculated as:
+Note that contribution can also be calculated as
\begin{equation*}
contribution_{t,i} = R_{t,i} * w_{t,i}
\end{equation*}
@@ -249,9 +252,8 @@
args(Return.portfolio)
@
+If no \verb"weights" are specified, then an equal weight portfolio is computed. If \verb"rebalance_on=NA" then a buy and hold portfolio is assumed. See \verb"?Return.portfolio" for a detailed explanation of the function and arguments.
-If no \verb"weights" are specified, then an equal weight portfolio is computed. Also, if \verb"rebalance_on=NA" then a buy and hold portfolio is assumed. See \verb"?Return.portfolio" for a detailed explanation of the function and arguments.
-
<<tidy=FALSE>>=
# Equally weighted, buy and hold portfolio returns
Return.portfolio(R)
@@ -265,5 +267,4 @@
Return.portfolio(R, rebalance_on="quarters", verbose=TRUE)
@
-
\end{document}
Added: pkg/PerformanceAnalytics/vignettes/portfolio_returns.pdf
===================================================================
(Binary files differ)
Property changes on: pkg/PerformanceAnalytics/vignettes/portfolio_returns.pdf
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
More information about the Returnanalytics-commits
mailing list