Algorithm to match continuous variables
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
Matt Tearle
el 17 de Mzo. de 2011
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 comentarios
Vasilisa Iatckova
el 15 de Sept. de 2023
Editada: Vasilisa Iatckova
el 15 de Sept. de 2023
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1484087/image.png)
0 comentarios
Ver también
Categorías
Más información sobre Matrices and Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!