# WrightMap and TAM – Example continued…

December 29, 2014
By

(This article was first published on R Snippets for IRT, and kindly contributed to R-bloggers)

As a follow up on the previous about integrating the `TAM` and `WrightMap` packages, we received a message from one of the `TAM` developers, Alexander Robitzsch, suggesting that it is possible to generate the Wright Map directly from the MML estimated distribution (instead of using the WLE estimates used in the previous post).

``````library(TAM)
library(WrightMap)
data( sim.rasch )
str( sim.rasch )
dat <- sim.rasch

# Run Rasch Model
mod1 <- tam.mml( dat )
summary( mod1 )
``````

After estimating the Rasch model in our data, we can get the item parameters directly from our model object:

``````difficulties <- tam.threshold( mod1 )
``````

Now, for the new part, Alexander has sent us this snippet to recover the estimated person distribution:

``````uni.proficiency <- rep( mod1\$theta[,1] , round( mod1\$pi.k * mod1\$ic\$n) )
``````

This extracts the ability distribution node locations and weights, and uses them to generate a vector of abilities that can be used to plot that distribution on `wrightMap`:

``````wrightMap( thetas = uni.proficiency, thresholds = mod1\$xsi[,1], label.items.rows = 3)
``````

This final Wright Map shows the distribution based on the nodes and weights estimated directly as part of the marginal maximum likelihood estimation, without needing to resort to generating person estimates on a separate step.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...