Question
Need help on R studio for my Quantitative Methods finance class 1. Download the daily data of SPDR S&P MidCap 400 ETF from July 31
Need help on R studio for my Quantitative Methods finance class
1. Download the daily data of SPDR S&P MidCap 400 ETF from July 31 to August 31 2013, from finance.yahoo.com. The ticker symbol is MDY. Use the column of data corresponding to "Adjusted prices" in the following questions: a) Compute the daily percentage returns for August 2013 b) Use a), compute sample mean, median, volatility, skewness and kurtosis of the daily returns. Comment on your findings. c) Draw histogram AND boxplot based on the returns from a). Comment on your graphs. d) Assuming the risk-free rate is zero, what is the Sharpe ratio of MDY's daily returns in August 2013? e) Assuming the daily returns from a) follow normal distribution, what is its value-at-risk measure at 5% level?
2. Below are the annual rates of return for Merck stock and the S&P 500 from 1989 to 2009. Draw time plot of the annual returns (both time series on the same plot). Compare the returns' time series, and compare the risks and returns for holding Merck versus holding S&P 500 during the sample time period. Comment. Year MRK S&P 500 1989 0.3715 0.2146 1990 0.1854 0.0364 1991 0.8786 0.1243 1992 -0.7338 0.1052 1993 -0.183 0.0858 1994 0.1424 0.02 1995 0.7539 0.1766 1996 0.2353 0.2377 1997 0.3525 0.3027 1998 0.4097 0.2428 1999 -0.5371 0.2228 2000 0.4119 0.0753 2001 -0.3575 -0.1633 2002 -0.0133 -0.1677 2003 -0.1583 -0.0289 2004 -0.272 0.1714 2005 0.0369 0.0677 2006 0.4183 0.0855 2007 0.3674 0.1272 2008 -0.4508 -0.1741 2009 0.2541 -0.2229
3. The Global Positioning System (GPS) used satellites to transit microwave signals that enable enable GPS receivers to determine the exact location of he receiver. Here are the market shares for the major GPS receiver brands sold in the United States. a) What are the variables in the above data? Are they categorical or quantitative variable? b) Use r to display the data in a bar chart as well as in a pie chart.
4. Treasury bills, also known as T-bills, are short-term debt obligation issued by the U.S. Department of the Treasury. The data set, "tbillrates.txt", contains the (annual) interest rates for T-Bills from December 12, 1958, to October 3, 2008. a) Use r to display the data in T-bill interest rates with a histogram b) Use r to display the T-bill rates in a time series plot.
You can see the questions from Page 31-35
Examining Distributions The Normal Distributions Reference: PSBE Chapter 1.3 And: introducing some basic terminologies in Finance. And: Assignment #1 (pp. 31-35) And: introducing R. Objectives Density curves and Normal distributions Density curves Normal distributions and the 68-95-99.7 rule Normal distribution calculations Finding a quantile when given a probability from normal distribution Rate of returns Volatility, Sharpe Ratio, Value-at-Risk Getting started in R Density curves A density curve is a mathematical model of a distribution. The total area under the curve, by definition, is equal to 1, or 100%. The area under the curve for a range of values is the proportion of all observations for that range. Histogram of a sample with the smoothed density curve describing theoretically the population. For continuous random variable: Density curves come in any imaginable shape. Some are well known mathematically and others aren't. The mathematical description of a density curve is called density function. Median and mean of a density curve The median of a density curve is the equal-areas point, the point that divides the area under the curve in half. The mean of a density curve is the balance point, at which the curve would balance if made of solid material. The median and mean are the same for a symmetric density curve. The mean of a skewed curve is pulled in the direction of the long tail. Normal distributions Normalor Gaussiandistributions are a family of symmetrical, bellshaped density curves defined by a mean (mu) and a standard deviation (sigma) : N(,2). Its density function is, 2 1 f (x) = e 2 1 " x % $ ' 2# & x e = 2.71828... The base of the natural logarithm = pi = 3.14159... x A family of density curves Here means are the same ( = 15), whereas standard deviations are different ( = 2, 4, and 6). 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 The first two moments are sufficient to describe a normal random variable (r.v.) 30 Here means are different ( = 10, 15, and 20), whereas standard deviations are the same ( = 3). 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 The 68-95-99.7 rule p About 68% of all observations are within 1 standard deviation () of the mean (). p About 95% of all observations are within 2 of the mean . p Almost all (99.7%) observations are within 3 of the mean. mean = 64.5 standard deviation = 2.5 N(, 2) = N(64.5, 2.52) The standard Normal distribution Because all Normal distributions share the same properties, we can standardize our data to transform any Normal curve N(,2) into the standard Normal curve N(0,1). N(64.5, 2.52) N(0,1) => x Standardized height (no units) For each x we calculate a new value, z (called a z-score). z Standardizing: calculating z-scores A z-score measures the number of standard deviations that a data value x is from the mean . (x ) z= When x is 1 standard deviation larger than the mean, then z = 1. for x = + , z = + = =1 When x is 2 standard deviations larger than the mean, then z = 2. for x = + 2 , z= + 2 2 = =2 When x is larger than the mean, z is positive. When x is smaller than the mean, z is negative. Example: Women heights N(, 2) = N(64.5, 2.52) Women heights follow the N(64.5\Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started