[R] while loop problems
Alon Honig
honeyoak at gmail.com
Tue May 31 19:31:48 CEST 2011
Hi , i am trying to get this loop in my r program to work but it is
not giving me the results that I desire. I am trying to model an
insurance contract where there are n securities that have a fixed
likelihood of default vector(data[i,2]) and a payout
vector(data[i,1]).
i need to price the value of stop losses at the security level and at
the portfolio level. to do this i created two while loops for the
conditional vectors of each level (which will be inputed into the
function by the user) one while loop to scan through the various
securities and a final one to model the various scenarios(i.e. monte
carlo). i tried to Use R's matrix capabilities to help organize the
results.
the problem with this code is that the if statement behaves oddly, not
activating and filtering correctly. this causes the program to be slow
and provide bad results. it fills the individual protection column
always rather than conditioning it on the likelihood
vector(data[i,2]). there is a lot of moving parts but overall it is a
simple model.
my end result is to have a vector containing the accumulated values of
insurance for each type of stop loss(i.e. idiosyncratic and
aggregate).
Thanks, Alon.
More information about the R-help
mailing list