Hi everybody,
I have a panel with 10000 firms and 70 years of each firms return. Now I've wanted to create 1000 artificial mutual funds, each of which creates an equal-weighted portfolio of 5% of the 10000 firms.
I've used this loop:
counter <- 1
funds <- as.data.frame(matrix(NA)) #collect returns and sds for all funds
for (m in 1:1000) {
panel$include <- 0
subset <- sample(1:10000,50,replace=FALSE) #50 firms ids drawn at random
for (i in 1:50) {
panel$include[panel$firmid == subset [i]] <- 1
}
new.data <- subset(panel, include ==1)
port.returns
port.sd
funds[counter, 1] <- port.returns
funds[counter,2] <- port.sd
counter <- counter+1 #refresh counter
}
As you can see I left out the portfolio return and the standard deviation. I am a bit confused. How can I manage to compute the portfolio return of my 50 firms when they're are equal-weighted. Does anybody know which code I could use to compute the portfolio return and the standard deviation?