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]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to