I want to produce a loss exceedance curve with the code:
x <- rpois (10000, 3) * rlnorm (10000, 100,10)
number_sequence = seq(0.1,1,0.1)
for (i in number_sequence)
{
y <- quantile (log(x), c(i))
plot (y,i)
}
I am getting 10 separated plot charts. The information is right, but I need to have the 10 data points in the same chart to make a curve as (10%, 85), (20%, 91).. (100%, 141) . I failed to make a matrix to plot at the end.
I am happy to technically explain how the formulas work for risk quantification in R.
I have gotten 10 separated plot charts rather than one single chart with the 10 data sets.
CodePudding user response:
y <- c()
for (i in number_sequence)
{
y <- c(y,quantile (log(x), c(i)))
}
plot(y,number_sequence)
Or faster:
y <- quantile(log(x),number_sequence)
plot(y,number_sequence)