So where did we mess up? In the calculation of returns for the market cap weighted portfolio andthe portfolio optimization portfolio, we simply took the starting weights (W0)and multiplied them by the relevant series of returns.resEqual = as.matri...

Zero Inflated Models and Generalized Linear Mixed Models with R.
Zuur, Saveliev, Ieno (2012).