* stock.do * * Written by Hiro Kasahara, UBC * Last Update: August 30, 2011 * (1) read the data use http://faculty.arts.ubc.ca/hkasahara/Econ325/stock.dta * Data contains monthly stock return for large companies such as IBM, Microsoft, Nissan. * month indicate year/month ranging from 2003/05 to 2008/04 (corresponding to month = 1 to month = 60) * * (2) Compute the summary statistics of stock returns for ibm, microsoft, nissan and SP 500 index summarize ibm microsoft nissan sp500 * Compute the pairwise correlate coefficeint using the Stata command ``pwcorr'' * Help -> Stata Command... -> type ``pwcorr'' to see how to use ``pwcorr'' command * The same result can be replicated by repeatedly applying ``correlate'' for every possible pair pwcorr ibm microsoft nissan sp500 * Graph the time series of stock returns for ibm, microsoft, and SP 500 * Help -> Stata Command... -> type ``line'' to see how to use ``line'' command line ibm month|| line microsoft month || line nissan month || line sp500 month * Compute the mean and the variance of stock portfolios with equal share of ibm and microsoft (50 percent each) generate portfolio_1 = 0.5*ibm + 0.5*microsoft * Compare this portfoloio with SP 500 summarize portfolio_1 sp500 ibm microsoft pwcorr portfolio_1 sp500 ibm microsoft * Verify the formula: Var(aX+bY) = a^2*Var(X) + b^2*Var(Y) + 2*a*b*Cov(X,Y), * where X = ibm, Y = microsoft, a=b=0.5 egen mean_ibm = mean(ibm) egen mean_ms = mean(microsoft) generate mean_ibm_ms = 0.5*mean_ibm + 0.5*mean_ms egen sd_ibm = sd(ibm) egen sd_ms = sd(microsoft) generate var_ibm = sd_ibm*sd_ibm generate var_ms = sd_ms*sd_ms correlate ibm microsoft, covariance * r(cov_12) returns the covariance between ibm and microsoft generate cov_ibm_ms = r(cov_12) generate sd_ibm_ms = sqrt((0.5)^2*var_ibm+(0.5)^2*var_ms+2*(0.5)^2*cov_ibm_ms) *compare mean_ibm_ms and sd_ibm_ms with the sample mean and standard deviation of portfolio_1 summarize mean_ibm_ms sd_ibm_ms portfolio_1 * Compute the mean and the variance of stock portfolios with equal share of ibm, microsoft, and nissan (1/3 each) generate portfolio_2 = (1/3)*ibm + (1/3)*microsoft + (1/3)*nissan * Compare this portfoloio with SP 500 summarize portfolio_1 portfolio_2 sp500 pwcorr portfolio_1 portfolio_2 sp500