Learn R Programming

xxIRT (version 2.0.3)

irt_stats: IRT Utility Functions

Description

irt_stats provides a friendly interface to compute statistics

irt_select subsets data in an IRT model

irt_sample randomly samples data in an IRT model

irt_rescale rescales parameters in a 3PL model

Usage

irt_stats(x, stats = c("prob", "info", "lik", "loglik"), summary = NULL,
  fun = NULL, ...)

irt_select(x, people_index = NULL, item_index = NULL)

irt_sample(x, n.people = NULL, n.items = NULL)

irt_rescale(x, parameter = c("theta", "b"), mean = 0, sd = 1)

Arguments

x

an IRT model object

stats

the statistic to be computed

summary

the summarization direction

fun

the summarization function

...

other optional arguments

people_index

the indices of people to keep

item_index

the indices of items to keep

n.people

the number of people to sample

n.items

the number of items to sample

parameter

the rescaling parameter: 'theta' or 'b'

mean

the mean of the new scale

sd

the standard deviation of the new scale

Details

In irt_stats, use stats="prob" to compute probability, stats="info" to compute information, stats="lik" to compute likelihood, and stats="loglik" to compute log-likelihood. Use summary="people" to summarize results over items and summary="items" to summarize results over people.

Examples

Run this code
# NOT RUN {
 
# Compute probability, information, likelihood and log-likelihood
x <- model_3pl()$gendata(20, 5)
irt_stats(x, "prob")
irt_stats(x, "prob", "people", sum)
irt_stats(x, "info")
irt_stats(x, "info", "items", sum)
irt_stats(x, "lik")
irt_stats(x, "loglik")
# subset
x <- model_3pl()$gendata(10, 5)
irt_select(x, people_index=c(1, 3, 5))
irt_select(x, item_index=c(1, 3, 5))
# sample wihtout replacement
irt_sample(x, n.people=3)
irt_sample(x, n.items=3)
# sample with replacement
irt_sample(x, n.people=30)
irt_sample(x, n.items=30)
# rescale theta
x <- model_3pl()$gendata(20, 5)
c(mean(x$people$theta), sd(x$people$theta))
y <- irt_rescale(x, "theta", 0, 1)
c(mean(y$people$theta), sd(y$people$theta))
round(abs(irt_stats(x, "prob") - irt_stats(y, "prob")), 2)
# rescale b
c(mean(x$items$b), sd(x$items$b))
y <- irt_rescale(x, "b", 0, 1)
c(mean(y$items$b), sd(y$items$b))
round(abs(irt_stats(x, "prob") - irt_stats(y, "prob")), 2)
# }

Run the code above in your browser using DataLab