I am trying apply the Canberra distance function in complex survey design using R package survey and srvyr.
example:
dstrata %>%
group_by(awards) %>%
summarise(api00 = survey_mean(api00),
api99=survey_mean(api99))
I want to apply the canb.dist function to measure the distance between apo00 and api99
canb.dist <- function(x, j){ sum((abs(x-j))/(abs(x)+abs(j)))}
canberra.index= function(x,j){
Canbdist=sum((abs(x-j))/(abs(x)+abs(j)))
domain=numeric(length(x))
return (CD= Canbdist/domain)
}
I don't know if anyone has defined a weighted version of the Canberra distance, but it's the total (or mean) of
abs(x-y)/(abs(x)+abs(y), soz=abs(x-y)/(abs(x)+abs(y))survey_mean(z)orsurvey_total(z)