R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot. install.packages(“tidyverse”) install.packages(“rvest”) install.packages(“tidyquant”) install.packages(“janitor”) install.packages(“timetk”) install.packages(“quantmod”) install.packages(“tidyverse”) install.packages(“rvest”) install.packages(“tidyquant”) install.packages(“janitor”) asset.names <- c(“MSFT”, “NORD”, “SBUX”) mu.vec = c(0.0427, 0.0015, 0.0285) mu.vec names(mu.vec) = asset.names sigma.mat = matrix(c(0.0100, 0.0018, 0.0011, 0.0018, 0.0109, 0.0026, 0.0011, 0.0026, 0.0199), nrow=3, ncol=3) dimnames(sigma.mat) = list(asset.names, asset.names) mu.vec sigma.mat x.vec = rep(1, 3)/3 names(x.vec ) = asset.names mu.p.x = crossprod( x.vec, mu.vec ) sig2.p.x = t(x.vec ) %% sigma.mat %% x.vec sig.p.x = sqrt(sig2.p.x) mu.p.x sig.p.x top.mat = cbind (2* sigma.mat, rep (1,3)) bot.vec = c( rep (1,3),0) Am.mat = rbind (top.mat, bot.vec) b.vec = c(rep(0,3), 1) z.m.mat = solve(Am.mat)%% b.vec m.vec = z.m.mat [1:3,1] m.vec mu.gmin = as.numeric(crossprod (m.vec, mu.vec)) mu.gmin sig2.gmin = as.numeric(t(m.vec)%% sigma.mat %% m.vec) sig.gmin = sqrt(sig2.gmin) sig.gmin one.vec = rep(1, 3) sigma.inv.mat = solve(sigma.mat) top.mat = sigma.inv.mat %% one.vec bot.val = as.numeric((t(one.vec) %% sigma.inv.mat %% one.vec)) m.mat = top.mat/bot.val m.mat [ ,1]