Hi!
I am trying to calculate Bray Curtis Dissimilarity in SAS by proc distance.
I found an example on the next page:https://www.statisticshowto.datasciencecentral.com/bray-curtis-dissimilarity/
According to the Formula, the result must be 0.39
The same numbers I am getting in the R vegan.
Proc distance producing different results.
data c; infile datalines; input id $ A1 A2 A3 ; datalines; Fish_1 6 7 4 Fish_2 10 0 6 ; run; proc distance data=c method=blwnm; var ANOMINAL( A: ) ; id id; run;
Results:
id | Fish_1 | Fish_2 |
Fish_1 | 0 | |
Fish_2 | 0,6 | 0 |
What am I doing wrong here?
Thanks,
Andrii
Hi @andrii and welcome to the SAS Support Communities!
Thanks for this interesting question. I didn't know this specific dissimilarity measure.
In the PROC DISTANCE documentation (close to the bottom of that page) I found that the formula SAS uses with method=blwnm is not equivalent to your linked formula. However, SAS provides an equivalent formula with method=nonmetric. Actually, the formula looks different, but it's an easy exercise to show that it's equivalent (hint: abs(x-y)=x+y-2*min(x,y)).
So, in order to replicate your result, use this code:
proc distance data=c out=want method=nonmetric;
var ratio(a:);
id id;
run;
(Note that level "ratio" is required for method=nonmetric.)
Hi @andrii and welcome to the SAS Support Communities!
Thanks for this interesting question. I didn't know this specific dissimilarity measure.
In the PROC DISTANCE documentation (close to the bottom of that page) I found that the formula SAS uses with method=blwnm is not equivalent to your linked formula. However, SAS provides an equivalent formula with method=nonmetric. Actually, the formula looks different, but it's an easy exercise to show that it's equivalent (hint: abs(x-y)=x+y-2*min(x,y)).
So, in order to replicate your result, use this code:
proc distance data=c out=want method=nonmetric;
var ratio(a:);
id id;
run;
(Note that level "ratio" is required for method=nonmetric.)
Hi @FreelanceReinh
Yes, it exactly what I have been looking for!
Thanks a lot!
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.