ECOM 2001 Term Project: (Your Assigned Stocks Here)

Your Name Here (Your Student ID here)

# Include comments in your coding to explain what you are doing.

# You can delete unnecessary comments/hints that I have provided.

# Replace your name, student ID and your three assigned stocks in the YAML.

# Knit frequently to ensure your coding is working and explanations are formatted in the

text as you in

# packages library(tidyquant) # for importing stock data

library(tidyverse) # for working with data

# library(broom) # for tidying output from various statistical procedures library(knitr) # for tables

# library(kableExtra) # for improving the appearance of tables

# Add any additional packages that you use to this code chunk

1 Import the Data (2 points)

## 1) Import your assigned stocks

## Use the package tidyquant. You may need to install this package first.

## Replace Stock1, Stock2, Stock3 with your assigned stock names (in quotation marks),

# yourDataName -c(-Stock1-, -Stock2-,-Stock3-) % %

# tq_get(get = -stock.prices-, from = -2000-01-01-)% %

# select(symbol, date, adjusted)

## This is your data set for this project (rename yourDataName to something more descriptive) output the first 6 rows of your data frame:

# head(yourDataName, n = 6 )% %

# kable(caption = -Your caption.-)

uncomment the co

##

2 The Analysis

2.1 Plot prices over time (3 points)

Plot the prices of each asset over time separately. Succinctly describe in words the evolution of each asset over time. (limit: 100 words for each time series).

## Don't forget to add fig.cap= -Your caption- to the code chunk header.

## facet_wrap() may be useful

2.2 Calculate returns and plot returns over time (4 points)

Calculate the daily percentage returns of each asset using the following formula:

r t = 100 ln * P t

Pt-1

Where Pt is the asset price at time t. Then plot the returns for each asset over time.

## Hint: you need to add a column to your data frame (yourDataName).

## You can use the mutate() function

## Don't forget to group_by()

## The lag() function can be used to find the price in the previous date ##

Double check your results!!

2.3 Histogram of returns (4 points)

Create a histogram for each of the returns series (explain how you determined the number of bins to use).

2.4 Summary table of returns (4 points)

Report the descriptive statistics in a single table which includes the mean, median, variance, standard deviation, skewness and kurtosis for each series. What conclusions can you draw from these descriptive statistics?

## Your summary table here. Be sure to format the table appropriately.

2.5 Are average returns significantly different from zero? (5 points)

Under the assumption that the returns of each asset are drawn from an independently and identically distributed normal distribution, are the expected returns of each asset statistically different from zero at the 1% level of significance? Provide details for all 5 steps to conduct a hypothesis test, including the equation for the test statistic. Calculate and report all the relevant values for your conclusion and be sure to provide an interpretation of the results.

## Hint: you can extract specific values from t.test objects using the $

## Eg. using t.test(x,y)$statistic will extract the value of the test statistic. ##

Consult the help file for the other values generated by the t.test() function.

## The relevant values are: the t-test method, the estimated mean , the test statistic,

whether the te

2.6 Are average returns different from each other? (6 points)

Assume the returns of each asset are independent from each other. With this assumption, are the mean returns statistically different from each other at the 1% level of significance? Provide details for all 5 steps to conduct each of the hypothesis tests using what your have learned in the unit. Calculate and report all the relevant values for your conclusion and be sure to provide and interpretation of the results. (Hint: You need to discuss the equality of variances to determine which type of test to use.)

## Decide on which test is appropriate for testing differences in mean returns

## Hint: Include the results of your supporting test for the differences in variances (

## Hint: http://www.sthda.com/english/wiki/one-way-anova-test-in-r

## So this section has (at least) 2 significance tests.

include all 5 hy

2.7 Correlations (2 points)

Calculate and present the correlation matrix of the returns. Discuss the direction and strength of the correlations.

## Include a formatted correlation matrix here

## Hint: http://www.sthda.com/english/wiki/correlation-matrix-a-quick-start-guide-to-analyze

-format-and

2.8 Testing the significance of correlations (2 points)

Is the assumption of independence of stock returns realistic? Provide evidence (the hypothesis test including all 5 steps of the hypothesis test and the equation for the test statistic) and a rationale to support your conclusion.

## Report the results of tests for statistical significance of the correlations here.

## Hint: http://www.sthda.com/english/wiki/correlation-matrix-a-quick-start-guide-to-analyze

-format-and

2.9 Advising an investor (12 points)

Suppose that an investor has asked you to assist them in choosing two of these three stocks to include in their portfolio. The portfolio is defined by

r = w1r1 + w2r2

Where r1 and r2 represent the returns from the first and second stock, respectively, and w1 and w2 represent the proportion of the investment placed in each stock. The entire investment is allocated between the two stocks, so w + 1 + w2 = 1.

The investor favours the combination of stocks that provides the highest return, but dislikes risk. Thus the investor’s happiness is a function of the portfolio, r:

h(r) = E(r) - Var(r)

Where E(r) is the expected return of the portfolio, and Var(r) is the variance of the portfolio.

Given your values for E(r1), E(r2), Var(r1), Var(r2) and Cov(r1, r2) which portfolio would you recommend to the investor? What is the expected return to this portfolio?

Provide evidence to support your answer, including all the steps undertaken to arrive at the result. (*Hint: review your notes from tutorial 6 on portfolio optimisation. A complete answer will include the optimal weights for each possible portfolio (pair of stocks) and the expected return for each of these portfolios.)

# You can use this section to create a table of your results.

2.10 The impact of financial events on returns (6 points)

Two significant financial events have occurred in recent history. On September 15, 2008 Lehman Brothers declared bankruptcy and a Global Financial Crisis started. On March 11, 2020 the WHO declared COVID-19 a pandemic. Use linear regression to determine if

a. Any of the stocks in your data exhibit positive returns over time.

b. Either of the two events had a significant impact on returns.

Report the regression output for each stock and interpret the results to address these two questions. How would you interpret this information in the context of your chosen portfolio?

## Add a column to your returns data set.

## This is a factor variable with three levels:

## 'Lehman Bankruptcy' for the date 2008-09-15,

## 'Pandemic' for the date 2020-03-11, and

## 'BAU' (Business as usual) for all other dates.

## Then run a regression analysis to determine whether returns to each stock are increasing

over time a

Your Name Here (Your Student ID here)

# Include comments in your coding to explain what you are doing.

# You can delete unnecessary comments/hints that I have provided.

# Replace your name, student ID and your three assigned stocks in the YAML.

# Knit frequently to ensure your coding is working and explanations are formatted in the

text as you in

# packages library(tidyquant) # for importing stock data

library(tidyverse) # for working with data

# library(broom) # for tidying output from various statistical procedures library(knitr) # for tables

# library(kableExtra) # for improving the appearance of tables

# Add any additional packages that you use to this code chunk

1 Import the Data (2 points)

## 1) Import your assigned stocks

## Use the package tidyquant. You may need to install this package first.

## Replace Stock1, Stock2, Stock3 with your assigned stock names (in quotation marks),

# yourDataName -c(-Stock1-, -Stock2-,-Stock3-) % %

# tq_get(get = -stock.prices-, from = -2000-01-01-)% %

# select(symbol, date, adjusted)

## This is your data set for this project (rename yourDataName to something more descriptive) output the first 6 rows of your data frame:

# head(yourDataName, n = 6 )% %

# kable(caption = -Your caption.-)

uncomment the co

##

2 The Analysis

2.1 Plot prices over time (3 points)

Plot the prices of each asset over time separately. Succinctly describe in words the evolution of each asset over time. (limit: 100 words for each time series).

## Don't forget to add fig.cap= -Your caption- to the code chunk header.

## facet_wrap() may be useful

2.2 Calculate returns and plot returns over time (4 points)

Calculate the daily percentage returns of each asset using the following formula:

r t = 100 ln * P t

Pt-1

Where Pt is the asset price at time t. Then plot the returns for each asset over time.

## Hint: you need to add a column to your data frame (yourDataName).

## You can use the mutate() function

## Don't forget to group_by()

## The lag() function can be used to find the price in the previous date ##

Double check your results!!

2.3 Histogram of returns (4 points)

Create a histogram for each of the returns series (explain how you determined the number of bins to use).

2.4 Summary table of returns (4 points)

Report the descriptive statistics in a single table which includes the mean, median, variance, standard deviation, skewness and kurtosis for each series. What conclusions can you draw from these descriptive statistics?

## Your summary table here. Be sure to format the table appropriately.

2.5 Are average returns significantly different from zero? (5 points)

Under the assumption that the returns of each asset are drawn from an independently and identically distributed normal distribution, are the expected returns of each asset statistically different from zero at the 1% level of significance? Provide details for all 5 steps to conduct a hypothesis test, including the equation for the test statistic. Calculate and report all the relevant values for your conclusion and be sure to provide an interpretation of the results.

## Hint: you can extract specific values from t.test objects using the $

## Eg. using t.test(x,y)$statistic will extract the value of the test statistic. ##

Consult the help file for the other values generated by the t.test() function.

## The relevant values are: the t-test method, the estimated mean , the test statistic,

whether the te

2.6 Are average returns different from each other? (6 points)

Assume the returns of each asset are independent from each other. With this assumption, are the mean returns statistically different from each other at the 1% level of significance? Provide details for all 5 steps to conduct each of the hypothesis tests using what your have learned in the unit. Calculate and report all the relevant values for your conclusion and be sure to provide and interpretation of the results. (Hint: You need to discuss the equality of variances to determine which type of test to use.)

## Decide on which test is appropriate for testing differences in mean returns

## Hint: Include the results of your supporting test for the differences in variances (

## Hint: http://www.sthda.com/english/wiki/one-way-anova-test-in-r

## So this section has (at least) 2 significance tests.

include all 5 hy

2.7 Correlations (2 points)

Calculate and present the correlation matrix of the returns. Discuss the direction and strength of the correlations.

## Include a formatted correlation matrix here

## Hint: http://www.sthda.com/english/wiki/correlation-matrix-a-quick-start-guide-to-analyze

-format-and

2.8 Testing the significance of correlations (2 points)

Is the assumption of independence of stock returns realistic? Provide evidence (the hypothesis test including all 5 steps of the hypothesis test and the equation for the test statistic) and a rationale to support your conclusion.

## Report the results of tests for statistical significance of the correlations here.

## Hint: http://www.sthda.com/english/wiki/correlation-matrix-a-quick-start-guide-to-analyze

-format-and

2.9 Advising an investor (12 points)

Suppose that an investor has asked you to assist them in choosing two of these three stocks to include in their portfolio. The portfolio is defined by

r = w1r1 + w2r2

Where r1 and r2 represent the returns from the first and second stock, respectively, and w1 and w2 represent the proportion of the investment placed in each stock. The entire investment is allocated between the two stocks, so w + 1 + w2 = 1.

The investor favours the combination of stocks that provides the highest return, but dislikes risk. Thus the investor’s happiness is a function of the portfolio, r:

h(r) = E(r) - Var(r)

Where E(r) is the expected return of the portfolio, and Var(r) is the variance of the portfolio.

Given your values for E(r1), E(r2), Var(r1), Var(r2) and Cov(r1, r2) which portfolio would you recommend to the investor? What is the expected return to this portfolio?

Provide evidence to support your answer, including all the steps undertaken to arrive at the result. (*Hint: review your notes from tutorial 6 on portfolio optimisation. A complete answer will include the optimal weights for each possible portfolio (pair of stocks) and the expected return for each of these portfolios.)

# You can use this section to create a table of your results.

2.10 The impact of financial events on returns (6 points)

Two significant financial events have occurred in recent history. On September 15, 2008 Lehman Brothers declared bankruptcy and a Global Financial Crisis started. On March 11, 2020 the WHO declared COVID-19 a pandemic. Use linear regression to determine if

a. Any of the stocks in your data exhibit positive returns over time.

b. Either of the two events had a significant impact on returns.

Report the regression output for each stock and interpret the results to address these two questions. How would you interpret this information in the context of your chosen portfolio?

## Add a column to your returns data set.

## This is a factor variable with three levels:

## 'Lehman Bankruptcy' for the date 2008-09-15,

## 'Pandemic' for the date 2020-03-11, and

## 'BAU' (Business as usual) for all other dates.

## Then run a regression analysis to determine whether returns to each stock are increasing

over time a

DescriptionIn this assessment, you are required to demonstrate that you understand how an Older Adult can develop mental health problems associated with cognitive decline leading to cognitive impairment...School of Engineering, Design and Built EnvironmentENGR7008 Fire Engineering Design and AssessmentAssignment 4: Peer Review of Fire Engineering ReportASSIGNMENT 4PEER REVIEW OF A FIRE ENGINEERING REPORTSee...Structural Analysis Etask 5The aim of this assessment task is to evaluate the appropriate use of the Force Method and Moment Distribution Method for structural analysis• Please download the eTask4 from...Purpose:The purpose of this task is for the student to demonstrate how to create a holistic plan of care that is person-centred, trauma-informed, and recovery-oriented in focus.Description:In this written...Assessment Plan The following outlines the assessment requirements for this cluster. You are required to complete all assessment requirements outlined below to achieve competency for this all units in...Structural Analysis Etask 4The aim of this assessment task is to evaluate the appropriate use of the Moment Distribution Method for structural analysis• Please download the eTask4 from Canvas. The students...ASSESSMENT OVERVIEWAssessment Number: Report 4: SystemsAssignment Type: ReportWeighting: 15%Word Count: 2,5000 WORDS (+/- 10%)ASSESSMENT OBJECTIVESThis assessment is designed to help you achieve the following...**Show All Questions**