I am facing problems with addition of two xts objects.
Object 1 : bk
head(bk)
iroqu
1962-07-03 0
1962-07-05 0
1962-07-06 0
1962-07-09 0
1962-07-10 0
1962-07-11 0
Object 2 : calculated as weight <- lag(crp(xik, c(alphas[i], 1-alphas[i])), 1) in for loop
[,1]
1962-07-03 NA
1962-07-05 0.9374210
1962-07-06 0.9367212
1962-07-09 0.9452369
1962-07-10 0.9464487
1962-07-11 1.0819963
When I am doing inside for loop,
bk <- bk + alphas[i] * weight
bk becomes
bk
Data:
numeric(0)
Index:
numeric(0)
I checked that alphas[i] * weight is not a problem and dimensions of the vectors also match. Why I am not able to add two objects using + sign? Is there a way to add these? I want effectively only 1 column.
The full example I am trying is from blog http://optimallog.blogspot.in/2012/06/universal-portfolio-part-4.html first code snippet