Combine Multiple Non-Mutually Exclusive Variables

General help and assistance with jamovi. Bug reports can be made at our issues page: https://github.com/jamovi/jamovi/issues . (If you're unsure feel free to discuss it here)
Post Reply
c.lapan
Posts: 2
Joined: Mon Nov 25, 2024 8:47 pm

Combine Multiple Non-Mutually Exclusive Variables

Post by c.lapan »

Hello!
I'm trying to combine a number of dichotomous variables into a single categorical variable. This is data from qualtrics where participants selected all applicable race/ethnicity categories that applied to them. This results in a number of variables (one for each response option). If they selected the option the variable has data, if not the variable data is missing. Example below
ethnicity variables.PNG
ethnicity variables.PNG (51.92 KiB) Viewed 421 times

I have seen solutions when the data in the columns are mutually exclusive or if people want to only keep one of the responses. Here instead I want to have the variable reflect their race/ethnicity selected BUT if they selected more than one response, then I want it to create a new category (i.e., "Multiracial").

I have done this in SPSS myself, but I have students in my class use Jamovi and I've not been able to advise them how to make this work for their data they have collected. This is the SPSS code that I use, for reference.

COMPUTE ethnicity=sysmis.
IF Q10_1=1 ethnicity=1.
IF Q10_11=1 ethnicity=2.
IF Q10_12=1 ethnicity=3.
IF Q10_14=1 ethnicity=4.
IF Q10_7=1 ethnicity=5.
IF Q10_8=1 ethnicity=6.
IF Q10_13=1 ethnicity=7.
IF Q10_3=1 ethnicity=8.
IF ((Q10_11=1) & (Q10_1=1)) ethnicity=9.
IF ((Q10_11=1) & (Q10_12=1)) ethnicity=9.
IF ((Q10_12=1) & (Q10_1=1)) ethnicity=9.
IF ((Q10_1=1) & (Q10_14=1)) ethnicity=9.
IF ((Q10_12=1) & (Q10_14=1)) ethnicity=9.
IF ((Q10_1=1) & (Q10_12=1)) ethnicity=9.
IF ((Q10_12=1) & (Q10_7=1)) ethnicity=9.
Execute.

Is there are way to do this in Jamovi? I tried some responses from ChatGPT for doing a computed variable but they didn't work with my data file.
User avatar
jonathon
Posts: 2750
Joined: Fri Jan 27, 2017 10:04 am

Re: Combine Multiple Non-Mutually Exclusive Variables

Post by jonathon »

Hi,

thanks for raising this. so called "multiple response variables" are something of an area of weakness in jamovi at the moment.

i've made a couple of changes to jamovi to better support this; i've added an ignore_missing argument to the HLOOKUP() function, and i've added a COUNT() function too. these will go out in the next release. (I assume we're probably too late for your class, but let me know if it would be helpful if i pushed the new version out now).

IF(
COUNT(Q10_1, Q10_11, Q10_12, Q10_14, Q10_7, Q10_8, Q10_13, Q10_3) > 1,
"Multi-racial",
HLOOKUP(1, Q10_1, Q10_11, Q10_12, Q10_14, Q10_7, Q10_8, Q10_13, Q10_3, ignore_missing=1))

the HLOOKUP(1, ... finds the first value in Q10_1, Q10_11, etc. and when called with ignore_missing=1, it finds the first non missing value.

jonathon
User avatar
reason180
Posts: 313
Joined: Mon Jul 24, 2017 4:56 pm

Re: Combine Multiple Non-Mutually Exclusive Variables

Post by reason180 »

Currently, this works, though it's not very concise . . .
-
RecodeMultiselect.png
RecodeMultiselect.png (64.74 KiB) Viewed 392 times
c.lapan
Posts: 2
Joined: Mon Nov 25, 2024 8:47 pm

Re: Combine Multiple Non-Mutually Exclusive Variables

Post by c.lapan »

Oh this worked!! Thank you so much @reason180.

I would look forward to a simpler solution in the future, but I will happily save this as a solution for now. I appreciate it!

Thank you Jonathan for keeping this in mind as a future fix.
Post Reply