net install http://researchata.com/stata/203/fetchyahookeystats.pkg, force net install http://researchata.com/stata/203/fetchyahooquotes.pkg, force * Create the portfolios * Low dividend yield vs. high dividend yield * ======================================================================== fetchyahookeystats AIV ABBV AEP A AAP AMG keep symbol trailingAnnualDividendYield destring trailingAnnualDividendYield, replace rename trailingAnnualDividendYield dividend_yield drop if dividend_yield == 0 drop if dividend_yield == . gsort -dividend_yield save temp.dta, replace * Compare the two portfolios * ======================================================================== fetchyahooquotes SPY AIV ABBV AEP A AAP AMG, freq(d) chg(ln) start(01jan2020) save temp_div_data.dta, replace use temp_div_data.dta, clear gen obs=_n tsset obs gen ln_port_1 = (ln_AIV / 3) + (ln_ABBV / 3) + (ln_AEP / 3) gen ln_port_2 = (ln_A / 3) + (ln_AAP / 3) + (ln_AMG / 3) save temp.dta, replace use temp.dta, clear collapse (sum) ln* save temp_part1.dta, replace use temp.dta, clear collapse (sd) ln* save temp_part2.dta, replace use temp_part1.dta, clear append using temp_part2.dta xpose, clear varname rename _varname symbol rename v1 return rename v2 sd replace return = return * 100 gen ret_sd = return / sd gsort -ret_sd twoway (scatter return sd, mlabel(symbol)), scale (0.5)