Compute Variable with if...than....

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)
User avatar
MAgojam
Posts: 421
Joined: Thu Jun 08, 2017 2:33 pm
Location: Parma (Italy)

Re: Compute Variable with if...than....

Post by MAgojam »

Hey @Lauri,
fix the Computed Variable C with this:

Code: Select all

IFMISS(A or B, 0, IF(A == 1 or B == 1, 1, 0))
Cheers,
Maurizio
User avatar
jonathon
Posts: 2609
Joined: Fri Jan 27, 2017 10:04 am

Re: Compute Variable with if...than....

Post by jonathon »

hi,

so a missing value in statistics means "don't know", so that's why IF(A == 1 or B == 1) results in a "don't know" when both A and B are missing, or where one of them is zero, and the other is missing -- without those values we "don't know".

how about the following?

IFMISS(A, 0, A) or IFMISS(B, 0, B)

jonathon
Lauri
Posts: 12
Joined: Mon Nov 28, 2022 10:32 am

Re: Compute Variable with if...than....

Post by Lauri »

Hey guys thank you so much - I got the solution with your support !!!

Just one mystery remains:
IFMISS(h_1 or h_4 or h_5 or h_7, 0, IF((h_1 == 1 and h_4 > 1 and h_5 == 0) or (h_7 == 1), 1, 0))

I get the correct result in all cases except for this case:
(h_1 == 1 and h_4 > 1 and h_5 == 0) - > not fulfilled
and for the second term: (h_7 == 1) - > there is no value (so no value for variable h_7)

What is my misconception?
Thank you guys !
User avatar
MAgojam
Posts: 421
Joined: Thu Jun 08, 2017 2:33 pm
Location: Parma (Italy)

Re: Compute Variable with if...than....

Post by MAgojam »

Hey @Lauri,
is this what you were looking for?
screenshot.PNG
screenshot.PNG (40.35 KiB) Viewed 1503 times

Code: Select all

IF(IFMISS(h_1,0,h_1)==1 and IFMISS(h_4,0,h_4)>1 and IFMISS(h_5,0,h_5)==0 or IFMISS(h_7,0,h_7)==1,1,0)
Cheers,
Maurizio
Lauri
Posts: 12
Joined: Mon Nov 28, 2022 10:32 am

Re: Compute Variable with if...than....

Post by Lauri »

Amazing - thank you very much Maurizio!!!
Lauri
Posts: 12
Joined: Mon Nov 28, 2022 10:32 am

Table $ setRow (): value ´est´ is not atomic

Post by Lauri »

When adding another covariate in the calculation of a binominal logistic regression, this error message appeared. I have tried various things, but the error message persists. Does anyone have any ideas? Thanks a lot
User avatar
jonathon
Posts: 2609
Joined: Fri Jan 27, 2017 10:04 am

Re: Compute Variable with if...than....

Post by jonathon »

hmm ... i think we need to start from a truth table. is this correct?

A, B, C
0, 0, 0
0, 1, 1
0, NA, 0,
1, 0, 1
1, 1, 1
1, NA, 1
NA, 0, 0
NA, 1, 1
NA, NA, 0
Lauri
Posts: 12
Joined: Mon Nov 28, 2022 10:32 am

Re: Compute Variable with if...than....

Post by Lauri »

Yes, that is correct
User avatar
jonathon
Posts: 2609
Joined: Fri Jan 27, 2017 10:04 am

Re: Compute Variable with if...than....

Post by jonathon »

i feel like this ought to do it:

IFMISS(A, 0, A) or IFMISS(B, 0, B)

a slightly longer way might be to recode A and B into separate columns ... this is nice and expressive as it makes clear that you're 'recoding' the missing values in your columns. and then perform the 'or' on the resultant columns.

jonathon
Post Reply