Risk Modelling Project

Lecture 3 – Portfolio Returns
Dr. Martin A. Negron
ANLY 515

Portfolio Returns

A portfolio’s return is simply the weighted-average return of the securities in the portfolio with the weights give by the amount of money invested in each security.

Two approaches

Long way – all steps are laid out
Matrix algebra – used for mean-variance optimization across multiple securities

Packages

xts
quantmod

Constructing Portfolio Returns (Long Way)

A portfolio’s return is the weighted-average of the returns of the individual securities in the portfolio with the weight calculated as the percentage invested in that security relative to the total amount invested in the portfolio.

rp: portfolio return

I: dollar amount invested

percentage invested represents the weight (w)

Constructing Portfolio Returns (Long Way)

Find First and Last Adjusted Closing Price for each security over the investment period (use data from previous lectures: AMZN, AAPL, GSPC, IBM)

Investment period: December 31, 2010 to December 31, 2013

Use “multi” from previous lecture

AMZN.Adjusted GSPC.Adjusted AAPL.Adjusted IBM.Adjusted
2010-12-31 180.00 1257.64 39.99933 106.9668
2011-01-03 184.22 1271.87 40.86861 107.4916
2011-01-04 185.01 1270.20 41.08190 107.6082
2013-12-30 393.37 1841.07 71.11713 143.2158

Define “period.ret” as the observtions for December 31, 2010 and December 30, 2013.

period.ret <- multi[c(1,nrow(multi)),] period.ret AMZN.Adjusted GSPC.Adjusted AAPL.Adjusted IBM.Adjusted 2010-12-31 180.00 1257.64 39.99933 106.9668 2013-12-30 393.37 1841.07 71.11713 143.2158 Constructing Portfolio Returns (Long Way) Calculate returns for each security over the investment period Since there are only two observations in “rets”, the Delt command can be used. “lapply” is used to apply “delt” to all four securities rets <- lapply(period.ret,Delt) rets $AMZN.Adjusted Delt.1.arithmetic 2010-12-31 NA 2013-12-30 1.185389 $GSPC.Adjusted Delt.1.arithmetic 2010-12-31 NA 2013-12-30 0.4639085 $AAPL.Adjusted Delt.1.arithmetic 2010-12-31 NA 2013-12-30 0.7779578 $IBM.Adjusted Delt.1.arithmetic 2010-12-31 NA 2013-12-30 0.3388808 Constructing Portfolio Returns (Long Way) Convert to a data.frame and clean up data (since is currently a list object) rets <- data.frame(rets) rets Delt.1.arithmetic Delt.1.arithmetic.1 Delt.1.arithmetic.2 2010-12-31 NA NA NA 2013-12-30 1.185389 0.4639085 0.7779578 Delt.1.arithmetic.3 2010-12-31 NA 2013-12-30 0.3388808 Remove NA's and convert to percentages rets <- rets[2,]*100 names(rets) <- paste(c("AMZN","GSPC","APPL","IBM")) rets AMZN GSPC APPL IBM 2013-12-30 118.5389 46.39085 77.79578 33.88808 Constructing Portfolio Returns (Long Way) Calculate weight of each security in the portfolio Create variables representing the dollar amount of investment in each security Calculate the weight by dividing the amount invested by the total investment ($100k) i.AMZN <- 50000 i.GSPC <- 10000 i.APPL <- 30000 i.IBM <- 10000 Constructing Portfolio Returns (Long Way) Calculate weight of each security in the portfolio (cont.) w.AMZN <- i.AMZN/(i.AMZN+i.GSPC+i.APPL+i.IBM) w.AMZN [1] 0.5 w.GSPC <- i.GSPC/(i.AMZN+i.GSPC+i.APPL+i.IBM) w.GSPC [1] 0.1 w.APPL <- i.APPL/(i.AMZN+i.GSPC+i.APPL+i.IBM) w.APPL [1] 0.3 w.IBM <- i.IBM/(i.AMZN+i.GSPC+i.APPL+i.IBM) w.IBM [1] 0.1 Constructing Portfolio Returns (Long Way) Calculate portfolio return (weights x return) port.ret.4asset <- w.AMZN*rets$AMZN+w.GSPC*rets$GSPC+w.APPL*rets$APPL+w.IBM*rets$IBM port.ret.4asset [1] 90.63607 Constructing Portfolio Returns (Matrix Algebra) The calculation requires two vectors (used for larger number of securities): Vector of weights - matrix with one row (50% AMZN, 10% GSPC, 30% APPL, 10% IBM) Column vector of returns (using c(…) and matrix command) wgt <- c(0.5,0.1,0.3,0.1) mat.wgt <- matrix(wgt,1) mat.wgt [,1] [,2] [,3] [,4] [1,] 0.5 0.1 0.3 0.1 ret <- c(rets$AMZN,rets$GSPC,rets$APPL,rets$IBM) mat.ret <- matrix(ret,4) mat.ret [,1] [1,] 118.53889 [2,] 46.39085 [3,] 77.79578 [4,] 33.88808 Constructing Portfolio Returns (Matrix Algebra) Calculate portfolio returns by multiplying the row vector times the column vector using the matrix mutiplication operator port.ret <- mat.wgt %*% mat.ret port.ret [,1] [1,] 90.63607 Constructing Benchmark Portfolio Returns The benchmark is used to compare against a portfolio in order to measure performance. Typically, a performance index is used as the benchmark (S&P 500). This section describes how to create an equally-weighted (EW) index and value-weighted (VW) index. Constructing Benchmark Portfolio Returns The objective is to create a hypothetical EW and VW portfolio consisting of AMZN, APPL and IBM using returns in 2013. Create object with only the relevant data port <- data.AMZN[,c(4,5)] port <- merge(port,data.AAPL[,c(4,5)]) port <- merge(port,data.IBM[,c(4,5)]) port[c(1:3,nrow(port)),] AMZN.Close AMZN.Adjusted AAPL.Close AAPL.Adjusted IBM.Close 2010-12-31 180.00 180.00 46.08000 39.99933 146.76 2011-01-03 184.22 184.22 47.08143 40.86861 147.48 2011-01-04 185.01 185.01 47.32715 41.08190 147.64 2013-12-30 393.37 393.37 79.21714 71.11713 186.41 IBM.Adjusted 2010-12-31 106.9668 2011-01-03 107.4916 2011-01-04 107.6082 2013-12-30 143.2158 Constructing Benchmark Portfolio Returns Calculate total returns of each security using the adjusted close prices port$AMZN.ret <- Delt(port$AMZN.Adjusted) port$AAPL.ret <- Delt(port$AAPL.Adjusted) port$IBM.ret <- Delt(port$IBM.Adjusted) port[c(1:3,nrow(port)),] AMZN.Close AMZN.Adjusted AAPL.Close AAPL.Adjusted IBM.Close 2010-12-31 180.00 180.00 46.08000 39.99933 146.76 2011-01-03 184.22 184.22 47.08143 40.86861 147.48 2011-01-04 185.01 185.01 47.32715 41.08190 147.64 2013-12-30 393.37 393.37 79.21714 71.11713 186.41 IBM.Adjusted AMZN.ret AAPL.ret IBM.ret 2010-12-31 106.9668 NA NA NA 2011-01-03 107.4916 0.023444450 0.021732238 0.004906082 2011-01-04 107.6082 0.004288318 0.005219116 0.001085015 2013-12-30 143.2158 -0.011831773 -0.009944364 0.007186204 Constructing Benchmark Portfolio Returns Convert to data.frame object and subset data from Dec 31, 2012 to Dec 31, 2013 leaving the Dec 31, 2010 data in because it will be used for later calculations. port <- cbind(data.frame(index(port)), data.frame(port)) names(port)[1] <- paste("date") port[c(1:3,nrow(port)),] date AMZN.Close AMZN.Adjusted AAPL.Close AAPL.Adjusted 2010-12-31 2010-12-31 180.00 180.00 46.08000 39.99933 2011-01-03 2011-01-03 184.22 184.22 47.08143 40.86861 2011-01-04 2011-01-04 185.01 185.01 47.32715 41.08190 2013-12-30 2013-12-30 393.37 393.37 79.21714 71.11713 IBM.Close IBM.Adjusted AMZN.ret AAPL.ret IBM.ret 2010-12-31 146.76 106.9668 NA NA NA 2011-01-03 147.48 107.4916 0.023444450 0.021732238 0.004906082 2011-01-04 147.64 107.6082 0.004288318 0.005219116 0.001085015 2013-12-30 186.41 143.2158 -0.011831773 -0.009944364 0.007186204 ports <- subset(port, port$date >= “2012-12-31” &
port$date <= "2013-12-31") Constructing Benchmark Portfolio Returns Convert to data.frame object and subset data from Dec 31, 2012 to Dec 31, 2013 leaving the Dec 31, 2010 data in because it will be used for later calculations. port <- subset(port, port$date >= “2012-12-31” &
port$date <= "2013-12-30") port[c(1:3,nrow(port)),] date AMZN.Close AMZN.Adjusted AAPL.Close AAPL.Adjusted 2012-12-31 2012-12-31 250.87 250.87 76.02428 66.57822 2013-01-02 2013-01-02 257.31 257.31 78.43285 68.68754 2013-01-03 2013-01-03 258.48 258.48 77.44286 67.82053 2013-12-30 2013-12-30 393.37 393.37 79.21714 71.11713 IBM.Close IBM.Adjusted AMZN.ret AAPL.ret IBM.ret 2012-12-31 191.55 144.3634 0.023207448 0.044310130 0.009060745 2013-01-02 196.35 147.9810 0.025670679 0.031681849 0.025058760 2013-01-03 195.27 147.1670 0.004547095 -0.012622552 -0.005500672 2013-12-30 186.41 143.2158 -0.011831773 -0.009944364 0.007186204 This will be the benchmark portfolio Equal-Weighted Portfolio Equal-weight to small firms and large firms Example: S&P 500 Equal Weight Index The indexes are balanced quarterly which means that in between quarters the constituent weights are allowed to fluctuate based on their performance. On each rebalancing date, the weights of each firm is set to reset to 1/N (number of securities in the portfolio) Equal-Weighted Portfolio Keep only variables we need to construct EW portfolio (AMZN,AAPL, IBM) To make calling in the variables easier, rename the return variables to only be the tickers. Also, renumber the index to denote the observation number. ewport <- port[c(1,8:10)] ewport[c(1:3,nrow(ewport)),] date AMZN.ret AAPL.ret IBM.ret 2012-12-31 2012-12-31 0.023207448 0.044310130 0.009060745 2013-01-02 2013-01-02 0.025670679 0.031681849 0.025058760 2013-01-03 2013-01-03 0.004547095 -0.012622552 -0.005500672 2013-12-30 2013-12-30 -0.011831773 -0.009944364 0.007186204 names(ewport) <- paste(c("date","AMZN","AAPL","IBM")) rownames(ewport) <- seq(1:nrow(ewport)) ewport[c(1:3,nrow(ewport)),] date AMZN AAPL IBM 1 2012-12-31 0.023207448 0.044310130 0.009060745 2 2013-01-02 0.025670679 0.031681849 0.025058760 3 2013-01-03 0.004547095 -0.012622552 -0.005500672 252 2013-12-30 -0.011831773 -0.009944364 0.007186204 Equal-Weighted Portfolio Convert the data to gross returns, by adding one to each security's returns. To reduce the number of variables overwrite the net return series ewport$AMZN <- 1+ewport$AMZN ewport$AAPL <- 1+ewport$AAPL ewport$IBM <- 1+ewport$IBM ewport[c(1:3,nrow(ewport)),] date AMZN AAPL IBM 1 2012-12-31 1.0232074 1.0443101 1.0090607 2 2013-01-02 1.0256707 1.0316818 1.0250588 3 2013-01-03 1.0045471 0.9873774 0.9944993 252 2013-12-30 0.9881682 0.9900556 1.0071862 Equal-Weighted Portfolio Calculate EW portfolio values for 1Q 2013 ew.q1 <- subset(ewport, ewport$date >= as.Date(“2012-12-31”) &
ewport$date <= as.Date("2013-03-31")) ew.q1[c(1:3,nrow(ew.q1)),] date AMZN AAPL IBM 1 2012-12-31 1.023207 1.0443101 1.0090607 2 2013-01-02 1.025671 1.0316818 1.0250588 3 2013-01-03 1.004547 0.9873774 0.9944993 61 2013-03-28 1.004485 0.9791631 1.0114278 Equal-Weighted Portfolio Calculate EW portfolio values for 1Q 2013 (cont.) The return on Dec. 31, 2012 is not used (it is used as a placeholder used later for indexing for each security at $1) Overwrite return on Dec. 31, 2012 (for each security) to 1.00 ew.q1[1,2:4]<-1 ew.q1$AMZN <- cumprod(ew.q1$AMZN) ew.q1$AAPL <- cumprod(ew.q1$AAPL) ew.q1$IBM <- cumprod(ew.q1$IBM) ew.q1[c(1:3,nrow(ew.q1)),] date AMZN AAPL IBM 1 2012-12-31 1.000000 1.0000000 1.000000 2 2013-01-02 1.025671 1.0316818 1.025059 3 2013-01-03 1.030335 1.0186594 1.019420 61 2013-03-28 1.062263 0.8366496 1.118234 Equal-Weighted Portfolio Calculate EW portfolio values for 1Q 2013 (cont.) Create a variable to denote the number of securities in the portfoliothat can be used for each quarterly calculation. num.sec <- 3 Equal-Weighted Portfolio Calculate the index value for each security during the quarter ew.q1$AMZN.idx <- (1/num.sec)*ew.q1$AMZN ew.q1$AAPL.idx <- (1/num.sec)*ew.q1$AAPL ew.q1$IBM.idx <- (1/num.sec)*ew.q1$IBM ew.q1[c(1:3,nrow(ew.q1)),] date AMZN AAPL IBM AMZN.idx AAPL.idx IBM.idx 1 2012-12-31 1.000000 1.0000000 1.000000 0.3333333 0.3333333 0.3333333 2 2013-01-02 1.025671 1.0316818 1.025059 0.3418902 0.3438939 0.3416863 3 2013-01-03 1.030335 1.0186594 1.019420 0.3434448 0.3395531 0.3398067 61 2013-03-28 1.062263 0.8366496 1.118234 0.3540878 0.2788832 0.3727448 Equal-Weighted Portfolio Calculate the index value for each security during the quarter The value of a portfolio is equal to the value of the components. To calculate the value of the EW portfolio on each day, sum the values of the three index variables. q1.val <- data.frame(rowSums(ew.q1[,5:7])) q1.val[c(1:3,nrow(q1.val)),] [1] 1.000000 1.027470 1.022805 1.005716 names(q1.val) <- paste("port.val") q1.val$date <- ew.q1$date q1.val[c(1:3,nrow(q1.val)),] port.val date 1 1.000000 2012-12-31 2 1.027470 2013-01-02 3 1.022805 2013-01-03 61 1.005716 2013-03-28 Equal-Weighted Portfolio Calculate the index value for each security during the quarter q1.val holds the portfolio values for the first quarter q2.inv holds the aggregate portfolio value at the end of Q1 q2.inv will be redistributed equally among three stocks at the beginning of the second quarter q2.inv <- q1.val[nrow(q1.val),1] q2.inv [1] 1.005716 The value of 1.006 is used at the beginning of the seconf quarter instead of 1.00 Equal-Weighted Portfolio Calculate the EW portfolio value for 2Q 2013 (similar steps) ew.q2 <- subset(ewport, ewport$date >= as.Date(“2013-04-01”) &
ewport$date <= as.Date("2013-06-30")) ew.q2[c(1:3,nrow(ew.q2)),] date AMZN AAPL IBM 62 2013-04-01 0.9816878 0.9689378 0.9956870 63 2013-04-02 1.0065365 1.0020517 1.0093229 64 2013-04-03 0.9837080 1.0051189 0.9920694 125 2013-06-28 1.0005045 1.0069835 0.9767953 Equal-Weighted Portfolio Calculate the EW portfolio value for 2Q 2013 (similar steps) ew.q2$AMZN <- cumprod(ew.q2$AMZN) ew.q2$AAPL <- cumprod(ew.q2$AAPL) ew.q2$IBM <- cumprod(ew.q2$IBM) ew.q2[c(1:3,nrow(ew.q2)),] date AMZN AAPL IBM 62 2013-04-01 0.9816878 0.9689378 0.9956870 63 2013-04-02 0.9881047 0.9709258 1.0049696 64 2013-04-03 0.9720065 0.9758958 0.9969996 125 2013-06-28 1.0420279 0.9017184 0.9001677 Equal-Weighted Portfolio Calculate the EW portfolio value for 2Q 2013 (similar steps) ew.q2$AMZN.idx <- (q2.inv/num.sec)*ew.q2$AMZN ew.q2$AAPL.idx <- (q2.inv/num.sec)*ew.q2$AAPL ew.q2$IBM.idx <- (q2.inv/num.sec)*ew.q2$IBM ew.q2[c(1:3,nrow(ew.q2)),] date AMZN AAPL IBM AMZN.idx AAPL.idx IBM.idx 62 2013-04-01 0.9816878 0.9689378 0.9956870 0.3290997 0.3248253 0.3337927 63 2013-04-02 0.9881047 0.9709258 1.0049696 0.3312508 0.3254918 0.3369046 64 2013-04-03 0.9720065 0.9758958 0.9969996 0.3258541 0.3271579 0.3342327 125 2013-06-28 1.0420279 0.9017184 0.9001677 0.3493280 0.3022908 0.3017709 Equal-Weighted Portfolio Calculate the EW portfolio value for 2Q 2013 (similar steps) q2.val <- data.frame(rowSums(ew.q2[,5:7])) q2.val[c(1:3,nrow(q2.val)),] [1] 0.9877177 0.9936472 0.9872448 0.9533897 Equal-Weighted Portfolio Calculate the EW portfolio value for 2Q 2013 (similar steps) names(q2.val) <- paste("port.val") q2.val$date <- ew.q2$date q2.val[c(1:3,nrow(q2.val)),] port.val date 62 0.9877177 2013-04-01 63 0.9936472 2013-04-02 64 0.9872448 2013-04-03 125 0.9533897 2013-06-28 q3.inv <- q2.val[nrow(q2.val),1] q3.inv [1] 0.9533897 The portfolio is not performing well Equal-Weighted Portfolio Calculate the EW portfolio value for 3Q 2013 (similar steps) ew.q3 <- subset(ewport, ewport$date >= as.Date(“2013-07-01”) &
ewport$date <= as.Date("2013-09-30")) ew.q3[c(1:3,nrow(ew.q3)),] date AMZN AAPL IBM 126 2013-07-01 1.0158810 1.0320027 1.0008896 127 2013-07-02 1.0057781 1.0226527 1.0011505 128 2013-07-03 1.0010573 1.0055197 1.0091380 189 2013-09-30 0.9893358 0.9875709 0.9906913 Equal-Weighted Portfolio Calculate the EW portfolio value for 3Q 2013 (similar steps) ew.q3$AMZN <- cumprod(ew.q3$AMZN) ew.q3$AAPL <- cumprod(ew.q3$AAPL) ew.q3$IBM <- cumprod(ew.q3$IBM) ew.q3[c(1:3,nrow(ew.q3)),] date AMZN AAPL IBM 126 2013-07-01 1.015881 1.032003 1.0008896 127 2013-07-02 1.021751 1.055380 1.0020411 128 2013-07-03 1.022831 1.061206 1.0111977 189 2013-09-30 1.125860 1.210243 0.9738148 Equal-Weighted Portfolio Calculate the EW portfolio value for 3Q 2013 (similar steps) ew.q3$AMZN.idx <- (q3.inv/num.sec)*ew.q3$AMZN ew.q3$AAPL.idx <- (q3.inv/num.sec)*ew.q3$AAPL ew.q3$IBM.idx <- (q3.inv/num.sec)*ew.q3$IBM ew.q3[c(1:3,nrow(ew.q3)),] date AMZN AAPL IBM AMZN.idx AAPL.idx IBM.idx 126 2013-07-01 1.015881 1.032003 1.0008896 0.3228435 0.3279669 0.3180793 127 2013-07-02 1.021751 1.055380 1.0020411 0.3247089 0.3353963 0.3184452 128 2013-07-03 1.022831 1.061206 1.0111977 0.3250522 0.3372476 0.3213552 189 2013-09-30 1.125860 1.210243 0.9738148 0.3577944 0.3846111 0.3094750 Equal-Weighted Portfolio Calculate the EW portfolio value for 3Q 2013 (similar steps) q3.val <- data.frame(rowSums(ew.q3[,5:7])) q3.val[c(1:3,nrow(q3.val)),] [1] 0.9688897 0.9785504 0.9836550 1.0518805 Equal-Weighted Portfolio Calculate the EW portfolio value for 3Q 2013 (similar steps) names(q3.val) <- paste("port.val") q3.val$date <- ew.q3$date q3.val[c(1:3,nrow(q3.val)),] port.val date 126 0.9688897 2013-07-01 127 0.9785504 2013-07-02 128 0.9836550 2013-07-03 189 1.0518805 2013-09-30 q4.inv <- q3.val[nrow(q3.val),1] q4.inv [1] 1.051881 The portfolio is improving Equal-Weighted Portfolio Calculate the EW portfolio value for 4Q 2013 (similar steps) ew.q4 <- subset(ewport, ewport$date >= as.Date(“2013-10-01”) &
ewport$date <= as.Date("2013-12-31")) ew.q4[c(1:3,nrow(ew.q4)),] date AMZN AAPL IBM 190 2013-10-01 1.0265801 1.0235134 1.0064802 191 2013-10-02 0.9986291 1.0032790 0.9923809 192 2013-10-03 0.9820598 0.9874378 0.9940527 252 2013-12-30 0.9881682 0.9900556 1.0071862 Equal-Weighted Portfolio Calculate the EW portfolio value for 4Q 2013 (similar steps) ew.q4$AMZN <- cumprod(ew.q4$AMZN) ew.q4$AAPL <- cumprod(ew.q4$AAPL) ew.q4$IBM <- cumprod(ew.q4$IBM) ew.q4[c(1:3,nrow(ew.q4)),] date AMZN AAPL IBM 190 2013-10-01 1.026580 1.023513 1.0064802 191 2013-10-02 1.025173 1.026870 0.9988117 192 2013-10-03 1.006781 1.013970 0.9928715 252 2013-12-30 1.258220 1.169916 1.0120480 Equal-Weighted Portfolio Calculate the EW portfolio value for 4Q 2013 (similar steps) ew.q4$AMZN.idx <- (q4.inv/num.sec)*ew.q4$AMZN ew.q4$AAPL.idx <- (q4.inv/num.sec)*ew.q4$AAPL ew.q4$IBM.idx <- (q4.inv/num.sec)*ew.q4$IBM ew.q4[c(1:3,nrow(ew.q4)),] date AMZN AAPL IBM AMZN.idx AAPL.idx IBM.idx 190 2013-10-01 1.026580 1.023513 1.0064802 0.3599465 0.3588713 0.3528990 191 2013-10-02 1.025173 1.026870 0.9988117 0.3594531 0.3600480 0.3502102 192 2013-10-03 1.006781 1.013970 0.9928715 0.3530044 0.3555250 0.3481274 252 2013-12-30 1.258220 1.169916 1.0120480 0.4411658 0.4102041 0.3548512 Equal-Weighted Portfolio Calculate the EW portfolio value for 4Q 2013 (similar steps) q4.val <- data.frame(rowSums(ew.q4[,5:7])) q4.val[c(1:3,nrow(q4.val)),] [1] 1.071717 1.069711 1.056657 1.206221 Equal-Weighted Portfolio Calculate the EW portfolio value for 4Q 2013 (similar steps) names(q4.val) <- paste("port.val") q4.val$date <- ew.q4$date q4.val[c(1:3,nrow(q4.val)),] port.val date 190 1.071717 2013-10-01 191 1.069711 2013-10-02 192 1.056657 2013-10-03 252 1.206221 2013-12-30 The portfolio is improving Equal-Weighted Portfolio Combine quarterly EW portfolio values into one data object (ew.portval) ew.portval <- rbind(q1.val,q2.val,q3.val,q4.val) ew.portval[c(1:3,nrow(ew.portval)),] port.val date 1 1.000000 2012-12-31 2 1.027470 2013-01-02 3 1.022805 2013-01-03 252 1.206221 2013-12-30 Please note that this calculations do not include transactions costs incurred during each Q rebalancing. Value-Weighted Portfolio Some of the major indexes use some form of value-weighting, such as the S&P 500 Index. In a VW portfolio the returns of larger firms are given more weight. Rebalance at the start of each quarter using the prior quarter end's capitalization data. Value-Weighted Portfolio Keep only the variables needed to construct the VW portfolio vwport <- port[,c(1,2,4,6,8:10)] vwport[c(1:3,nrow(vwport)),] date AMZN.Close AAPL.Close IBM.Close AMZN.ret AAPL.ret 2012-12-31 2012-12-31 250.87 76.02428 191.55 0.023207448 0.044310130 2013-01-02 2013-01-02 257.31 78.43285 196.35 0.025670679 0.031681849 2013-01-03 2013-01-03 258.48 77.44286 195.27 0.004547095 -0.012622552 2013-12-30 2013-12-30 393.37 79.21714 186.41 -0.011831773 -0.009944364 IBM.ret 2012-12-31 0.009060745 2013-01-02 0.025058760 2013-01-03 -0.005500672 2013-12-30 0.007186204 Value-Weighted Portfolio Date already available, the index of vwport can be changed to an indicator of the observation number rownames(vwport) <- seq(1:nrow(vwport)) vwport[c(1:3,nrow(vwport)),] date AMZN.Close AAPL.Close IBM.Close AMZN.ret AAPL.ret 1 2012-12-31 250.87 76.02428 191.55 0.023207448 0.044310130 2 2013-01-02 257.31 78.43285 196.35 0.025670679 0.031681849 3 2013-01-03 258.48 77.44286 195.27 0.004547095 -0.012622552 252 2013-12-30 393.37 79.21714 186.41 -0.011831773 -0.009944364 IBM.ret 1 0.009060745 2 0.025058760 3 -0.005500672 252 0.007186204 Value-Weighted Portfolio Converting Net Returns to Gross Returns vwport$AMZN.ret <- 1+vwport$AMZN.ret vwport$AAPL.ret <- 1+vwport$AAPL.ret vwport$IBM.ret <- 1+vwport$IBM.ret vwport[c(1:3,nrow(vwport)),] date AMZN.Close AAPL.Close IBM.Close AMZN.ret AAPL.ret IBM.ret 1 2012-12-31 250.87 76.02428 191.55 1.0232074 1.0443101 1.0090607 2 2013-01-02 257.31 78.43285 196.35 1.0256707 1.0316818 1.0250588 3 2013-01-03 258.48 77.44286 195.27 1.0045471 0.9873774 0.9944993 252 2013-12-30 393.37 79.21714 186.41 0.9881682 0.9900556 1.0071862 Value-Weighted Portfolio Calculate the market capitalization of each security in the portfolio Market cap is equal to the price multiplied by the outstanding shares Construct a series of calendar days date <- seq(as.Date("2012-12-31"),as.Date("2013-12-31"),by=1) date <- data.frame(date) date[c(1:3,nrow(date)),] [1] "2012-12-31" "2013-01-01" "2013-01-02" "2013-12-31" Value-Weighted Portfolio Calculate the market capitalization of each security in the portfolio Market cap is equal to the price multiplied by the outstanding shares Create data object with daily prices, filling in last avialable price on non-trading days PRICE.qtr <- vwport[,c(1,2,3,4)] PRICE.qtr[c(1:3,nrow(PRICE.qtr)),] date AMZN.Close AAPL.Close IBM.Close 1 2012-12-31 250.87 76.02428 191.55 2 2013-01-02 257.31 78.43285 196.35 3 2013-01-03 258.48 77.44286 195.27 252 2013-12-30 393.37 79.21714 186.41 Value-Weighted Portfolio Calculate the market capitalization of each security in the portfolio Market cap is equal to the price multiplied by the outstanding shares Create data object with daily prices, filling in last avialable price on non-trading days Merge date and PRICE.qtr using a combination of the na.locf and merge commands. The merge command combines two data objects. Using the all.x=TRUE option tells R that when merging we should keep all the data in the “by” variable that is available in the x=date data object. PRICE.qtr <- na.locf(merge(x=date,y=PRICE.qtr,by="date",all.x=TRUE)) PRICE.qtr[c(1:3,nrow(PRICE.qtr)),] date AMZN.Close AAPL.Close IBM.Close 1 2012-12-31 250.87 76.02428 191.55 2 2013-01-01 250.87 76.02428 191.55 3 2013-01-02 257.31 78.43285 196.35 366 2013-12-31 393.37 79.21714 186.41 Value-Weighted Portfolio Calculate the market capitalization of each security in the portfolio Market cap is equal to the price multiplied by the outstanding shares Keep only prices at the end of each calendar quarter PRICE.qtr <- subset(PRICE.qtr, PRICE.qtr$date==as.Date("2012-12-31") | PRICE.qtr$date==as.Date("2013-03-31") | PRICE.qtr$date==as.Date("2013-06-30") | PRICE.qtr$date==as.Date("2013-09-30")) PRICE.qtr date AMZN.Close AAPL.Close IBM.Close 1 2012-12-31 250.87 76.02428 191.55 91 2013-03-31 266.49 63.23714 213.30 182 2013-06-30 277.69 56.64714 191.11 274 2013-09-30 312.64 68.10714 185.18 Value-Weighted Portfolio Calculate the market capitalization of each security in the portfolio Market cap is equal to the price multiplied by the outstanding shares Obtain shares outstanding data from SEC filings Available from the SEC EDGAR database (Form 10k - Form 10-Q) Enter the data manually PRICE.qtr$AMZN.shout <- c(454000000,455000000,457000000,458000000) PRICE.qtr$AAPL.shout <- c(1115233000,1084766000,1065046000,1013059000) PRICE.qtr$IBM.shout <- c(1117367676,1108794396,1095425823,1085854383) PRICE.qtr date AMZN.Close AAPL.Close IBM.Close AMZN.shout AAPL.shout IBM.shout 1 2012-12-31 250.87 76.02428 191.55 4.54e+08 1115233000 1117367676 91 2013-03-31 266.49 63.23714 213.30 4.55e+08 1084766000 1108794396 182 2013-06-30 277.69 56.64714 191.11 4.57e+08 1065046000 1095425823 274 2013-09-30 312.64 68.10714 185.18 4.58e+08 1013059000 1085854383 Value-Weighted Portfolio Calculate the market capitalization of each security in the portfolio Market cap is equal to the price multiplied by the outstanding shares Calculate market capitalization for each security -check that date and closing price are read-in as character variables str(PRICE.qtr) 'data.frame': 4 obs. of 7 variables: $ date : Date, format: "2012-12-31" "2013-03-31" ... $ AMZN.Close: num 251 266 278 313 $ AAPL.Close: num 76 63.2 56.6 68.1 $ IBM.Close : num 192 213 191 185 $ AMZN.shout: num 4.54e+08 4.55e+08 4.57e+08 4.58e+08 $ AAPL.shout: num 1.12e+09 1.08e+09 1.07e+09 1.01e+09 $ IBM.shout : num 1.12e+09 1.11e+09 1.10e+09 1.09e+09 Value-Weighted Portfolio Calculate the market capitalization of each security in the portfolio Market cap is equal to the price multiplied by the outstanding shares To make the data object name more sensible to hold the weights of the securities, copy the data in PRICE.qtr into weights. Calculate the market cap for each security by multiplying that security's closing price with its shares outstanding. weights <- PRICE.qtr weights$AMZN.mcap <- weights$AMZN.Close*weights$AMZN.shout weights$AAPL.mcap <- weights$AAPL.Close*weights$AAPL.shout weights$IBM.mcap <- weights$AMZN.Close*weights$IBM.shout weights date AMZN.Close AAPL.Close IBM.Close AMZN.shout AAPL.shout IBM.shout 1 2012-12-31 250.87 76.02428 191.55 4.54e+08 1115233000 1117367676 91 2013-03-31 266.49 63.23714 213.30 4.55e+08 1084766000 1108794396 182 2013-06-30 277.69 56.64714 191.11 4.57e+08 1065046000 1095425823 274 2013-09-30 312.64 68.10714 185.18 4.58e+08 1013059000 1085854383 AMZN.mcap AAPL.mcap IBM.mcap 1 113894977730 84784790318 280314023291 91 121252945450 68597503748 295482607502 182 126904330914 60331814129 304188798980 274 143189126870 68996551141 339481530589 Value-Weighted Portfolio Calculate the market capitalization of each security in the portfolio Market cap is equal to the price multiplied by the outstanding shares Calculate quarter-end aggregate market capitalization -Apply the rowSums command to the three market capitalization variables (8-10) weights$tot.mcap <- rowSums(weights[8:10]) weights date AMZN.Close AAPL.Close IBM.Close AMZN.shout AAPL.shout IBM.shout 1 2012-12-31 250.87 76.02428 191.55 4.54e+08 1115233000 1117367676 91 2013-03-31 266.49 63.23714 213.30 4.55e+08 1084766000 1108794396 182 2013-06-30 277.69 56.64714 191.11 4.57e+08 1065046000 1095425823 274 2013-09-30 312.64 68.10714 185.18 4.58e+08 1013059000 1085854383 AMZN.mcap AAPL.mcap IBM.mcap tot.mcap 1 113894977730 84784790318 280314023291 478993791339 91 121252945450 68597503748 295482607502 485333056700 182 126904330914 60331814129 304188798980 491424944022 274 143189126870 68996551141 339481530589 551667208600 Value-Weighted Portfolio Calculate the quarter-end weights of each security in the portfolio Divide each security's market cap by the combined market cap of the three securities weights$AMZN.wgt <- weights$AMZN.mcap/weights$tot.mcap weights$AAPL.wgt <- weights$AAPL.mcap/weights$tot.mcap weights$IBM.wgt <- weights$IBM.mcap/weights$tot.mcap weights date AMZN.Close AAPL.Close IBM.Close AMZN.shout AAPL.shout IBM.shout 1 2012-12-31 250.87 76.02428 191.55 4.54e+08 1115233000 1117367676 91 2013-03-31 266.49 63.23714 213.30 4.55e+08 1084766000 1108794396 182 2013-06-30 277.69 56.64714 191.11 4.57e+08 1065046000 1095425823 274 2013-09-30 312.64 68.10714 185.18 4.58e+08 1013059000 1085854383 AMZN.mcap AAPL.mcap IBM.mcap tot.mcap AMZN.wgt AAPL.wgt 1 113894977730 84784790318 280314023291 478993791339 0.2377797 0.1770060 91 121252945450 68597503748 295482607502 485333056700 0.2498345 0.1413411 182 126904330914 60331814129 304188798980 491424944022 0.2582375 0.1227691 274 143189126870 68996551141 339481530589 551667208600 0.2595571 0.1250692 IBM.wgt 1 0.5852143 91 0.6088244 182 0.6189934 274 0.6153738 Value-Weighted Portfolio Calculate the quarter-end weights of each security in the portfolio Create an object WEIGHT to keep only the date and the three weight variables WEIGHT <- weights[,c(1,12:14)] WEIGHT date AMZN.wgt AAPL.wgt IBM.wgt 1 2012-12-31 0.2377797 0.1770060 0.5852143 91 2013-03-31 0.2498345 0.1413411 0.6088244 182 2013-06-30 0.2582375 0.1227691 0.6189934 274 2013-09-30 0.2595571 0.1250692 0.6153738 Value-Weighted Portfolio Calculate the quarter-end weights of each security in the portfolio To apply the weights to the start of the following quarter, add one to all dates WEIGHT$date <- WEIGHT$date+1 WEIGHT date AMZN.wgt AAPL.wgt IBM.wgt 1 2013-01-01 0.2377797 0.1770060 0.5852143 91 2013-04-01 0.2498345 0.1413411 0.6088244 182 2013-07-01 0.2582375 0.1227691 0.6189934 274 2013-10-01 0.2595571 0.1250692 0.6153738 Value-Weighted Portfolio Calculating the quarterly VW portfolio values (similar to EW portfolio) Create series of dates to find the applicable weights at the beginning of each quarter date <- seq(as.Date("2012-12-31"),as.Date("2013-12-31"),by=1) date <- data.frame(date) date[c(1:3,nrow(date)),] [1] "2012-12-31" "2013-01-01" "2013-01-02" "2013-12-31" Merge WEIGHT into date vwret <- na.locf(merge(date,WEIGHT,by="date",all.x=TRUE)) vwret[c(1:3,nrow(vwret)),] date AMZN.wgt AAPL.wgt IBM.wgt 2 2013-01-01 0.2377797 0.1770060 0.5852143 3 2013-01-02 0.2377797 0.1770060 0.5852143 4 2013-01-03 0.2377797 0.1770060 0.5852143 366 2013-12-31 0.2595571 0.1250692 0.6153738 Value-Weighted Portfolio Calculating the quarterly VW portfolio values (similar to EW portfolio) Check date as.date and wgt as.num str(vwret) 'data.frame': 365 obs. of 4 variables: $ date : Date, format: "2013-01-01" "2013-01-02" ... $ AMZN.wgt: num 0.238 0.238 0.238 0.238 0.238 ... $ AAPL.wgt: num 0.177 0.177 0.177 0.177 0.177 ... $ IBM.wgt : num 0.585 0.585 0.585 0.585 0.585 ... - attr(*, "na.action")= 'omit' Named int 1 ..- attr(*, "names")= chr "1" Value-Weighted Portfolio Calculating the quarterly VW portfolio values (similar to EW portfolio) Extract the beginning of the quarter weights from vwret q1.vw.wgt <- subset(vwret,vwret$date==as.Date("2013-01-01")) q1.vw.wgt date AMZN.wgt AAPL.wgt IBM.wgt 2 2013-01-01 0.2377797 0.177006 0.5852143 q2.vw.wgt <- subset(vwret,vwret$date==as.Date("2013-04-01")) q2.vw.wgt date AMZN.wgt AAPL.wgt IBM.wgt 92 2013-04-01 0.2498345 0.1413411 0.6088244 q3.vw.wgt <- subset(vwret,vwret$date==as.Date("2013-07-01")) q3.vw.wgt date AMZN.wgt AAPL.wgt IBM.wgt 183 2013-07-01 0.2582375 0.1227691 0.6189934 q4.vw.wgt <- subset(vwret,vwret$date==as.Date("2013-10-01")) q4.vw.wgt date AMZN.wgt AAPL.wgt IBM.wgt 275 2013-10-01 0.2595571 0.1250692 0.6153738 Value-Weighted Portfolio Create pie charts of the weights Q1 Q1.pie.values <- as.numeric(q1.vw.wgt[,-1]) Q1.pie.labels <- c("Amazon","Apple","IBM") pct <- round(Q1.pie.values*100) Q1.pie.labels <- paste(Q1.pie.labels,pct) #Add pct Q1.pie.labels <- paste(Q1.pie.labels,"%",sep="") #Add % sign pie(Q1.pie.values, labels=Q1.pie.labels, col=c("red","blue","green"), main="Q1 Value Weigthing") Value-Weighted Portfolio Create pie charts of the weights Q2 Value-Weighted Portfolio Calculating VW portfolio values for 1Q 2013 (similar to the EW portfolio) Subset vwport to the data from Dec 31, 2012 to March 31, 2013 vw.q1 <- subset(vwport[,c(1,5:7)], vwport$date >= as.Date(“2012-12-31”) &
vwport$date <= as.Date("2013-03-31")) names(vw.q1) <- paste(c("date","AMZN","AAPL","IBM")) # shorten the names vw.q1[c(1:3,nrow(vw.q1)),] date AMZN AAPL IBM 1 2012-12-31 1.023207 1.0443101 1.0090607 2 2013-01-02 1.025671 1.0316818 1.0250588 3 2013-01-03 1.004547 0.9873774 0.9944993 61 2013-03-28 1.004485 0.9791631 1.0114278 Value-Weighted Portfolio Calculating VW portfolio values for 1Q 2013 (similar to the EW portfolio) Calculate the cumulative gross return for each security vw.q1[1,2:4] <-1 vw.q1$AMZN <- cumprod(vw.q1$AMZN) vw.q1$AAPL <- cumprod(vw.q1$AAPL) vw.q1$IBM <- cumprod(vw.q1$IBM) vw.q1[c(1:3,nrow(vw.q1)),] date AMZN AAPL IBM 1 2012-12-31 1.000000 1.0000000 1.000000 2 2013-01-02 1.025671 1.0316818 1.025059 3 2013-01-03 1.030335 1.0186594 1.019420 61 2013-03-28 1.062263 0.8366496 1.118234 Value-Weighted Portfolio Calculating VW portfolio values for 1Q 2013 (similar to the EW portfolio) Apply quarter-end weights vw.q1$AMZN.idx <- (1*q1.vw.wgt$AMZN.wgt)*vw.q1$AMZN vw.q1$AAPL.idx <- (1*q1.vw.wgt$AAPL.wgt)*vw.q1$AAPL vw.q1$IBM.idx <- (1*q1.vw.wgt$IBM.wgt)*vw.q1$IBM vw.q1[c(1:3,nrow(vw.q1)),] date AMZN AAPL IBM AMZN.idx AAPL.idx IBM.idx 1 2012-12-31 1.000000 1.0000000 1.000000 0.2377797 0.1770060 0.5852143 2 2013-01-02 1.025671 1.0316818 1.025059 0.2438836 0.1826139 0.5998791 3 2013-01-03 1.030335 1.0186594 1.019420 0.2449926 0.1803089 0.5965793 61 2013-03-28 1.062263 0.8366496 1.118234 0.2525846 0.1480920 0.6544068 Value-Weighted Portfolio Calculating VW portfolio values for 1Q 2013 (similar to the EW portfolio) Calculate daily portfolio values q1.vw.val <- data.frame(rowSums(vw.q1[,5:7])) q1.vw.val[c(1:3,nrow(q1.vw.val)),] [1] 1.000000 1.026377 1.021881 1.055083 names(q1.vw.val) <- paste("port.val") q1.vw.val$date <- vw.q1$date q1.vw.val[c(1:3,nrow(q1.vw.val)),] port.val date 1 1.000000 2012-12-31 2 1.026377 2013-01-02 3 1.021881 2013-01-03 61 1.055083 2013-03-28 q2.vw.inv <- q1.vw.val[nrow(q1.vw.val),1] q2.vw.inv [1] 1.055083 End of Q1 value Value-Weighted Portfolio Calculating VW portfolio values for 2Q 2013 (similar to the EW portfolio) Subset vwport to the data from Mar 2012 to Jun 2013 vw.q2 <- subset(vwport[,c(1,5:7)], vwport$date >= as.Date(“2013-04-01”) &
vwport$date <= as.Date("2013-06-30")) names(vw.q2) <- paste(c("date","AMZN","AAPL","IBM")) # shorten the names vw.q2[c(1:3,nrow(vw.q2)),] date AMZN AAPL IBM 62 2013-04-01 0.9816878 0.9689378 0.9956870 63 2013-04-02 1.0065365 1.0020517 1.0093229 64 2013-04-03 0.9837080 1.0051189 0.9920694 125 2013-06-28 1.0005045 1.0069835 0.9767953 Value-Weighted Portfolio Calculating VW portfolio values for 2Q 2013 (similar to the EW portfolio) Calculate the cumulative gross return for each security vw.q2[1,2:4] <-1 vw.q2$AMZN <- cumprod(vw.q2$AMZN) vw.q2$AAPL <- cumprod(vw.q2$AAPL) vw.q2$IBM <- cumprod(vw.q2$IBM) vw.q2[c(1:3,nrow(vw.q2)),] date AMZN AAPL IBM 62 2013-04-01 1.000000 1.0000000 1.0000000 63 2013-04-02 1.006537 1.0020517 1.0093229 64 2013-04-03 0.990138 1.0071811 1.0013183 125 2013-06-28 1.061466 0.9306257 0.9040669 Value-Weighted Portfolio Calculating VW portfolio values for 2Q 2013 (similar to the EW portfolio) Apply quarter-end weights vw.q2$AMZN.idx <- (1*q2.vw.wgt$AMZN.wgt)*vw.q2$AMZN vw.q2$AAPL.idx <- (1*q2.vw.wgt$AAPL.wgt)*vw.q2$AAPL vw.q2$IBM.idx <- (1*q2.vw.wgt$IBM.wgt)*vw.q2$IBM vw.q2[c(1:3,nrow(vw.q2)),] date AMZN AAPL IBM AMZN.idx AAPL.idx IBM.idx 62 2013-04-01 1.000000 1.0000000 1.0000000 0.2498345 0.1413411 0.6088244 63 2013-04-02 1.006537 1.0020517 1.0093229 0.2514676 0.1416311 0.6145004 64 2013-04-03 0.990138 1.0071811 1.0013183 0.2473707 0.1423561 0.6096270 125 2013-06-28 1.061466 0.9306257 0.9040669 0.2651907 0.1315357 0.5504180 Value-Weighted Portfolio Calculating VW portfolio values for 2Q 2013 (similar to the EW portfolio) Calculate daily portfolio values q2.vw.val <- data.frame(rowSums(vw.q2[,5:7])) q2.vw.val[c(1:3,nrow(q2.vw.val)),] [1] 1.0000000 1.0075990 0.9993537 0.9471444 names(q2.vw.val) <- paste("port.val") q2.vw.val$date <- vw.q2$date q2.vw.val[c(1:3,nrow(q2.vw.val)),] port.val date 62 1.0000000 2013-04-01 63 1.0075990 2013-04-02 64 0.9993537 2013-04-03 125 0.9471444 2013-06-28 q3.vw.inv <- q2.vw.val[nrow(q2.vw.val),1] q3.vw.inv [1] 0.9471444 End of Q2 value Value-Weighted Portfolio Calculating VW portfolio values for 3Q 2013 (similar to the EW portfolio) Subset vwport to the data from July 2013 to Sept 2013 vw.q3 <- subset(vwport[,c(1,5:7)], vwport$date >= as.Date(“2013-07-01”) &
vwport$date <= as.Date("2013-09-30")) names(vw.q3) <- paste(c("date","AMZN","AAPL","IBM")) # shorten the names vw.q3[c(1:3,nrow(vw.q3)),] date AMZN AAPL IBM 126 2013-07-01 1.0158810 1.0320027 1.0008896 127 2013-07-02 1.0057781 1.0226527 1.0011505 128 2013-07-03 1.0010573 1.0055197 1.0091380 189 2013-09-30 0.9893358 0.9875709 0.9906913 Value-Weighted Portfolio Calculating VW portfolio values for 3Q 2013 (similar to the EW portfolio) Calculate the cumulative gross return for each security vw.q3[1,2:4] <-1 vw.q3$AMZN <- cumprod(vw.q3$AMZN) vw.q3$AAPL <- cumprod(vw.q3$AAPL) vw.q3$IBM <- cumprod(vw.q3$IBM) vw.q3[c(1:3,nrow(vw.q3)),] date AMZN AAPL IBM 126 2013-07-01 1.000000 1.000000 1.0000000 127 2013-07-02 1.005778 1.022653 1.0011505 128 2013-07-03 1.006842 1.028298 1.0102990 189 2013-09-30 1.108260 1.172713 0.9729493 Value-Weighted Portfolio Calculating VW portfolio values for 3Q 2013 (similar to the EW portfolio) Apply quarter-end weights vw.q3$AMZN.idx <- (1*q3.vw.wgt$AMZN.wgt)*vw.q3$AMZN vw.q3$AAPL.idx <- (1*q3.vw.wgt$AAPL.wgt)*vw.q3$AAPL vw.q3$IBM.idx <- (1*q3.vw.wgt$IBM.wgt)*vw.q3$IBM vw.q3[c(1:3,nrow(vw.q3)),] date AMZN AAPL IBM AMZN.idx AAPL.idx IBM.idx 126 2013-07-01 1.000000 1.000000 1.0000000 0.2582375 0.1227691 0.6189934 127 2013-07-02 1.005778 1.022653 1.0011505 0.2597296 0.1255502 0.6197055 128 2013-07-03 1.006842 1.028298 1.0102990 0.2600042 0.1262432 0.6253684 189 2013-09-30 1.108260 1.172713 0.9729493 0.2861941 0.1439730 0.6022492 Value-Weighted Portfolio Calculating VW portfolio values for 3Q 2013 (similar to the EW portfolio) Calculate daily portfolio values q3.vw.val <- data.frame(rowSums(vw.q3[,5:7])) q3.vw.val[c(1:3,nrow(q3.vw.val)),] [1] 1.000000 1.004985 1.011616 1.032416 names(q3.vw.val) <- paste("port.val") q3.vw.val$date <- vw.q3$date q3.vw.val[c(1:3,nrow(q3.vw.val)),] port.val date 126 1.000000 2013-07-01 127 1.004985 2013-07-02 128 1.011616 2013-07-03 189 1.032416 2013-09-30 q4.vw.inv <- q3.vw.val[nrow(q3.vw.val),1] q4.vw.inv [1] 1.032416 End of Q3 value Value-Weighted Portfolio Calculating VW portfolio values for 4Q 2013 (similar to the EW portfolio) Subset vwport to the data from Oct 2012 to Dec 2013 vw.q4 <- subset(vwport[,c(1,5:7)], vwport$date >= as.Date(“2013-10-01”) &
vwport$date <= as.Date("2013-12-31")) names(vw.q4) <- paste(c("date","AMZN","AAPL","IBM")) # shorten the names vw.q4[c(1:3,nrow(vw.q4)),] date AMZN AAPL IBM 190 2013-10-01 1.0265801 1.0235134 1.0064802 191 2013-10-02 0.9986291 1.0032790 0.9923809 192 2013-10-03 0.9820598 0.9874378 0.9940527 252 2013-12-30 0.9881682 0.9900556 1.0071862 Value-Weighted Portfolio Calculating VW portfolio values for 4Q 2013 (similar to the EW portfolio) Calculate the cumulative gross return for each security vw.q4[1,2:4] <-1 vw.q4$AMZN <- cumprod(vw.q4$AMZN) vw.q4$AAPL <- cumprod(vw.q4$AAPL) vw.q4$IBM <- cumprod(vw.q4$IBM) vw.q4[c(1:3,nrow(vw.q4)),] date AMZN AAPL IBM 190 2013-10-01 1.0000000 1.0000000 1.0000000 191 2013-10-02 0.9986291 1.0032790 0.9923809 192 2013-10-03 0.9807135 0.9906756 0.9864789 252 2013-12-30 1.2256426 1.1430397 1.0055319 Value-Weighted Portfolio Calculating VW portfolio values for 4Q 2013 (similar to the EW portfolio) Apply quarter-end weights vw.q4$AMZN.idx <- (1*q4.vw.wgt$AMZN.wgt)*vw.q4$AMZN vw.q4$AAPL.idx <- (1*q4.vw.wgt$AAPL.wgt)*vw.q4$AAPL vw.q4$IBM.idx <- (1*q4.vw.wgt$IBM.wgt)*vw.q4$IBM vw.q4[c(1:3,nrow(vw.q4)),] date AMZN AAPL IBM AMZN.idx AAPL.idx IBM.idx 190 2013-10-01 1.0000000 1.0000000 1.0000000 0.2595571 0.1250692 0.6153738 191 2013-10-02 0.9986291 1.0032790 0.9923809 0.2592012 0.1254793 0.6106852 192 2013-10-03 0.9807135 0.9906756 0.9864789 0.2545511 0.1239030 0.6070532 252 2013-12-30 1.2256426 1.1430397 1.0055319 0.3181242 0.1429590 0.6187780 Value-Weighted Portfolio Calculating VW portfolio values for 4Q 2013 (similar to the EW portfolio) Calculate daily portfolio values q4.vw.val <- data.frame(rowSums(vw.q4[,5:7])) q4.vw.val[c(1:3,nrow(q4.vw.val)),] [1] 1.0000000 0.9953657 0.9855073 1.0798612 names(q4.vw.val) <- paste("port.val") q4.vw.val$date <- vw.q4$date q4.vw.val[c(1:3,nrow(q4.vw.val)),] port.val date 190 1.0000000 2013-10-01 191 0.9953657 2013-10-02 192 0.9855073 2013-10-03 252 1.0798612 2013-12-30 End value for the year Value-Weighted Portfolio Combining quarterly VW portfolio values into one data object vw.portval <- rbind(q1.vw.val,q2.vw.val,q3.vw.val,q4.vw.val) vw.portval[c(1:3,nrow(vw.portval)),] port.val date 1 1.000000 2012-12-31 2 1.026377 2013-01-02 3 1.021881 2013-01-03 252 1.079861 2013-12-30 Value-Weighted Portfolio Normalized EW and VW portfolio price chart Combine the data port.val <- merge(vw.portval,ew.portval,by="date") names(port.val) <- paste(c("date","VW.cum","EW.cum")) port.val[c(1:3,nrow(port.val)),] date VW.cum EW.cum 1 2012-12-31 1.000000 1.000000 2 2013-01-02 1.026377 1.027470 3 2013-01-03 1.021881 1.022805 252 2013-12-30 1.079861 1.206221 Value-Weighted Portfolio Plot the data y.range <-range(port.val[,2:3]) plot(port.val$EW.cum, type="l", xlab="Date", ylab="Value of Investment", ylim=y.range, lty=1, main="Value of $1 Investment in Equal-Weighted and Value-Weighted Portfolios of AMZN, AAPL, and IBM December 31, 2012 - December 31, 2013") lines(port.val$VW.cum,lty=2) abline(h=1,lty=1) legend("topleft", c("Equal-Weighted Portfolio","Value-Weighted Portfolio"), lty=c(1,2))

Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more
Open chat
1
You can contact our live agent via WhatsApp! Via + 1 929 473-0077

Feel free to ask questions, clarifications, or discounts available when placing an order.

Order your essay today and save 20% with the discount code GURUH