4
$\begingroup$

I have conducted an IRT analysis using package ltm in R 2.10.

fit1 <- grm(data)

When producing plots of item response characteristic curves (ICCs),

plot(fit1)

the text "Item response characteristic curves - Item:NAME" is printed as the main title of each plot. NAME is substituted with the actual name of the items in the dataset.

A common practice is to present all the individual ICC plots on a single page, and then all that is needed in the title of each plot is the NAME (or at the most "Item: NAME").

I have not been able to achieve this, if I create a vector with the actual item names (e.g. v1, v2, v3...Vn) they are all used as the title in each of the plots.

What I would like to achieve is to have the title of each plot simply read "Item: NAME" where NAME is replaced/pasted with the names of the actual variables in my data.

The variable names themselves are available in the coefficients fit1 object, and can be retrieved with names(fit1$coefficients).

Anyone have a suggestion for how to achieve this?

Reproducible sample (thanks @Chi)

dat <- Science[c(1,3,4,7)]
fit1 <- grm(dat)
par(mfrow = c(2,2))
plot(fit1)

This plots each of the four ICCs on the same device, but all titles contain the abovementioned text that I wish to remove. It also contains the text "Item: NAME" (i.e. comfort, environment, work, benefit) which I would like to retain.

$\endgroup$

1 Answer 1

3
$\begingroup$

Try using the argument main= when calling plot(), e.g.

dat <- Science[c(1,3,4,7)]
fit1 <- grm(dat)
plot(fit1, items=1, main=paste("Item", names(dat)[1], sep=": "))

See help(plot.grm).

Also, you can embed all ICC curves in the same figure by using par(), e.g.

opar <- par(mfrow=c(2,2))
for (i in 1:4)
  plot(fit1, items=i, main=paste("Item", names(dat)[i], sep=": "))
par(opar)
$\endgroup$
6
  • $\begingroup$ @Chi Thanks! This works, but means I have to plot each item individually (and combine them with par). What I was hoping for was to simply obtain the same result by using par(mfrow=c(3,3)) and simply plot(fit1, 'some edits to 'main='") which gives me all the plots (9 in my case). $\endgroup$
    – Tormod
    Commented Oct 7, 2010 at 6:14
  • $\begingroup$ @Tormod I'm afraid you can't. Look at the R code for that function (just type plot.grm at the R prompt or edit(plot.grm)) near line 52 and 91: Dimitri R. automatically prefixes the title if missing and append "Item". $\endgroup$
    – chl
    Commented Oct 7, 2010 at 6:25
  • $\begingroup$ @Chi Thanks again! Still, your solution works fine so I am still able to achieve what I want, albeit with a few more lines of code. $\endgroup$
    – Tormod
    Commented Oct 7, 2010 at 6:31
  • $\begingroup$ @Tormod The same applies for the eRm package. It's difficult to provide users with both a friendly and generic interface :( $\endgroup$
    – chl
    Commented Oct 7, 2010 at 6:40
  • $\begingroup$ @Tormod It's just my humble opinion: Would it be troublesome if you created another function like plot2.grm which does not prefix the title? If you are going to use the form a lot, it would be better considering simplicity of the code!!! (+1) for nice work $\endgroup$
    – KH Kim
    Commented Sep 3, 2012 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.