Algorithm to match continuous variables
조회 수: 8 (최근 30일)
이전 댓글 표시
Hi, I have data sampled from two different populations (say people) where I have measured several continuous variables (for example age and sex). In some cases the populations will have uneven sample sizes
In the simplest case what algorithm would I use to match (on a case by case basis) the individual samples. The critical thing is that the individual samples are closely-matched (ie under some set threshold) and I dont mind losing some of my samples in order to achieve this tight matching. Presumably the tighter I set my matching criteria the more samples I will lose. Any ideas how to program this?
In the more complex case I would like the individual samples to matched along two continuous variables (e.g. both age and sex). That is, individuals must be matched within thresholds for both variables.Any ideas?
Thanks in advance for any suggestions. I am guessing there are probably algorithms for this kind of thing, but its not something I have done before. Cheers, J
댓글 수: 0
답변 (2개)
Matt Tearle
2011년 3월 17일
I'm not completely sure if you want just to extract a subset of data, or group all samples into a set of bins. The former you can do with logical indexing:
xselect = x(age > 42 & age < 99 & height > 123);
One way to achieve the latter would be to use categorical arrays. You could group everyone from age x to age y in one category, age y to age z in another, etc.
댓글 수: 0
Vasilisa Iatckova
2023년 9월 15일
편집: Vasilisa Iatckova
2023년 9월 15일
For people still looking: compute distances between variables and select the minimal ones. For instance, I'll be matching the red and the blue dots only by the y-coordinate, but I can pretend their x-coordinates are 1 & 2, as in the image, to separate the groups. I'm going to compute all-to-all hypots between each blue dot to all red dots and select pairs with minimal distances, eliminating them from running, once selected.

댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Performance and Memory에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!