Homework2 - In rstudio install package quantmod load...

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

View Full Document Right Arrow Icon
# In rstudio, install package quantmod # load package library(quantmod) library(fpp) # this is the three month t-bill rate. Note this is in percentage. tb3=getSymbols('TB3MS',src='FRED', from='2008', auto.assign = FALSE) # this is to obtain the t-bill rate from 2008-01 to 2012-12 tb=as.vector(tb3[889:948]) # obtain the daily return of sp500 index. "^GSPC" is the symbol for sp500 index. sp500=getSymbols('^GSPC',from='2008-01-01',to='2012-12-31',auto.assign=FALSE) sp500.adj=sp500$GSPC.Adjusted # read the help file of monthlyReturn to find out how to compute log return # instead of arithmetic return. sp500.rtn.monthly=monthlyReturn(sp500.adj,type='arithmetic') # this computes the excess sp500 monthly return. For simplicity, we assume that # the monthly t-bill return (monthly risk free rate) is (annualized t-bill rate)/12. sp500.excess=sp500.rtn.monthly-tb/(100*12) # you job is to compute the excess return of your stock, and run a regression # with sp500.excess. tb3=getSymbols('TB3MS',src='FRED', from='2008', auto.assign = FALSE) tb=as.vector(tb3[889:948]) synaptics=getSymbols('SYNA',from='2008-01-01',to='2012-12-31',auto.assign=FALSE)
Image of page 1

Info icon This 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