welcome in this session we will learn to construct the fission frontier in art well the first thing that we are going to do is to install several packages that we need to build the vision frontier and also to optimize the portfolio so we are we're going to install firstly the first uh firstly the package f portfolio i'm going to write install dot packages open parenthesis and then i write the name of the portfolio i have already installed all the packages so i'm not going to press enter but you if you haven't not if you have not installed the packages you can just run them from the script you have to start the package f portfolio time series quant mode deployer performance analytics and ggplot 2. after you have installed the packages you have to put them on the library so you have to write library open parenthesis and the name of the packages press enter and you will have to do all of for you will have to do this for all the packages for the package time series one multiplier performance analytic and gg plot dose i'm going to re i'm gg plot2 sorry i'm going to run them from the script so i i have already put all the packages on my library and now i'm going to change the class of the return. matrix variable from a data frame to a time series and this is required by the package if portfolio if you don't do this you will obtain any roar so you have to change the class i'm going to write return dot matrix equals and i'm going to use the function as dot time series to change the class of the variable as time in rstudio is already suggesting me the function and then i write the the same name of the variable return matrix and as you can see return matrix was a data frame before and now you can look for it and now it is here and has a formal class time series so we changed the class the variable and now let's create the efficient frontier i'm going to clean the screen i'm going to create the variable efficient frontier efficient dot frontier equals and now i'm going to use the function portfolio frontier from the package f portfolio portfolio and you can see here that our student is already suggesting us the variable and now we are going to write the arguments i press chief enter to go to the second line the first variable is the name of the matrix that contains the returns so return matrix that has a class of time series the second argument in the second argument we are going to set the risk free rate so we have to write set risk and our studies already suggesting us the variable we double click and inside set risk free rate we have to write portfolio spec then a comma and then we have to give the value of the risk-free rate if we remember it was 2.
21 but that was an annual risk free rate and we are working with monthly data so we have to divide it by 12. it was 2 21 if i remember divided by 12.