Reputation: 103
I'm having problem writing the following double sum into a function in r:
where the I function is an indicator function and we have n observations x_1...x_n.
I tried something like this
sum( (x <= t) / (sum((x<=x)))^2)
Upvotes: 0
Views: 191
Reputation: 12559
You can do:
sumiI <- function(xi, x) sum(xi<=x)
sum(1/sapply(x[x<=t], FUN=sumI, x=x))
Upvotes: 1