Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

I HAVE AN ASSIGNMENT ON R PROGRAMMING AND NEED HELP WITH IT

1 answer below »
I HAVE AN ASSIGNMENT ON R PROGRAMMING AND NEED HELP WITH IT
Answered Same Day Apr 28, 2021

Solution

Naveen answered on Apr 29 2021
133 Votes
Data Analysis Project [15 marks]
Due date: 5pm, 29April 2020
Requirement: Pls finish the tasks according to the requirements. All the tasks need to be finished by using R. Pls present your results in the word file, copyall your R code in the end of this word file, and then submit your word file via the Turnitin link in iLearn.
Task 1: Stock Return and Portfolio Analysis
In the file named as “Stock.csv”, you have been provided with the daily prices of three stocks from 2012 to 2018.
a. Plot and present the stock prices in time series with appropriate labels. [1 mark]
. Calculate the log returns of all the three stocks and express them in percentages.
Pls report the descriptive statistics of log returns of three stocks in Table 1. Pls change the names in Table 1 to the stock names in your file. [1 mark]
Table 1: Summary Statistics
    Variable
    MSFT
    MMM
    AMZN
    Min
    -0.121
    -0.0708
    -0.1165
    Max
    0.0994
    0.0574
    0.1462
    Mean
    0.0009
    0.0006
    0.0012
    Median
    0.0005
    0.0008
    0.0009
    SD
    0.0145
    0.0104
    0.0191
    Skewness
    -0.0848
    -0.6662
    0.4093
    Kurtosis
    8.2279
    5.3061
    9.0696
    N
    1759
    1759
    1759
c. Pls report the co
elation matrix of log returns of three stocks in Table 1. Pls change the names in Table 1 to the stock names in your file. [1 mark]
Table 2: Co
elation Matrix
    Variable
    MSFT
    MMM
    AMZN
    MSFT
    1
    0.473848
    0.45311
    MMM
    0.473848
    1
    0.348167
    AMZN
    0.45311
    0.348167
    1
d. There is a file named as “FF3factors.csv” in your folder. Merge your stock data with the Fama French three factors data, which are all in percentages. Pls create a new variable Stock.Rf for all the three stocks, which equals to the difference between log return of each stock and RF (available in the FF3factors.csv), and run a regression of :
.
Report the regression results for all the three stocks in tables (you can use only one table to summarize all the results or three separate tables). [1 mark]
Call:
lm(formula = Stock.Rf ~ Mkt.RF, data = Stock_FF3)
Residuals:
Min 1Q Median 3Q Max
-0.03841 -0.00350 -0.00018 0.00319 0.07356
Coefficients:
Estimate Std. E
or t value Pr(>|t|)
(Intercept) 0.000332 0.000168 1.98 0.048 *
Mkt.RF 0.011181 0.000202 55.41 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard e
or: 0.00702 on 1756 degrees of freedom
Multiple R-squared: 0.636,    Adjusted R-squared: 0.636
F-statistic: 3.07e+03 on 1 and 1756 DF, p-value: <2e-16
Call:
lm(formula = Stock.Rf ~ MSFT + MMM + AMZN, data = Stock_FF3)
Residuals:
Min 1Q Median 3Q Max
-3.90e-16 -1.20e-18 -5.00e-19 2.00e-19 1.22e-15
Coefficients:
Estimate Std. E
or t value Pr(>|t|)
(Intercept) -1.94e-18 7.35e-19 -2.65e+00 0.0082 **
MSFT 3.33e-01 6.11e-17 5.45e+15 <2e-16 ***
MMM 3.33e-01 8.09e-17 4.12e+15 <2e-16 ***
AMZN 3.33e-01 4.36e-17 7.64e+15 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard e
or: 3.07e-17 on 1754 degrees of freedom
Multiple R-squared: 1,    Adjusted R-squared: 1
F-statistic: 8.41e+31 on 3 and 1754 DF, p-value: <2e-16
e. Pls run regressionsof:
.
Report the regression results for all the three stocks in tables (you can use only one table to summarize all the results or three separate tables). [1 mark]
Call:
lm(formula = Stock.Rf ~ Mkt.RF + SMB + HML, data = Stock_FF3)
Residuals:
Min 1Q Median 3Q Max
-0.03734 -0.00327 -0.00027 0.00297 0.07060
Coefficients:
Estimate Std. E
or t value Pr(>|t|)
(Intercept) 0.000298 0.000156 1.91 0.057 .
Mkt.RF 0.011372 0.000191 59.48 <2e-16 ***
SMB -0.003070 0.000327 -9.40 <2e-16 ***
HML -0.004997 0.000331 -15.10 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard e
or: 0.00653 on 1754 degrees of freedom
Multiple R-squared: 0.686,    Adjusted R-squared: 0.686
F-statistic: 1.28e+03 on 3 and 1754 DF, p-value: <2e-16
f. Pls make your comments by comparing the results in d and e [1 mark].
Ans:
To comparing the results in D and E we need certain criteria like probability values in the summary statistics or compare the accuracy of the model built, the probability values explain the significance of each variable in the model, while accuracy tells the performance of the model.
    Hence comparing the accuracy we get that model constructed using Stock.Rf on MSFT, MMM, AMZN is better than the model built on Stock.Rf on Mkt.RF, SMB and HML
g. If an investor would like to form a portfolio with a targeted expected return of 0.08% and achieve the minimized standard deviation by investing in these three stocks in the “Stock.csv” file. If the daily risk free rate is 0.02%, what is the Sharpe ratio of this optimal portfolio, given there is no short sale constraint? [1 mark] [hint: can use the li
ary of “quadprog”] [pls provide your R code used to form the optimal portfolio in the end of the word file].
Ans:
mean
MSFT MMM AMZN
50.51 140.80 661.93
cova
MSFT MMM AMZN
MSFT 608 1009 11577
MMM 1009 2048 18540
AMZN 11577 18540 227942
va
MSFT MMM AMZN
608 2048 227942
stdev
MSFT MMM AMZN
24.66 45.26 477.43
ratios
MSFT MMM AMZN
0.7006 1.0729 0.4798
mean.n
MSFT MMM AMZN
6.061 16.896 79.432
cov.n
MSFT MMM AMZN
MSFT 72.96 121.1 1389
MMM 121.07 245.8 2225
AMZN 1389.23 2224.8 27353
print(weights.n)
stock weight
1 MSFT 1
2 MMM 0
3 AMZN ...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here