# Calculate monthly returns for a QUARTERLY and YEARLY rebalanced portfolio in R

I built a minimum variance, equal weight, inverse volatility, and equal risk contribution portfolios based on the same data set of monthly returns for 30 different companies.

The covariance matrix is estimated using a preliminary estimation of T months and implementing a fixed rolling-window approach starting with the preliminary estimation and moving one month forward, picking up the next T +1 month and leaving the first one behind. In this way, a new covariance matrix is estimated every month, the respective weights are monthly updated, and the portfolio is monthly rebalanced.

Now, I want to rebalance the portfolios QUARTERLY and YEARLY. I managed to do the for-loop where I calculate the respective updated vector of weights for every quarter or year, but what I am missing is how exactly to calculate the monthly portfolio returns between the rebalancing periods. I do not know how to compute those changes... Can someone help me out? I definitely am missing something, but I don't know what. This is the code of my loop, but it is wrong, because I update my covariance matrix and weights on the respective rebalancing date, but between the dates I multiply the asset returns with the vector of weights from the previous rebalancing, which is wrong... I need somehow to calculate those monthly portfolio returns between i have the new vector of weights for the rebalancing. This is the for-loop:

k=11 #for yearly rebalancing

for (i in seq(from=1, to=n, by=k)) {

find the indices of the in-sample period

period.end <- first + i - 2

period.start <- period.end - in.sample + 1

if(period.start<1) period.start <- 1 # index cannot be less than 1

covariance matrix estimation

covmat <- cov(ret[period.start:period.end,])

compute the minimum variance weights; this is an external builded function

w.minvar<- minvarport(covmat,shorts=FALSE)

return on the minimum variance portfolio

for (y in 0:(k-1)) {

if (i+y <= n)

returns.minvar[i+y] <- sum(w.minvar*ret[(period.end+1+y),])

}

}

Any help will be appreciated! Thank you.