I am comparing the efficient frontier of a set of portfolios that are in and out of sample. The first period is from 1991-01-03 until 1992-10-03 and the second one from 1992-10-03 until 1994-03-03. I used historical data from yahoo finance.

I used the empirical covariance matrix from the first period and constructed my in sample efficient frontier. And used the same weights but the parameters from the second period to get the out of sample efficient frontier.

You may find my R code here:


load("~/Desktop/SE q/2periods.RData")

cov.mat1 <- cov(logret1)
mu2 <- colMeans(logret2)
cov.mat2 <- cov(logret2)

## efficient frontier of portfolios in sample
pf1s <- list()
t <-  seq(0,.25,length.out = 20)
for ( i in 1:20){
        pf1s<- c(pf1s,list(portfolio.optim(x=logret1,pm=t[i],covmat = cov.mat1)))

## get frontiers
for( i in 1:20){
        temp <- pf1s[[i]]
        pf1 <-rbind(pf1,c(temp$pw,temp$pm,temp$ps))

pf1.weights <- pf1[,1:ncol(logret1)]
pf1.ret <- pf1[,ncol(logret1)+1]
pf1.risk<- pf1[,ncol(logret1)+2]

## efficient frontier of portfolios out of sample

pf2 <- NULL
for( i in 1:20){
        pf2 <- rbind(pf2,c( pf1.weights[i,]%*%mu2,sqrt(t(pf1.weights[i,])%*%cov.mat2%*%(pf1.weights[i,]))))
pf2.ret <- pf2[,1]
pf2.risk<- pf2[,2]

# plot efficient frontiers

red : in sample. blue: out of sample Red is in sample and blue out of sample.

Here is a R.data file with my data set https://www.dropbox.com/s/d1pdwvwh4c5r893/2periods.RData?dl=0

My question is if there is an explanation on the strange behaviour of the out of sample portfolio?

Best, J.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.