I have two datasets of a given variable x that have the same length, let's say 14600 values in total each one.

I need to extract the extreme observations within each dataset, where extremes means values > 99th percentile.

I do this by using the R function quantile as follows, where df_1 and df_2 are the two datasets:

df_1_q99 = quantile(df_1$x, probs = 0.99)
df_1_extr = subset(df_1, x > df_1_q99[[1]])

df_2_q99 = quantile(df_2$x, probs = 0.99)
df_2_extr = subset(df_2, x > df_2_q99[[1]])

The issue, which does not make sense to me, is that for df_1 I obtain n=84 and for df_2 n=126 extreme values.

Shouldn't the number of extremes be the same since the two datasets have the same length?


That is only true if each observation has a distinct value. When there are ties you can easily get the pattern you saw.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.