Algorithm to match continuous variables
2 次查看(过去 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 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!