[Uwgarp-commits] r98 - pkg/GARPFRM/vignettes
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Mar 5 03:23:12 CET 2014
Author: tfillebeen
Date: 2014-03-05 03:23:10 +0100 (Wed, 05 Mar 2014)
New Revision: 98
Added:
pkg/GARPFRM/vignettes/CAPM_TF.tex
pkg/GARPFRM/vignettes/EWMA_GARCH11_TF.tex
Log:
for .tex
Added: pkg/GARPFRM/vignettes/CAPM_TF.tex
===================================================================
--- pkg/GARPFRM/vignettes/CAPM_TF.tex (rev 0)
+++ pkg/GARPFRM/vignettes/CAPM_TF.tex 2014-03-05 02:23:10 UTC (rev 98)
@@ -0,0 +1,330 @@
+\documentclass[a4paper]{article}\usepackage[]{graphicx}\usepackage[]{color}
+%% maxwidth is the original width if it is less than linewidth
+%% otherwise use linewidth (to make sure the graphics do not exceed the margin)
+\makeatletter
+\def\maxwidth{ %
+ \ifdim\Gin at nat@width>\linewidth
+ \linewidth
+ \else
+ \Gin at nat@width
+ \fi
+}
+\makeatother
+
+\definecolor{fgcolor}{rgb}{0.345, 0.345, 0.345}
+\newcommand{\hlnum}[1]{\textcolor[rgb]{0.686,0.059,0.569}{#1}}%
+\newcommand{\hlstr}[1]{\textcolor[rgb]{0.192,0.494,0.8}{#1}}%
+\newcommand{\hlcom}[1]{\textcolor[rgb]{0.678,0.584,0.686}{\textit{#1}}}%
+\newcommand{\hlopt}[1]{\textcolor[rgb]{0,0,0}{#1}}%
+\newcommand{\hlstd}[1]{\textcolor[rgb]{0.345,0.345,0.345}{#1}}%
+\newcommand{\hlkwa}[1]{\textcolor[rgb]{0.161,0.373,0.58}{\textbf{#1}}}%
+\newcommand{\hlkwb}[1]{\textcolor[rgb]{0.69,0.353,0.396}{#1}}%
+\newcommand{\hlkwc}[1]{\textcolor[rgb]{0.333,0.667,0.333}{#1}}%
+\newcommand{\hlkwd}[1]{\textcolor[rgb]{0.737,0.353,0.396}{\textbf{#1}}}%
+
+\usepackage{framed}
+\makeatletter
+\newenvironment{kframe}{%
+ \def\at at end@of at kframe{}%
+ \ifinner\ifhmode%
+ \def\at at end@of at kframe{\end{minipage}}%
+ \begin{minipage}{\columnwidth}%
+ \fi\fi%
+ \def\FrameCommand##1{\hskip\@totalleftmargin \hskip-\fboxsep
+ \colorbox{shadecolor}{##1}\hskip-\fboxsep
+ % There is no \\@totalrightmargin, so:
+ \hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}%
+ \MakeFramed {\advance\hsize-\width
+ \@totalleftmargin\z@ \linewidth\hsize
+ \@setminipage}}%
+ {\par\unskip\endMakeFramed%
+ \at at end@of at kframe}
+\makeatother
+
+\definecolor{shadecolor}{rgb}{.97, .97, .97}
+\definecolor{messagecolor}{rgb}{0, 0, 0}
+\definecolor{warningcolor}{rgb}{1, 0, 1}
+\definecolor{errorcolor}{rgb}{1, 0, 0}
+\newenvironment{knitrout}{}{} % an empty environment to be redefined in TeX
+
+\usepackage{alltt}
+\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.
+\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
+
+\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{Selected Returns Time Series}
+\begin{knitrout}
+\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{kframe}
+\begin{alltt}
+\hlcom{# 'Load the GARPFRM package and CRSP dataset for CAPM analysis.}
+\hlkwd{suppressMessages}\hlstd{(}\hlkwd{library}\hlstd{(GARPFRM))}
+\hlkwd{options}\hlstd{(}\hlkwc{digits} \hlstd{=} \hlnum{3}\hlstd{)}
+\hlkwd{data}\hlstd{(crsp.short)}
+
+\hlstd{stock.df} \hlkwb{<-} \hlstd{largecap.ts[,} \hlnum{1}\hlopt{:}\hlnum{20}\hlstd{]}
+\hlstd{mrkt} \hlkwb{<-} \hlstd{largecap.ts[,} \hlstr{"market"}\hlstd{]}
+\hlstd{rfr} \hlkwb{<-} \hlstd{largecap.ts[,} \hlstr{"t90"}\hlstd{]}
+
+\hlcom{# Plot first four stocks from}
+\hlkwd{plot.zoo}\hlstd{(stock.df[,} \hlnum{1}\hlopt{:}\hlnum{4}\hlstd{],} \hlkwc{main} \hlstd{=} \hlstr{"First Four Large Cap Returns"}\hlstd{)}
+\end{alltt}
+\end{kframe}
+\includegraphics[width=\maxwidth]{figure/ex1}
+
+\end{knitrout}
+
+
+
+Summarize the start and end dates corresponding to the first 4 large cap returns.
+\begin{knitrout}
+\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{kframe}
+\begin{alltt}
+\hlcom{# Illustrate the type of data being analzyed: start-end dates.}
+\hlkwd{start}\hlstd{(stock.df[,} \hlnum{1}\hlopt{:}\hlnum{4}\hlstd{])}
+\end{alltt}
+\begin{verbatim}
+## [1] "1997-01-31"
+\end{verbatim}
+\begin{alltt}
+\hlkwd{end}\hlstd{(stock.df[,} \hlnum{1}\hlopt{:}\hlnum{4}\hlstd{])}
+\end{alltt}
+\begin{verbatim}
+## [1] "2001-12-31"
+\end{verbatim}
+\begin{alltt}
+\hlcom{# Count the number of rows: sample size.}
+\hlkwd{nrow}\hlstd{(stock.df)}
+\end{alltt}
+\begin{verbatim}
+## [1] 60
+\end{verbatim}
+\end{kframe}
+\end{knitrout}
+
+\subsection{Estimate Excess Returns}
+Estimate excess returns: subtracting off risk-free rate.
+\begin{knitrout}
+\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{kframe}
+\begin{alltt}
+\hlcom{# Excess Returns initialized before utilizing in CAPM}
+\hlstd{exReturns} \hlkwb{<-} \hlkwd{Return.excess}\hlstd{(stock.df, rfr)}
+\hlkwd{colnames}\hlstd{(exReturns)} \hlkwb{=} \hlkwd{c}\hlstd{(}\hlkwd{colnames}\hlstd{(stock.df))}
+\end{alltt}
+\end{kframe}
+\end{knitrout}
+
+
+\subsection{Fitting CAPM Model: Univariate}
+Run CAPM regression for AMAT and estimate CAPM with $\alpha=0$ \& $\beta=1$ for asset.
+\begin{knitrout}
+\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{kframe}
+\begin{alltt}
+\hlcom{# Univariate CAPM}
+\hlstd{uv} \hlkwb{<-} \hlkwd{CAPM}\hlstd{(exReturns[,} \hlnum{1}\hlstd{], mrkt)}
+\hlkwd{getStatistics}\hlstd{(uv)}
+\end{alltt}
+\begin{verbatim}
+## Estimate Std. Error t value Pr(>|t|)
+## alpha. AMAT 0.0158 0.0174 0.909 0.366872
+## beta. AMAT 2.2611 0.3192 3.951 0.000213
+\end{verbatim}
+\begin{alltt}
+\hlcom{# Plot data with regression line}
+\hlkwd{plot}\hlstd{(uv)}
+\end{alltt}
+\end{kframe}
+\includegraphics[width=\maxwidth]{figure/ex4}
+
+\end{knitrout}
+
+\subsection{CAPM Model: Multiple Asset Analysis}
+Run CAPM regression
+\begin{knitrout}
+\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{kframe}
+\begin{alltt}
+\hlcom{# MLM CAPM for AMAT, AMGN, and CAT}
+\hlstd{mlm} \hlkwb{<-} \hlkwd{CAPM}\hlstd{(exReturns[,} \hlnum{1}\hlopt{:}\hlnum{3}\hlstd{], mrkt)}
+\hlkwd{getStatistics}\hlstd{(mlm)}
+\end{alltt}
+\begin{verbatim}
+## Estimate Std. Error t value Pr(>|t|)
+## alpha. AMAT 0.01580 0.0174 0.909 0.366872
+## beta. AMAT 2.26113 0.3192 3.951 0.000213
+## alpha. AMGN 0.01887 0.0150 1.256 0.214198
+## beta. AMGN 0.86859 0.2760 -0.476 0.635765
+## alpha. CAT 0.00231 0.0122 0.190 0.850330
+## beta. CAT 0.60218 0.2241 -1.775 0.081064
+\end{verbatim}
+\begin{alltt}
+\hlcom{# Plot data with regression line}
+\hlkwd{plot}\hlstd{(mlm)}
+\end{alltt}
+\end{kframe}
+\includegraphics[width=\maxwidth]{figure/ex5}
+
+\end{knitrout}
+
+\section{Testing CAPM}
+\subsection{Retrieve $\alpha$ \& $\beta$ and Estimate Result Significance}
+Retrieve $\alpha$ \& $\beta$ from CAPM object for one or multiple assets and run hypothesis test.
+\begin{knitrout}
+\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{kframe}
+\begin{alltt}
+\hlcom{# For uv}
+\hlkwd{getBetas}\hlstd{(uv)}
+\end{alltt}
+\begin{verbatim}
+## beta. AMAT
+## 2.26
+\end{verbatim}
+\begin{alltt}
+\hlkwd{getAlphas}\hlstd{(uv)}
+\end{alltt}
+\begin{verbatim}
+## alpha. AMAT
+## 0.0158
+\end{verbatim}
+\begin{alltt}
+\hlkwd{hypTest}\hlstd{(uv,} \hlkwc{CI} \hlstd{=} \hlnum{0.05}\hlstd{)}
+\end{alltt}
+\begin{verbatim}
+## $alpha
+## [1] FALSE
+##
+## $beta
+## [1] TRUE
+\end{verbatim}
+\begin{alltt}
+\hlcom{# For mlm}
+\hlkwd{getBetas}\hlstd{(mlm)}
+\end{alltt}
+\begin{verbatim}
+## beta. AMAT beta. AMGN beta. CAT
+## 2.261 0.869 0.602
+\end{verbatim}
+\begin{alltt}
+\hlkwd{getAlphas}\hlstd{(mlm)}
+\end{alltt}
+\begin{verbatim}
+## alpha. AMAT alpha. AMGN alpha. CAT
+## 0.01580 0.01887 0.00231
+\end{verbatim}
+\begin{alltt}
+\hlkwd{hypTest}\hlstd{(mlm,} \hlkwc{CI} \hlstd{=} \hlnum{0.05}\hlstd{)}
+\end{alltt}
+\begin{verbatim}
+## $alpha
+## alpha. AMAT alpha. AMGN alpha. CAT
+## FALSE FALSE FALSE
+##
+## $beta
+## beta. AMAT beta. AMGN beta. CAT
+## TRUE FALSE FALSE
+\end{verbatim}
+\end{kframe}
+\end{knitrout}
+
+
+\subsection{Estimate Expected Returns and Plot}
+Plot expected return versus beta.
+Estimate expected returns
+\begin{knitrout}
+\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{kframe}
+\begin{alltt}
+\hlcom{# MLM CAPM}
+\hlstd{mlm} \hlkwb{<-} \hlkwd{CAPM}\hlstd{(exReturns[, ], mrkt)}
+
+\hlcom{# Plot expected returns versus betas}
+\hlkwd{chartSML}\hlstd{(mlm)}
+\end{alltt}
+\end{kframe}
+\includegraphics[width=\maxwidth]{figure/ex7}
+
+\end{knitrout}
+
+
+\section{Consumption-Oriented CAPM}
+\subsection{Fitting C-CAPM}
+Run C-CAPM regression for CONS (Consumption).
+\begin{knitrout}
+\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{kframe}
+\begin{alltt}
+\hlcom{# Load FED consumption data: CONS}
+\hlkwd{data}\hlstd{(cons)}
+\hlstd{cons} \hlkwb{<-} \hlkwd{xts}\hlstd{(cons[,} \hlnum{2}\hlstd{],} \hlkwd{index}\hlstd{(largecap.ts))}
+\hlkwd{colnames}\hlstd{(cons)} \hlkwb{=} \hlkwd{c}\hlstd{(}\hlstr{"CONS"}\hlstd{)}
+
+\hlstd{capm.cons} \hlkwb{=} \hlkwd{CAPM}\hlstd{(cons, mrkt)}
+\hlkwd{coef}\hlstd{(}\hlkwd{summary}\hlstd{(capm.cons))}
+\end{alltt}
+\begin{verbatim}
+## Estimate Std. Error t value Pr(>|t|)
+## (Intercept) 0.174 0.025 6.94 3.64e-09
+## Rmkt 0.481 0.460 1.04 3.01e-01
+\end{verbatim}
+\begin{alltt}
+\hlcom{# Plot data with regression line}
+\hlkwd{plot}\hlstd{(capm.cons)}
+\end{alltt}
+\end{kframe}
+\includegraphics[width=\maxwidth]{figure/ex8}
+
+\end{knitrout}
+
+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}
Added: pkg/GARPFRM/vignettes/EWMA_GARCH11_TF.tex
===================================================================
--- pkg/GARPFRM/vignettes/EWMA_GARCH11_TF.tex (rev 0)
+++ pkg/GARPFRM/vignettes/EWMA_GARCH11_TF.tex 2014-03-05 02:23:10 UTC (rev 98)
@@ -0,0 +1,58 @@
+\documentclass{article}\usepackage[]{graphicx}\usepackage[]{color}
+%% maxwidth is the original width if it is less than linewidth
+%% otherwise use linewidth (to make sure the graphics do not exceed the margin)
+\makeatletter
+\def\maxwidth{ %
+ \ifdim\Gin at nat@width>\linewidth
+ \linewidth
+ \else
+ \Gin at nat@width
+ \fi
+}
+\makeatother
+
+\definecolor{fgcolor}{rgb}{0.345, 0.345, 0.345}
+\newcommand{\hlnum}[1]{\textcolor[rgb]{0.686,0.059,0.569}{#1}}%
+\newcommand{\hlstr}[1]{\textcolor[rgb]{0.192,0.494,0.8}{#1}}%
+\newcommand{\hlcom}[1]{\textcolor[rgb]{0.678,0.584,0.686}{\textit{#1}}}%
+\newcommand{\hlopt}[1]{\textcolor[rgb]{0,0,0}{#1}}%
+\newcommand{\hlstd}[1]{\textcolor[rgb]{0.345,0.345,0.345}{#1}}%
+\newcommand{\hlkwa}[1]{\textcolor[rgb]{0.161,0.373,0.58}{\textbf{#1}}}%
+\newcommand{\hlkwb}[1]{\textcolor[rgb]{0.69,0.353,0.396}{#1}}%
+\newcommand{\hlkwc}[1]{\textcolor[rgb]{0.333,0.667,0.333}{#1}}%
+\newcommand{\hlkwd}[1]{\textcolor[rgb]{0.737,0.353,0.396}{\textbf{#1}}}%
+
+\usepackage{framed}
+\makeatletter
+\newenvironment{kframe}{%
+ \def\at at end@of at kframe{}%
+ \ifinner\ifhmode%
+ \def\at at end@of at kframe{\end{minipage}}%
+ \begin{minipage}{\columnwidth}%
+ \fi\fi%
+ \def\FrameCommand##1{\hskip\@totalleftmargin \hskip-\fboxsep
+ \colorbox{shadecolor}{##1}\hskip-\fboxsep
+ % There is no \\@totalrightmargin, so:
+ \hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}%
+ \MakeFramed {\advance\hsize-\width
+ \@totalleftmargin\z@ \linewidth\hsize
+ \@setminipage}}%
+ {\par\unskip\endMakeFramed%
+ \at at end@of at kframe}
+\makeatother
+
+\definecolor{shadecolor}{rgb}{.97, .97, .97}
+\definecolor{messagecolor}{rgb}{0, 0, 0}
+\definecolor{warningcolor}{rgb}{1, 0, 1}
+\definecolor{errorcolor}{rgb}{1, 0, 0}
+\newenvironment{knitrout}{}{} % an empty environment to be redefined in TeX
+
+\usepackage{alltt}
+\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
+
+\begin{document}
+
+
+
+
+\end{document}
More information about the Uwgarp-commits
mailing list