I have lists named dat and res with 33 datasets each. Iam running global minimum variance portfolios with a for loop like this:
for(i in dat) {
N <- ncol(i)
Amat <- t(rbind( rep(1,N), diag(rep(1,N)), diag(rep(-1,N))))
bvec <- c(1 , rep(0,N), rep(-0.15,N))
Dmat <- cov.shrink(i) #from tawny package
dvec <- rep(0,N)
mvw <- solve.QP( Dmat, dvec, Amat, bvec, meq = 1 )$solution #from quadprog package
names(mvw) = colnames(i)
}
Its working, but saves only the last iteration of course. I dont know how to save them all. I need to save all the 33 mvw results in a list. How can I do it?
After that, i have to evaluate the results of mvw with the equivalent resdatasets:
mvwreturns = res%*%matrix(mvw,ncol=1)
This command give me the portfolio returs evaluated for each period. Each mvw data matches with one res dataset. How can I do this? Iam wondering if I have to run another for loop.
Any help is appreciated. Sorry for my poor english.