代做ECOM 2001 Term Project帮做R程序

ECOM 2001 Term Project: (Your Assigned Stocks Here)

Your Name Here (Your Student ID here)

Due May 25, 2025 at 23:58 AWST

# 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 intend.

# YOU MUST ONLY USE THE STOCKS ASSIGNED TO YOU

# Any deviation from the assigned stocks will results in a grade of zero.

# 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),

## uncomment the code, and Run

## The beginnig date is January 01,2000

## The ending date is the date you knit and submit your project.

## Please make sure you indicate your submission date in your chunk!

# 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.")

2 The Analysis

2.1 Plot prices over time (4 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:

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 (6 points)

Create a histogram for each of the returns series.

You have to explain your choice of bins. (Hint: Discuss the formula you use to calculate the bins)

2.4 Summary table of returns (5 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? (6 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?

Part 1: Provide details for all 5 steps to conduct a hypothesis test, including the equation for the test statistic. (1 points)

Part 2: Calculate and report all the relevant values for your conclusion and be sure to provide an interpre-tation of the results. (Hint: you will need to repeat the test for expected returns of each asset) (3 points - one for each stock)

Part 3: If you would have done this question using Chat-GPT, what answer will you get? (hints: you will need to describe how you prompt the question in Chat-GPT to guide the answer (1 point), would expect your answer to be different or similar to your answer above (1 point))

## 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 test is one or two tailed, the degrees of freedom, and the p-value.

## (You might wish to present this in a table)

2.6 Are average returns different from each other? (7 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.(2 points)

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.) (3 points)

If you have a chance to engage Chat-GPT, how would you approach this question? That is, you need to clearly lay out ALL STEPS that you would ask the question to Chat-GPT. (1 points)

Now, compare your answer to Chat-GPT, why do you think your answer is different or similar? Please attach a picture of the screenshot of the answer you have got from Chat-GPT. What do you learn from this exercise? (1 points)

## 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

## (include all 5 hypothesis step tests and the equation for the test statistics,

## and a clear interpretation of the result).

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

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

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-visualize-a-correlation-matrix-using-r-software

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-visualize-a-correlation-matrix-using-r-software

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 w1 + 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.

# You can choose to submit hand calculation but please do not deviate from what you

# have learned in the tutorials.





热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图