How does jamovi calculate grouped z-scores?

Discuss the jamovi platform, possible improvements, etc.
Post Reply
jmjamison
Posts: 8
Joined: Fri May 10, 2019 5:37 am

How does jamovi calculate grouped z-scores?

Post by jmjamison »

I've been asked to create an R script that can calculate z-scores for var1 grouped by var2. Jamovi does this really easily using the compute function "Z(var1, group_by=var2)". But how does it do the grouping? I've been searching for 2 hours how to script this in R and I can't find a script that works :(

Any chance we could share the underlying code that jamovi is using to calculate the grouped z-scores?
User avatar
MAgojam
Posts: 421
Joined: Thu Jun 08, 2017 2:33 pm
Location: Parma (Italy)

Re: How does jamovi calculate grouped z-scores?

Post by MAgojam »

jmjamison wrote: Any chance we could share the underlying code that jamovi is using to calculate the grouped z-scores?
Hi, @jmjamison.
Take a look at this screenshot if that's what you're looking for.
ScreenShot.PNG
ScreenShot.PNG (66.4 KiB) Viewed 5952 times
Cheers,
Maurizio
User avatar
jonathon
Posts: 2613
Joined: Fri Jan 27, 2017 10:04 am

Re: How does jamovi calculate grouped z-scores?

Post by jonathon »

mz's your man,

the group_by stuff is actually implemented in python, and it's implemented as part of a complex AST system, so it's not simply a few lines of code you can copy/paste unfortunately.

but mz's solution is your ticket.

cheers

jonathon
jmjamison
Posts: 8
Joined: Fri May 10, 2019 5:37 am

Re: How does jamovi calculate grouped z-scores?

Post by jmjamison »

Wow, I didn't even know that we use Python under the hood. Makes sense and answers a few questions. Thanks @jonathon

And thanks @MAgojam for going the extra mile and creating a usable script for R. You have a really clean logic in your script. Unfortunately, my dataset has >1400 groups, so I'll need to automate the grouping. But you gave me the idea to test a few methods using a toy dataset like yours, and one started working. So I think I'll have to debug my data cleaning before I'm able to solve my standardization by groups anyway. Thanks for your input :)
Post Reply