[R] non negativity constraints if else function
Esra Ulasan
esra_ulasan at icloud.com
Sat Dec 20 05:26:55 CET 2014
Hello,
I have tried the solve the non-negativity constraint "if else function" in R. But I have done something wrong because it still gives the same solution. I want that, if weight element is negative set it to zero, else recalculate the weights again. These are the codes:
for(i in 1:M){ w[,i] = f+r[i]*g #portfolio weights
for(i in 1:M){
if (w <0){w=0}else{w=w}
}
}
If you help me I would be happy
Thank you
[[alternative HTML version deleted]]
More information about the R-help
mailing list