pystatsmodels 2-way ANOVA interaction graph Median (not Mean)

64 views
Skip to first unread message

Muffin Man Caniko

unread,
Apr 7, 2023, 7:24:52 AM4/7/23
to pystatsmodels
Hello,

I am a novice user of python for stats, I have some very old data that I'd like to plot for median effect size (as the data was generated/normalized with median, not mean). When I feed this old data, the x-axis is a little bit off as the original data was normalized using median values of a baseline group. Is there a way to make Y axis display median difference rather than mean? I could go back and re-normalize the data but that'll take some time. Attaching an image that shows the code and what I'm trying to convey. 

Thanks

-C.J

Screenshot_interactionplotmeandifference.png

josef...@gmail.com

unread,
Apr 7, 2023, 11:08:36 AM4/7/23
to pystat...@googlegroups.com
Try using the `func` keyword in the interaction_plot

the default is func=np.mean
Try interaction_plot(..., func=np.median)

I never tried this, and AFAICS, there are no unit tests for functions other than np.mean.

The code uses
plot_data = data.groupby(['trace', 'x']).aggregate(func).reset_index()

So func can be anything that works with pandas aggregate. see docstring

Josef

--
You received this message because you are subscribed to the Google Groups "pystatsmodels" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pystatsmodel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pystatsmodels/b1aebc23-73aa-458c-8625-2afc28179a65n%40googlegroups.com.

Muffin Man Caniko

unread,
Apr 8, 2023, 6:39:31 AM4/8/23
to pystat...@googlegroups.com
Thanks Josef,  by applying your suggestion, it seems like my baseline/control group as centered around 0 for 8 week old group which is what I would expect given that the data was normalized relative to this group. The y-axis label also changed to "median of ..." in lieu of "mean of..." so that is a good confirmation of events too I suppose:

image.png

You received this message because you are subscribed to a topic in the Google Groups "pystatsmodels" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pystatsmodels/tYbHAIs-Foo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pystatsmodel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pystatsmodels/CAMMTP%2BCnu18TOKmJeGQSfq7ba7Le1EVgF8pT%3DoXcvXqum%2BV2nQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages