{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

12.stockPortfolio_intro

# 12.stockPortfolio_intro - University of California Los...

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

University of California, Los Angeles Department of Statistics Statistics C183/C283 Instructor: Nicolas Christou Introduction to the package stockPortfolio As short introduction of the package stockPortfolio . ######################### #===> ((((( 1 ))))) <===# #===> quick example <===# ######################### # load package library(stockPortfolio) # select stocks #IBM: International Business Machines Copr. #WFC: Wells Fargo & Compnay #JPM: JPMorgan Chase & Company #LUV: Southwest Airlines Co. #AMR: AMR Corporation ticker <- c("IBM", "WFC", "JPM", "LUV", "AMR") #Get stock data gr <- getReturns(ticker, start="2005-03-31", end="2010-03-31") #gr is a "list" object and we find what it contains by typing the following: names(gr) #We can access each component of gr by typing: gr\$R gr\$ticker etc. #Obtain the variance-covariance matrix of the returns: cov(gr\$R) IBM WFC JPM LUV AMR IBM 0.004032997 0.001119602 0.001909833 0.001835828 0.002888327 WFC 0.001119602 0.014004525 0.009073188 0.004552771 0.012378982 JPM 0.001909833 0.009073188 0.008714023 0.004077969 0.009667494 LUV 0.001835828 0.004552771 0.004077969 0.008271521 0.011399779 AMR 0.002888327 0.012378982 0.009667494 0.011399779 0.047216958 #Obtain the correlation matrix of the returns: cor(gr\$R) #We can find summary statistics as follows: summary(gr\$R) #To find the mean, variance, and standard deviation of a particular stock mean(gr\$R[,4]) var(gr\$R[,4]) sd(gr\$R[,4]) 1

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• 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.

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

• 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.

Dana University of Pennsylvania ‘17, Course Hero Intern

• 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.

Jill Tulane University ‘16, Course Hero Intern