Statistics C183/C283 Instructor: Nicolas Christou Project 1


Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due


Statistics C183/C283 Instructor: Nicolas Christou 

Project 1 

Select 30 stocks (plus the market S&P500) from http://finance.yahoo.com. Please select stocks from 5 industries. To find the industry in which each stock belongs go to https://finance.yahoo.com/screener/predefined/ms_technology/ and click on the following to select the stocks: 

Basic Materials 

Communication Services 

Consumer Cyclical 

Consumer Defensive 

Energy 

Financial Services 

Healthcare 

Industrials 

Real Estate 

Technology 

Utilities 

The portfolios will be constructed using monthly data from 01-Jan-2014 to 01-Jan-2019 (5 years). For the testing period use monthly data from 01-Jan-2019 to 31-Mar-2022. Make sure that you have data available for all your stocks for the entire period, 01-Jan-2014 to 31-Mar-2022. 

Project 1 

Things to do: 

a. Use http://shiny.stat.ucla.edu:3838/c183c283/ Enter the tickers as follows: ^GSPC,AAPL,IBM,.... 

b. You will download the adjusted close prices for 30 stocks plus the S&P500 in a csv file. Import the data in R and convert the adjusted close prices into returns. (Use the first 5-year data only!) 

c. Compute the means of the 31 assets, the standard deviations, and the variance covariance matrix. 

d. Plot the 31 assets on the space expected return against standard deviation. 

e. Assume equal allocation portfolio using the 30 stocks. Compute the mean and standard deviation of this portfolio and add it on the plot of question (c). 

f. Add on the plot the minimum risk portfolio. 

Few R commands to begin the project: 

#Read your csv file: 

a <- read.csv("stockData.csv", sep=",", header=TRUE) 

#Convert adjusted close prices into returns: 

r <- (a[-1,3:ncol(a)]-a[-nrow(a),3:ncol(a)])/a[-nrow(a),3:ncol(a)] 

#Compute mean vector: 

means <- colMeans(r[-1]) #Without ^GSPC 

#Compute variance covariance matrix: 

covmat <- cov(r[-1])  #Without ^GSPC 

#Compute correlation matrix: 

cormat <- cor(r[-1]) #Without ^GSPC 

#Compute the vector of variances: 

variances <- diag(covmat) 

#Compute the vector of standard deviations: 

stdev <- diag(covmat)^.

发表评论

电子邮件地址不会被公开。 必填项已用*标注