sim_TIRT_data: Simulate Thurstonian IRT data

Description Usage Arguments Value Examples

View source: R/simulations.R

Description

Simulate Thurstonian IRT data

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
sim_TIRT_data(
  npersons,
  ntraits,
  lambda,
  gamma,
  psi = NULL,
  Phi = NULL,
  eta = NULL,
  family = "bernoulli",
  nblocks_per_trait = 5,
  nitems_per_block = 3,
  comb_blocks = c("random", "fixed")
)

Arguments

npersons

Number of persons.

ntraits

Number of traits.

lambda

Item factor loadings.

gamma

Baseline attractiveness parameters of the first item versus the second item in the pairwise comparisons. Can be thought of as intercept parameters.

psi

Optional item uniquenesses. If not provided, they will be computed as psi = 1 - lambda^2 in which case lambda are taken to be the standardized factor loadings.

Phi

Optional trait correlation matrix from which to sample person factor scores. Only used if eta is not provided.

eta

Optional person factor scores. If provided, argument Phi will be ignored.

family

Name of assumed the response distribution. Either "bernoulli", "cumulative", or "gaussian".

nblocks_per_trait

Number of blocks per trait.

nitems_per_block

Number of items per block.

comb_blocks

Indicates how to combine traits to blocks. "fixed" implies a simple non-random design that may combine certain traits which each other disproportionally often. We thus recommend to use a "random" block design (the default) that combines all traits with all other traits equally often on average.

Value

A data.frame of the same structure as returned by make_TIRT_data. Parameter values from which the data were simulated are stored as attributes of the returned object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# simulate some data
sdata <- sim_TIRT_data(
  npersons = 100,
  ntraits = 3,
  nblocks_per_trait = 4,
  gamma = 0,
  lambda = c(runif(6, 0.5, 1), runif(6, -1, -0.5)),
  Phi = diag(3)
)

# take a look at the data
head(sdata)
str(attributes(sdata))


# fit a Thurstonian IRT model using lavaan
fit <- fit_TIRT_lavaan(sdata)
print(fit)

thurstonianIRT documentation built on Aug. 7, 2020, 9:07 a.m.