February 15th, 2008, 12:08 am
I create efficient frontiers often using R. The function portfolio.optim() in the package tseries is useful.Consider you have a:Matrix of returns (in this example they are daily) called intlEqVector of holding constraints called max and minr<-NULLtemp<-NULLr<-seq(.00046,.00052,.000001)return<-NULLrisk<-NULLfor(z in 1:length(r)){temp<-portfolio.optim(intlEq,pm=r[z],reshigh=max,reslow=min)return[z]<-(1+temp$pm)^250-1risk[z]<-(temp$ps*sqrt(250))}ef<-data.frame(return,risk) postscript(file="~/intlEq.ps")par(col="blue",cex.main=1.5,cex.lab=1.2,cex.axis=1.2)plot(y=return,x=risk,xlab="Annualized Risk",ylab="Annualized Return",main="10 Yr Historical Efficient Frontier",type="l")dev.off()
Last edited by
bostonquant on February 14th, 2008, 11:00 pm, edited 1 time in total.