WrightMap Tutorial 3

[This article was first published on R on WrightMap, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Plotting Multidimensional & Polytomous Models

Updated Fri 24-Apr-2020

Multidimensional models

We will need again to load RColorBrewer for this example.

install.packages("RColorBrewer")
library(RColorBrewer)

We start by creating mock person and item estimates.

For the person proficiencies we create a matrix with five columns of 1000 values each.

set.seed(2020)
mdim.sim.thetas <- matrix(rnorm(5000), ncol = 5)

Since this will start with a dichotomous model as an example, we’ll generate a single column for thresholds for now.

mdim.sim.thresholds <- runif(10, -3, 3)

Okay, let’s see what the Wright Map looks like for this.

wrightMap(mdim.sim.thetas, mdim.sim.thresholds)

That doesn’t look right. Let’s adjust the proportion of the map’s parts.

wrightMap(mdim.sim.thetas, mdim.sim.thresholds, item.prop = 0.5)

Let’s change the dimensions names.

wrightMap(mdim.sim.thetas, mdim.sim.thresholds, item.prop = 0.5
    , dim.names = c("Algebra", "Calculus", "Trig", "Stats", "Arithmetic"))

And let’s give them some color.

wrightMap(mdim.sim.thetas, mdim.sim.thresholds, item.prop = 0.5
    , dim.names = c("Algebra", "Calculus", "Trig", "Stats", "Arithmetic")
    , dim.color = brewer.pal(5, "Set1"))

And let’s associate the items with each dimension.

wrightMap(mdim.sim.thetas, mdim.sim.thresholds, item.prop = 0.5
    , dim.names = c("Algebra", "Calculus", "Trig", "Stats", "Arithmetic")
    , dim.color = brewer.pal(5, "Set1"), show.thr.lab = FALSE
    , thr.sym.col.fg = rep(brewer.pal(5, "Set1"), each = 2)
    , thr.sym.col.bg = rep(brewer.pal(5, "Set1"), each = 2)
    , thr.sym.cex = 2, person.side = personDens)

Polytomous models

All right, let’s look at a Rating Scale Model. First, let’s generate three dimensions of person estimates.

rsm.sim.thetas <- data.frame(d1 = rnorm(1000, mean = -0.5, sd = 1), d2 = rnorm(1000, 
    mean = 0, sd = 1), d3 = rnorm(1000, mean = +0.5, sd = 1))

Now let’s generate the thresholds for the polytomous items. We’ll make them a matrix where each row is an item and each column a level.

items.loc <- sort(rnorm(10))

rsm.sim.thresholds <- data.frame(l1 = items.loc - 1, l2 = items.loc - 0.5
    , l3 = items.loc + 0.5, l4 = items.loc + 1)

rsm.sim.thresholds

Let’s look at the Wright Map!

wrightMap(rsm.sim.thetas, rsm.sim.thresholds)

Let’s assign a color for each level

itemlevelcolors <- matrix(rep(brewer.pal(4, "Set1"), 10), byrow = TRUE, ncol = 4)

itemlevelcolors

And now make a Wright Map with them

wrightMap(rsm.sim.thetas, rsm.sim.thresholds, thr.sym.col.fg = itemlevelcolors
    , thr.sym.col.bg = itemlevelcolors)

But we also want to indicate which dimension they belong… with symbols

itemdimsymbols <- matrix(c(rep(16, 12), rep(17, 12), rep(18, 16))
    , byrow = TRUE, ncol = 4)

itemdimsymbols

wrightMap(rsm.sim.thetas, rsm.sim.thresholds, show.thr.lab = FALSE
    , thr.sym.col.fg = itemlevelcolors, thr.sym.col.bg = itemlevelcolors
    , thr.sym.pch = itemdimsymbols, thr.sym.cex = 2)

Additionally, we may want to clearly indicate which item parameters are associated with each item. We can draw lines that connect all parameters connected to an item using the vertLines parameter.

```R wrightMap(rsm.sim.thetas, rsm.sim.thresholds, show.thr.lab = FALSE , thr.sym.col.fg = itemlevelcolors, thr.sym.col.bg = itemlevelcolors , thr.sym.pch = itemdimsymbols, thr.sym.cex = 2, vertLines = TRUE)

To leave a comment for the author, please follow the link and comment on their blog: R on WrightMap.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)