GGPLOT - DIF analysis (Is it possible to change the plot?)

45 views
Skip to first unread message

Cursos Psi

unread,
Mar 6, 2018, 4:05:55 PM3/6/18
to mirt-package
Dear Dr. Phil, 
I'm trying to use ggplot to plot a DIF analysis I conducted with my dataset (two groups: male and females). I've found your code here and it helped me a lot. Unfortunately, I'm afraid I could not use this script to plot DIF analysis when I have two groups (That is my case). Could you please help me (and, probably, other mirt users) ?

I want to transform this output:
plot(mod_metric, type='info')


To something like this output
plt <- plot(mod_metric, type='info') #store the object
plt$panel.args
pltdata <- data.frame(lapply(plt$panel.args, function(x) do.call(cbind, x))[[1]])
ggplot(pltdata, aes(x, y)) + 
  geom_line(size = 1.5) + 
  labs(x="ability", y="I(Theta)")


I know this question is much more a programming question than a mirt question, but I've tried to ask on stackoverflow and they did not accepted it.

Thanks.

Cursos Psi

unread,
Mar 6, 2018, 4:11:13 PM3/6/18
to mirt-package

Phil Chalmers

unread,
Mar 6, 2018, 11:52:46 PM3/6/18
to Cursos Psi, mirt-package
It looks like you missed the grouping variable within the defined data. You'd need to locate and pull that out as well in order to properly map the functions (here it's clearly that lines are being drawn from one group and then the next). HTH.

Phil

--
You received this message because you are subscribed to the Google Groups "mirt-package" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mirt-package+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Cursos Psi

unread,
Mar 7, 2018, 8:34:27 AM3/7/18
to mirt-package
Dear Dr. Phil, 
thanks. I've realized I forgot this grouping variable, but I don't know how to do that. Do you have any code or tutorial that I can learn from ?
If you don't, that's ok and, again, thanks much for all support you always provide.

Phil

To unsubscribe from this group and stop receiving emails from it, send an email to mirt-package...@googlegroups.com.

Phil Chalmers

unread,
Mar 7, 2018, 9:49:20 AM3/7/18
to Cursos Psi, mirt-package
If you check out the structure of the lattice plot (via str(your_plot)) you should be able to locate a list element corresponding to the grouping variable. Lattice must have stored it *somewhere*, otherwise it too would have  it's plot look like yours. Try digging around for it in the object structure, and let us know if you can locate it. Cheers.

Phil

To unsubscribe from this group and stop receiving emails from it, send an email to mirt-package+unsubscribe@googlegroups.com.

Cursos Psi

unread,
Mar 7, 2018, 4:38:06 PM3/7/18
to mirt-package
Ok!
I'll do that! 
Thank you
Reply all
Reply to author
Forward
0 new messages