Using group_by with multiple factors in a calculation of z-scores

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
User avatar
FunnyBikeRider
Posts: 2
Joined: Tue Feb 21, 2023 9:39 am
Location: London, UK
Contact:

Using group_by with multiple factors in a calculation of z-scores

Post by FunnyBikeRider »

I am trying to calculate z scores (in order to detect outliers) for a number of groups in my data set split by two different factors (e.g., a study in which 2 distinct groups of subjects participated in a listening task in two different conditions). I see that splitting by one factor is straightforward, with a command like Z(uLevs, group_by=CondCode) but is it not possible to split by more than one factor? This is a very common situation and I cannot find any relevant documentation about it. Thanks!
User avatar
jonathon
Posts: 2874
Joined: Fri Jan 27, 2017 10:04 am

Re: Using group_by with multiple factors in a calculation of z-scores

Post by jonathon »

so one way you could do it is create a column with a level for each group combo. so with the Tooth Growth data set for example, we could create a new computed column with the formula `supp + dose` ... this will result in a column with 6 levels with values like `VC 500`, `OJ 2000`, etc. and then you could use that column with a group_by. (note that the supp + dose, only works because one of the columns is text ... if both supp and dose were numeric, you could have to convert one or both of them to text, i.e. TEXT(supp) + dose.)

or, you could do it all in one formula like this:

Screenshot 2025-08-06 at 10.05.46.png
Screenshot 2025-08-06 at 10.05.46.png (168.29 KiB) Viewed 3853 times
Post Reply