Hello all,
I recently came across Jamovi and am very happy with it. However, as part of my research, I ran into a problem that I could not solve myself through trial and error. So I wanted to ask if it is possible to compute a new nominal variable from two dichotomous variables. In the specific case, the two variables are: Anorexia nervosa (1=yes, 2=no) and atypical anorexia nervosa (1=yes, 2=no). I would now like to compute a new variable with (1= Anorexia nervosa, 2= Atypical anorexia nervosa, 3= No anorexia nervosa).
To my limited understanding, this should be logically possible since all AN, atyp AN and no AN are mutually exclusive.
I tried using the filter code, but unfortunately I did not succeed.
IF(AN==1, atypAN==2) gives me all cases with AN.
IF(AtypAN==1, AN==2) gives me all cases with atypical AN.
But somehow I can't combine these two codes together.
Is it possible to compute a new nominal variable from two dichotomous variables?
Thanks a lot!
New nominal variable from two dichotomous variables?
Re: New nominal variable from two dichotomous variables?
you can nest if statements like this:
IF(AN == 'yes', IF(AtypeAN == 'no', 'Anorexia nervosa', 'Atypical anorexia nervosa'), 'No anorexia nervosa')
cheers
jonathon
IF(AN == 'yes', IF(AtypeAN == 'no', 'Anorexia nervosa', 'Atypical anorexia nervosa'), 'No anorexia nervosa')
cheers
jonathon
Re: New nominal variable from two dichotomous variables?
Hi, @Psych.
Do you think the screenshot that I am attaching could be useful to you? Cheers,
Maurizio
Do you think the screenshot that I am attaching could be useful to you? Cheers,
Maurizio
Re: New nominal variable from two dichotomous variables?
Hi Jonathon and Maurizio,
Thanks for your answers, you have helped me a lot! I was not even aware of this possibility. Really great to have such an active community!
The first code didn't quite work, so I tried a bit myself and it worked with that
IF('Anorexia nervosa' == 2, IF('Atypical Anorexia' == 2, 'No AN', 'Atypical AN'), 'Anorexia nervosa')
I am very happy that it worked. I don't quite understand the logic behind it yet, unfortunately.
I'll try it:
AN ==2, Atypical AN == 2 if both are true, it is 'No Anorexia Nervosa', IF Atypical AN is not 2 (then it is 1) it is Atypical Anorexia Nervosa, otherwise it's Anorexia Nervosa.
Is there anywhere to learn more about variable generation codes? It's a stupid question, but are these the same codes I would use in R?
Thanks for your answers, you have helped me a lot! I was not even aware of this possibility. Really great to have such an active community!
The first code didn't quite work, so I tried a bit myself and it worked with that
IF('Anorexia nervosa' == 2, IF('Atypical Anorexia' == 2, 'No AN', 'Atypical AN'), 'Anorexia nervosa')
I am very happy that it worked. I don't quite understand the logic behind it yet, unfortunately.
I'll try it:
AN ==2, Atypical AN == 2 if both are true, it is 'No Anorexia Nervosa', IF Atypical AN is not 2 (then it is 1) it is Atypical Anorexia Nervosa, otherwise it's Anorexia Nervosa.
Is there anywhere to learn more about variable generation codes? It's a stupid question, but are these the same codes I would use in R?
Re: New nominal variable from two dichotomous variables?
the little fx button beside the formula will give you a list of the different functions available.
when we nest IF()'s we take the result of the inner IF(), i.e.
IF('Atypical Anorexia' == 2, 'No AN', 'Atypical AN')
and the result of that gets substituted into the outer IF(), where the X is:
IF('Anorexia nervosa' == 2, X, 'Anorexia nervosa')
in this way we can take the results of different calculations and build up complex relationships.
the computed variables are designed to be familiar if you're coming from excel ... and no, they won't work in R.
cheers
jonathon
when we nest IF()'s we take the result of the inner IF(), i.e.
IF('Atypical Anorexia' == 2, 'No AN', 'Atypical AN')
and the result of that gets substituted into the outer IF(), where the X is:
IF('Anorexia nervosa' == 2, X, 'Anorexia nervosa')
in this way we can take the results of different calculations and build up complex relationships.
the computed variables are designed to be familiar if you're coming from excel ... and no, they won't work in R.
cheers
jonathon
Re: New nominal variable from two dichotomous variables?
If you've never done, pop in the archives of Jamovi Blog.Psych wrote:Is there anywhere to learn more about variable generation codes?
https://blog.jamovi.org/archives.html
You will find helpful tips including
Computed variables in jamovi, Transforming and recoding variables in jamovi,
and so on.
Cheers,
Maurizio
Re: New nominal variable from two dichotomous variables?
Thanks a lot again