Mutate(market_returns = market_returns_tidy$returns) %>% Let’s make sure it’s periodicity aligns perfectly with our portfolio returns periodicity portfolio_returns_tq_rebalanced_monthly %>% Head(market_returns_tidy) # A tibble: 6 x 2 We will also want a ame object of market returns, and will convert the xts object using tk_tbl(preserve_index = TRUE, rename_index = "date") from the timetk package. To.monthly(indexAt = "last", OHLC = FALSE) Note the start date is “” and the end date is “”, so we will be working with five years of returns. Let’s calculate our market return for SPY and save it as market_return_xts. With those caveats in mind, feel free to choose a different asset for the market return and try to reproduce this work, or construct a different portfolio that does not include SPY. It will offer one benefit in the way of a sanity check, which I’ll note below. That’s going to make our calculations substantively uninteresting because (1) SPY is 25% of our portfolio and (2) we have chosen assets and a time period (2013 - 2017) in which correlations with SPY have been high. Our first step is to make a choice about which asset to use as a proxy for the market return, and we will go with the SPY ETF, effectively treating the S&P 500 as the market. + asset_returns_long (a tidy tibble of monthly returns for those 5 assets above) + portfolio_returns_tq_rebalanced_monthly (a tibble of monthly returns) We will be working with two objects of portfolio returns and one object of our individual asset returns: + portfolio_returns_xts_rebalanced_monthly (an xts of monthly returns) Portfolio_returns_tq_rebalanced_monthly % Mutate(returns = (log(returns) - log(lag(returns)))) %>% Tk_tbl(preserve_index = TRUE, rename_index = "date") %>% To.monthly(indexAt = "last", OHLC = FALSE) %>% I won’t go through the logic again but the code is here: library(tidyquant) + EEM (an emerging-mkts fund) weighted 20%īefore we can calculate beta for that portfolio, we need to find portfolio monthly returns, which was covered in this post. + IJS (a small-cap value fund) weighted 20% + EFA (a non-US equities fund) weighted 25% We will be working with and calculating beta for our usual portfolio consisting of: + SPY (S&P500 fund) weighted 25% If you’re a tidyverse type of person but need to collaborate with an xts or tidyquant enthusiast, it will help if each of you is familiar with the three universes (though at some point ya just have to choose a code flow and get stuff done). I don’t think everyone needs to grind through their work using each paradigm, but I do think it’s helpful to be fluent, or, at least, conversant, in the various worlds. These seem to be the most popular paradigms for doing financial time series work, and even within a team there can be differing preferences. We are going to be calculating beta in several ways: by-hand (for illustrative purposes), in the xts world with PerformanceAnalytics, in the tidyverse with dplyr, and in the tidyquant world. Even if your team dislikes CAPM in favor of more nuanced models, these code flows can serve as a good base for the building of those more complex models. For our purposes, it’s a good vehicle for exploring reproducible flows for modeling or regressing our portfolio returns on the market returns. It captures the linear relationship between the asset/portfolio and the market. Beta, as we noted above, is the beta coefficient of an asset that results from regressing the returns of that asset on market returns. We are going to focus on one particular aspect of CAPM: beta. Plus, it might have been questioned by future research, but it’s still an iconic model that we should learn and love. With that, we will forge ahead with our analysis because calculating CAPM betas can serve as a nice template for more complex models in a team’s work and sometimes it’s a good idea to start with a simple model, even if it hasn’t stood up to empirical rigor. Indeed, it is often the only asset pricing model taught in these courses…nfortunately, the empirical record of the model is poor.” 1 Fama and French have written that CAPM “is the centerpiece of MBA investment courses. That linear relationship is the stock’s beta coefficient, or just good ol’ beta.ĬAPM was introduced back in 1964, garnered a Nobel for its creator, and, like many ephocally important theories, has been widely used, updated, criticized, debunked, revived, re-debunked, etc. That will entail fitting a linear model and, when we get to visualization next time, considering the meaning of our results from the perspective of asset returns.īy way of brief background, the Capital Asset Pricing Model (CAPM) is a model, created by William Sharpe, that estimates the return of an asset based on the return of the market and the asset’s linear relationship to the return of the market. Today we will continue our portfolio fun by calculating the CAPM beta of our portfolio returns.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |