famamacb20171101101843.rmd

famamacb20171101101843.rmd - -title"Factor Models output...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
--- title: "Factor Models" output: html_document: toc: true --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ``` ```{r, include=FALSE} # loading the packages and datasets dataff <- read.table("/Users/robertamorelli/Desktop/Econometrics /L5-6- 7/ffdata.csv", stringsAsFactors = F, header = T, sep = ",") # packages used listofpackages <- c("plm", "foreign", "lmtest", "aod", "systemfit", "dygraphs", "car", "sandwich") for (j in listofpackages){ if(sum(installed.packages()[, 1] == j) == 0) { install.packages(j) } library(j, character.only = T) } ``` ## Fama-MacBeth regressions ### One factor model Here we introduce only one factor: market excess return. 1)Estimate over the sample 1962:1 2014:6 the CAPM for the 25 FF portfolios and plot the Securities Market Line ```{r} # 1962:1 2014:6 returns <- as.matrix(subset(dataff, select = PR11:PR55, date >= 1962 & date <=2014 + 5/12 + 0.01)) rf <- as.matrix(subset(dataff, select = RF, date >= 1962 & date <=2014 + 5/12 + 0.01)) ex_returns <- returns - rep(rf, ncol(returns)) factors <- as.matrix(subset(dataff, select = exret_mkt, date >= 1962 & date <=2014 + 5/12 + 0.01)) # the first step X <- cbind(matrix(1, nrow(ex_returns), 1), factors) Y <- ex_returns
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern