[Uwgarp-commits] r144 - pkg/GARPFRM/vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Mar 27 21:01:39 CET 2014


Author: rossbennett34
Date: 2014-03-27 21:01:38 +0100 (Thu, 27 Mar 2014)
New Revision: 144

Removed:
   pkg/GARPFRM/vignettes/sample_vignette.Rnw
   pkg/GARPFRM/vignettes/sample_vignette.pdf
Log:
Removing unused sample_vignette

Deleted: pkg/GARPFRM/vignettes/sample_vignette.Rnw
===================================================================
--- pkg/GARPFRM/vignettes/sample_vignette.Rnw	2014-03-27 19:40:23 UTC (rev 143)
+++ pkg/GARPFRM/vignettes/sample_vignette.Rnw	2014-03-27 20:01:38 UTC (rev 144)
@@ -1,209 +0,0 @@
-\documentclass[a4paper]{article}
-\usepackage[OT1]{fontenc}
-\usepackage{Sweave}
-\usepackage{Rd}
-\usepackage{amsmath}
-\usepackage{hyperref}
-\usepackage{url}
-\usepackage[round]{natbib}
-\usepackage{bm}
-\usepackage{verbatim}
-\usepackage[latin1]{inputenc}
-\bibliographystyle{abbrvnat}
-
-\let\proglang=\textsf
-%\newcommand{\pkg}[1]{{\fontseries{b}\selectfont #1}}
-%\newcommand{\R}[1]{{\fontseries{b}\selectfont #1}}
-%\newcommand{\email}[1]{\href{mailto:#1}{\normalfont\texttt{#1}}}
-%\newcommand{\E}{\mathsf{E}}
-%\newcommand{\VAR}{\mathsf{VAR}}
-%\newcommand{\COV}{\mathsf{COV}}
-%\newcommand{\Prob}{\mathsf{P}}
-
-\renewcommand{\topfraction}{0.85}
-\renewcommand{\textfraction}{0.1}
-\renewcommand{\baselinestretch}{1.5}
-\setlength{\textwidth}{15cm} \setlength{\textheight}{22cm} \topmargin-1cm \evensidemargin0.5cm \oddsidemargin0.5cm
-
-\usepackage[latin1]{inputenc}
-% or whatever
-
-\usepackage{lmodern}
-\usepackage[T1]{fontenc}
-% Or whatever. Note that the encoding and the font should match. If T1
-% does not look nice, try deleting the line with the fontenc.
-
-\begin{document}
-
-\title{CAPM Fitting and Testing}
-\author{Thomas Fillebeen}
-
-\maketitle
-
-\begin{abstract}
-Standard Capital Asset Pricing Model (CAPM) fitting and testing using Quandl data.
-
-CAPM Assumptions
-1. Identical investors who are price takers;
-2. Investment over the same time horizon; 
-3. No transaction costs or taxes;
-4. Can borrow and lend at risk-free rate;
-5. Investors only care about portfolio expected return and variance;
-6. Market consists of all publicly traded assets.
-
-The Consumption-Oriented CAPM is analogous to the simple form of the CAPM. Except that the growth rate of per capita consumption has replaced the rate of return on the market porfolio as the influence effecting returns.
-\end{abstract}
-
-\tableofcontents
-
-\section{Fitting CAPM}
-\subsection{Extracting and Organizing Data}
-<<ex1>>=
-# 'Load the GARPFRM package and the CAPM dataset.
-suppressMessages(library(GARPFRM))
-options(digits=3)
-data(capm_data)
-stock.df <- capm_data
-colnames(stock.df)
-@
-
-<<ex2>>=
-# Estimate a zooreg object: regularly spaced zoo object.
-stock.z = zooreg(stock.df[,-1], start=c(1993, 1), end=c(2013,11), 
-                 frequency=12)
-index(stock.z) = as.yearmon(index(stock.z))
-# Summarize Start, End, and Number of Rows
-start(stock.z)
-end(stock.z)
-nrow(stock.z)
-@
-\subsection{Estimate Excess Returns}
-Estimate excess returns: subtracting off risk-free rate.
-To strip off the dates and just return a plain vector/matrix coredata() can be used.
-<<ex3>>=
-# as.data.frame to check if an object is a data frame, or coerce it if possible.
-returns.mat = as.matrix(coredata(stock.z))
-exReturns.mat = returns.mat - returns.mat[,"RFREE"]
-exReturns.df = as.data.frame(exReturns.mat)
-@
-
-\subsection{Fitting CAPM Model}
-Run CAPM regression for AAPL (AAPL) using first 5 years (60 months divided by 12 months in a years = 5 years).
-<<ex4>>=
-capm.fit = lm(AAPL~MARKET,data=exReturns.df,subset=1:60)
-summary(capm.fit)
-
-# Plot data with regression line
-plot(exReturns.df$MARKET,exReturns.df$AAPL, main="CAPM for AAPL",
-    
-     ylab="Excess Return: AAPL",
-     xlab="Excess Return: MARKET")
-# Plot CAPM regression estimate
-abline(capm.fit)    
-# Create Axis 
-abline(h=0,v=0,lty=3)
-# Placing beta & tstat values on the plot for APPL
-alpha = coef(summary(capm.fit))[1,1]
-a_tstat = coef(summary(capm.fit))[1,3]
-beta = coef(summary(capm.fit))[2,1]
-b_tstat = coef(summary(capm.fit))[2,3]
-
-legend("topleft", legend=
-c(paste("alpha =",round(alpha,dig=2),"(",round(a_tstat, dig=2),")"), 
-paste("beta =",round(beta,dig=2),"(",round(b_tstat,dig=2),")")), cex=1, bty="n")
-
-@
-
-\section{Testing CAPM}
-\subsection{Created CAPM Function}
-Use a capm.tstats function:
-Estimating CAPM with alpha=0 for asset using first 5 years of data
-<<ex5>>=
-capm.tstats = function(r,mkrt) {
-  # Fiting CAPM
-  capm.fit = lm(r~mkrt)  	
-  # Extract summary info
-  capm.summary = summary(capm.fit)		
-  # Retrieve t-stat
-  t.stat = coef(capm.summary)[1,3]	
-  t.stat
-}
-@
-\subsection{Estimate Significance and Test Beta Results}
-Retrieve tstats from function for assets.
-Filter out rf and market before running.
-<<ex6>>=
-colnames(exReturns.mat[,-c(1,6,7)])
-tstats = apply(exReturns.mat[1:60,-c(1,6,7)],2, capm.tstats, 
-               exReturns.mat[1:60,"MARKET"])
-tstats
-
-# Test Hypothesis for 5% CI: H0: alpha=0
-abs(tstats) > 2
-any(abs(tstats) > 2)
-@
-
-\subsection{Estimate Expected Returns and Plot}
-Plot expected return versus beta.
-Estimate expected returns over first 5 years.
-<<ex7>>=
-mu.hat = colMeans(exReturns.mat[1:60,-c(1,6,7)])
-mu.hat
-
-# Compute beta over first 5 years
-capm.betas = function(r,market) {
-  capm.fit = lm(r~market)  				
-  # Fit capm regression
-  capm.beta = coef(capm.fit)[2]				
-  # Extract coefficients
-  capm.beta
-}
-
-betas = apply(exReturns.mat[1:60,-c(1,6,7)],2,
-      
-       FUN=capm.betas,
-       market=exReturns.mat[1:60,"MARKET"])
-betas
-
-# Plot expected returns versus betas
-plot(betas,mu.hat,main="Expected Return vs. Beta")
-# Estimate regression of Expected Return vs. Beta
-sml.fit = lm(mu.hat~betas)
-sml.fit
-summary(sml.fit)
-# Ideally intercept is zero and equals the excess market return
-mean(exReturns.mat[1:60,"MARKET"])
-# Plot Fitted SML
-plot(betas,mu.hat,main="Estimated SML")
-abline(sml.fit)
-legend("topright",1, "Estimated SML",1)
-@
-
-\section{Consumption-Oriented CAPM}
-\subsection{Fitting C-CAPM}
-Run C-CAPM regression for CONS (Consumption) using first 5 years (60 months divided by 12 months in a years = 5 years).
-<<ex8>>=
-end = nrow(stock.z)
-capm.fit = lm(CONS~MARKET,data=exReturns.df,(end-60):end)
-summary(capm.fit)
-
-# Plot data with regression line
-plot(exReturns.df$MARKET,exReturns.df$CONS, main="CAPM for CONS",
-    
-     ylab="Excess Return: CONS",
-    xlab="Excess Return: MARKET")
-# Plot C-CAPM regression estimate
-abline(capm.fit)    
-# Create Axis 
-abline(h=0,v=0,lty=3)
-# Placing beta & tstat values on the plot for CONS
-beta = coef(summary(capm.fit))[2,1]
-b_stat = coef(summary(capm.fit))[2,3]
-alpha = coef(summary(capm.fit))[1,1]
-a_stat = coef(summary(capm.fit))[1,3]
-legend("topleft", legend=
-c(paste("alpha =",round(alpha,dig=2),"(",round(a_tstat, dig=2),")"), 
-paste("beta =",round(beta,dig=2),"(",round(b_tstat,dig=2),")")), cex=1, bty="n")
-@
-NOTE: Specific problems with CCAPM is that it suffers from two puzzles: the equity premium puzzle (EPP) and the risk-free rate puzzle (RFRP). EPP implies that investors are extremely risk averse to explain the existence of a market risk premium. While RFRP stipulates that investors save in TBills despite the low rate of return.
-\end{document}
\ No newline at end of file

Deleted: pkg/GARPFRM/vignettes/sample_vignette.pdf
===================================================================
(Binary files differ)



More information about the Uwgarp-commits mailing list