Title: | Thurstonian IRT Models |
---|---|
Description: | Fit Thurstonian Item Response Theory (IRT) models in R. This package supports fitting Thurstonian IRT models and its extensions using 'Stan', 'lavaan', or 'Mplus' for the model estimation. Functionality for extracting results, making predictions, and simulating data is provided as well. References: Brown & Maydeu-Olivares (2011) <doi:10.1177/0013164410375112>; Bürkner et al. (2019) <doi:10.1177/0013164419832063>. |
Authors: | Paul-Christian Bürkner [aut, cre], Angus Hughes [ctb], Trustees of Columbia University [cph] |
Maintainer: | Paul-Christian Bürkner <[email protected]> |
License: | GPL (>=3) |
Version: | 0.12.6 |
Built: | 2024-10-26 04:43:57 UTC |
Source: | https://github.com/paul-buerkner/thurstonianirt |
This package fits Thurstonian Item Response Theory (IRT) models
using 'Stan', 'lavaan', or 'Mplus'. To bring your data into the right
format, use the make_TIRT_data
function. Models can then be
fitted via fit_TIRT_stan
, fit_TIRT_lavaan
, or
fit_TIRT_mplus
depending on the desired model fitting engine.
Data from Thurstonian IRT models can be simulated via
sim_TIRT_data
.
Maintainer: Paul-Christian Bürkner [email protected]
Other contributors:
Angus Hughes [contributor]
Trustees of Columbia University [copyright holder]
Brown, A., & Maydeu-Olivares, A. (2011). Item response modeling of forced-choice questionnaires. Educational and Psychological Measurement, 71(3), 460-502. doi:10.1177/0013164410375112
Bürkner P. C., Schulte N., & Holling H. (2019). On the Statistical and Practical Limitations of Thurstonian IRT Models. Educational and Psychological Measurement. doi:10.1177/0013164419832063
Useful links:
Report bugs at https://github.com/paul-buerkner/thurstonianIRT/issues
Set up Correlation Matrices
cor_matrix(cors, dim, dimnames = NULL)
cor_matrix(cors, dim, dimnames = NULL)
cors |
vector of unique correlations |
dim |
Dimension of the correlation matrix |
dimnames |
Optional dimnames of the correlation matrix |
A correlation matrix
of dimension dim
.
cor_matrix(c(0.2, 0.3, 0.5), dim = 3)
cor_matrix(c(0.2, 0.3, 0.5), dim = 3)
Fit Thurstonian IRT models in lavaan
fit_TIRT_lavaan(data, estimator = "ULSMV", ...)
fit_TIRT_lavaan(data, estimator = "ULSMV", ...)
data |
An object of class |
estimator |
Name of the estimator that should be used.
See |
... |
Further arguments passed to
|
A 'TIRTfit'
object.
# load the data data("triplets") # define the blocks of items blocks <- set_block(c("i1", "i2", "i3"), traits = c("t1", "t2", "t3"), signs = c(1, 1, 1)) + set_block(c("i4", "i5", "i6"), traits = c("t1", "t2", "t3"), signs = c(-1, 1, 1)) + set_block(c("i7", "i8", "i9"), traits = c("t1", "t2", "t3"), signs = c(1, 1, -1)) + set_block(c("i10", "i11", "i12"), traits = c("t1", "t2", "t3"), signs = c(1, -1, 1)) # generate the data to be understood by 'thurstonianIRT' triplets_long <- make_TIRT_data( data = triplets, blocks = blocks, direction = "larger", format = "pairwise", family = "bernoulli", range = c(0, 1) ) # fit the data using lavaan fit <- fit_TIRT_lavaan(triplets_long) print(fit) predict(fit)
# load the data data("triplets") # define the blocks of items blocks <- set_block(c("i1", "i2", "i3"), traits = c("t1", "t2", "t3"), signs = c(1, 1, 1)) + set_block(c("i4", "i5", "i6"), traits = c("t1", "t2", "t3"), signs = c(-1, 1, 1)) + set_block(c("i7", "i8", "i9"), traits = c("t1", "t2", "t3"), signs = c(1, 1, -1)) + set_block(c("i10", "i11", "i12"), traits = c("t1", "t2", "t3"), signs = c(1, -1, 1)) # generate the data to be understood by 'thurstonianIRT' triplets_long <- make_TIRT_data( data = triplets, blocks = blocks, direction = "larger", format = "pairwise", family = "bernoulli", range = c(0, 1) ) # fit the data using lavaan fit <- fit_TIRT_lavaan(triplets_long) print(fit) predict(fit)
Fit Thurstonian IRT models in Mplus
fit_TIRT_mplus(data, ...)
fit_TIRT_mplus(data, ...)
data |
An object of class |
... |
Further arguments passed to
|
A 'TIRTfit'
object.
# load the data data("triplets") # define the blocks of items blocks <- set_block(c("i1", "i2", "i3"), traits = c("t1", "t2", "t3"), signs = c(1, 1, 1)) + set_block(c("i4", "i5", "i6"), traits = c("t1", "t2", "t3"), signs = c(-1, 1, 1)) + set_block(c("i7", "i8", "i9"), traits = c("t1", "t2", "t3"), signs = c(1, 1, -1)) + set_block(c("i10", "i11", "i12"), traits = c("t1", "t2", "t3"), signs = c(1, -1, 1)) # generate the data to be understood by 'thurstonianIRT' triplets_long <- make_TIRT_data( data = triplets, blocks = blocks, direction = "larger", format = "pairwise", family = "bernoulli", range = c(0, 1) ) ## Not run: # fit the data using Mplus fit <- fit_TIRT_mplus(triplets_long) print(fit) predict(fit) ## End(Not run)
# load the data data("triplets") # define the blocks of items blocks <- set_block(c("i1", "i2", "i3"), traits = c("t1", "t2", "t3"), signs = c(1, 1, 1)) + set_block(c("i4", "i5", "i6"), traits = c("t1", "t2", "t3"), signs = c(-1, 1, 1)) + set_block(c("i7", "i8", "i9"), traits = c("t1", "t2", "t3"), signs = c(1, 1, -1)) + set_block(c("i10", "i11", "i12"), traits = c("t1", "t2", "t3"), signs = c(1, -1, 1)) # generate the data to be understood by 'thurstonianIRT' triplets_long <- make_TIRT_data( data = triplets, blocks = blocks, direction = "larger", format = "pairwise", family = "bernoulli", range = c(0, 1) ) ## Not run: # fit the data using Mplus fit <- fit_TIRT_mplus(triplets_long) print(fit) predict(fit) ## End(Not run)
Fit Thurstonian IRT models in Stan
fit_TIRT_stan(data, init = 0, ...)
fit_TIRT_stan(data, init = 0, ...)
data |
An object of class |
init |
Initial values of the parameters.
Defaults to |
... |
Further arguments passed to
|
A 'TIRTfit'
object.
# load the data data("triplets") # define the blocks of items blocks <- set_block(c("i1", "i2", "i3"), traits = c("t1", "t2", "t3"), signs = c(1, 1, 1)) + set_block(c("i4", "i5", "i6"), traits = c("t1", "t2", "t3"), signs = c(-1, 1, 1)) + set_block(c("i7", "i8", "i9"), traits = c("t1", "t2", "t3"), signs = c(1, 1, -1)) + set_block(c("i10", "i11", "i12"), traits = c("t1", "t2", "t3"), signs = c(1, -1, 1)) # generate the data to be understood by 'thurstonianIRT' triplets_long <- make_TIRT_data( data = triplets, blocks = blocks, direction = "larger", format = "pairwise", family = "bernoulli", range = c(0, 1) ) # fit the data using Stan fit <- fit_TIRT_stan(triplets_long, chains = 1) print(fit) predict(fit)
# load the data data("triplets") # define the blocks of items blocks <- set_block(c("i1", "i2", "i3"), traits = c("t1", "t2", "t3"), signs = c(1, 1, 1)) + set_block(c("i4", "i5", "i6"), traits = c("t1", "t2", "t3"), signs = c(-1, 1, 1)) + set_block(c("i7", "i8", "i9"), traits = c("t1", "t2", "t3"), signs = c(1, 1, -1)) + set_block(c("i10", "i11", "i12"), traits = c("t1", "t2", "t3"), signs = c(1, -1, 1)) # generate the data to be understood by 'thurstonianIRT' triplets_long <- make_TIRT_data( data = triplets, blocks = blocks, direction = "larger", format = "pairwise", family = "bernoulli", range = c(0, 1) ) # fit the data using Stan fit <- fit_TIRT_stan(triplets_long, chains = 1) print(fit) predict(fit)
By default lavaan will return a value for degrees of freedom that ignores redundancies amongst the estimated model thresholds. This function corrects the degrees of freedom, and then recalculates the associated chi-square test statistic p-value and root mean square error of approximation (RMSEA).
## S3 method for class 'TIRTfit' gof(object, ...) gof(object, ...)
## S3 method for class 'TIRTfit' gof(object, ...) gof(object, ...)
object |
A |
... |
currently unused. |
Note this function is currently only implemented for lavaan.
A vector containing the chi-square value, adjusted degrees of freedom, p-value, and RMSEA.
# load the data data("triplets") # define the blocks of items blocks <- set_block(c("i1", "i2", "i3"), traits = c("t1", "t2", "t3"), signs = c(1, 1, 1)) + set_block(c("i4", "i5", "i6"), traits = c("t1", "t2", "t3"), signs = c(-1, 1, 1)) + set_block(c("i7", "i8", "i9"), traits = c("t1", "t2", "t3"), signs = c(1, 1, -1)) + set_block(c("i10", "i11", "i12"), traits = c("t1", "t2", "t3"), signs = c(1, -1, 1)) # generate the data to be understood by 'thurstonianIRT' triplets_long <- make_TIRT_data( data = triplets, blocks = blocks, direction = "larger", format = "pairwise", family = "bernoulli", range = c(0, 1) ) # fit the data using lavaan fit <- fit_TIRT_lavaan(triplets_long) gof(fit)
# load the data data("triplets") # define the blocks of items blocks <- set_block(c("i1", "i2", "i3"), traits = c("t1", "t2", "t3"), signs = c(1, 1, 1)) + set_block(c("i4", "i5", "i6"), traits = c("t1", "t2", "t3"), signs = c(-1, 1, 1)) + set_block(c("i7", "i8", "i9"), traits = c("t1", "t2", "t3"), signs = c(1, 1, -1)) + set_block(c("i10", "i11", "i12"), traits = c("t1", "t2", "t3"), signs = c(1, -1, 1)) # generate the data to be understood by 'thurstonianIRT' triplets_long <- make_TIRT_data( data = triplets, blocks = blocks, direction = "larger", format = "pairwise", family = "bernoulli", range = c(0, 1) ) # fit the data using lavaan fit <- fit_TIRT_lavaan(triplets_long) gof(fit)
Generate lavaan code for Thurstonian IRT models
make_lavaan_code(data)
make_lavaan_code(data)
data |
An object of class |
A character string of lavaan code for a Thurstonian IRT model.
lambdas <- c(runif(6, 0.5, 1), runif(6, -1, -0.5)) sim_data <- sim_TIRT_data( npersons = 100, ntraits = 3, nblocks_per_trait = 4, gamma = 0, lambda = lambdas, Phi = diag(3) ) cat(make_lavaan_code(sim_data))
lambdas <- c(runif(6, 0.5, 1), runif(6, -1, -0.5)) sim_data <- sim_TIRT_data( npersons = 100, ntraits = 3, nblocks_per_trait = 4, gamma = 0, lambda = lambdas, Phi = diag(3) ) cat(make_lavaan_code(sim_data))
Generate Mplus code for Thurstonian IRT models
make_mplus_code(data, iter = 1000, eta_file = "eta.csv")
make_mplus_code(data, iter = 1000, eta_file = "eta.csv")
data |
An object of class |
iter |
Maximum number of iterations of the model fitting algorithm. |
eta_file |
optional file name in which predicted trait scores should be stored. |
A list of Mplus code snippets to be interpreted by the MplusAutomation package.
sim_data <- 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) ) # show the created Mplus code lapply(make_mplus_code(sim_data), cat)
sim_data <- 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) ) # show the created Mplus code lapply(make_mplus_code(sim_data), cat)
Prepare data for Thurstonian IRT models fitted with lavaan or Mplus
make_sem_data(data)
make_sem_data(data)
data |
An object of class |
A data.frame
ready to be passed to lavaan
or Mplus.
# 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) ) # create data ready for use in SEM software sem_data <- make_sem_data(sdata) head(sem_data)
# 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) ) # create data ready for use in SEM software sem_data <- make_sem_data(sdata) head(sem_data)
Prepare data for Thurstonian IRT models fitted with Stan
make_stan_data(data)
make_stan_data(data)
data |
An object of class |
A list of data ready to be passed to Stan.
#' @examples # simulate some data sim_data <- 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) )
# create data ready for use in Stan stan_data <- make_stan_data(sim_data) str(stan_data)
Prepare data for Thurstonian IRT models
make_TIRT_data( data, blocks, direction = c("larger", "smaller"), format = c("ranks", "pairwise"), family = "bernoulli", partial = FALSE, range = c(0, 1) )
make_TIRT_data( data, blocks, direction = c("larger", "smaller"), format = c("ranks", "pairwise"), family = "bernoulli", partial = FALSE, range = c(0, 1) )
data |
An object of class |
blocks |
Object of class |
direction |
Indicates if |
format |
Format of the item responses. Either |
family |
Name of assumed the response distribution. Either
|
partial |
A flag to indicate whether partial comparisons are allowed
for responses stored in the |
range |
Numeric vector of length two giving the range of the
responses when using the |
A data.frame
in a specific format and with attributes ready
for use with other functions of the ThurstonianIRT package.
# load the data data("triplets") # define the blocks of items blocks <- set_block(c("i1", "i2", "i3"), traits = c("t1", "t2", "t3"), signs = c(1, 1, 1)) + set_block(c("i4", "i5", "i6"), traits = c("t1", "t2", "t3"), signs = c(-1, 1, 1)) + set_block(c("i7", "i8", "i9"), traits = c("t1", "t2", "t3"), signs = c(1, 1, -1)) + set_block(c("i10", "i11", "i12"), traits = c("t1", "t2", "t3"), signs = c(1, -1, 1)) # generate the data to be understood by 'thurstonianIRT' triplets_long <- make_TIRT_data( data = triplets, blocks = blocks, direction = "larger", format = "pairwise", family = "bernoulli", range = c(0, 1) ) # fit the data using Stan fit <- fit_TIRT_stan(triplets_long, chains = 1) print(fit) predict(fit)
# load the data data("triplets") # define the blocks of items blocks <- set_block(c("i1", "i2", "i3"), traits = c("t1", "t2", "t3"), signs = c(1, 1, 1)) + set_block(c("i4", "i5", "i6"), traits = c("t1", "t2", "t3"), signs = c(-1, 1, 1)) + set_block(c("i7", "i8", "i9"), traits = c("t1", "t2", "t3"), signs = c(1, 1, -1)) + set_block(c("i10", "i11", "i12"), traits = c("t1", "t2", "t3"), signs = c(1, -1, 1)) # generate the data to be understood by 'thurstonianIRT' triplets_long <- make_TIRT_data( data = triplets, blocks = blocks, direction = "larger", format = "pairwise", family = "bernoulli", range = c(0, 1) ) # fit the data using Stan fit <- fit_TIRT_stan(triplets_long, chains = 1) print(fit) predict(fit)
Predict trait scores of Thurstonian IRT models
## S3 method for class 'TIRTfit' predict(object, newdata = NULL, ...)
## S3 method for class 'TIRTfit' predict(object, newdata = NULL, ...)
object |
An object of class |
newdata |
Optional |
... |
Further arguments passed to the underlying methods. |
When predicting trait scores of new persons (via newdata
),
posterior medians of item parameters are used for predictions. This implies
that the uncertainty in the new trait scores is underestimated as the
uncertainty in the (posterior distribution of) item parameters is ignored.
A data frame with predicted trait scores.
Prepare blocks of items and incorporate information about which item belongs to which trait. A block of items is a set of two or more items presented and answered together by fully ranking them or selecting the most and/or least favorit in a forced choice format. A whole test usually contains several blocks and items may reappear in different blocks.
set_block(items, traits, names = items, signs = 1) empty_block()
set_block(items, traits, names = items, signs = 1) empty_block()
items |
Names of item comparisons to be combined into one block. Should correspond to variables in the data. |
traits |
Names of the traits to which each item belongs |
names |
Optional names of the items in the output. Can be used to equate parameters of items across blocks, if the same item was used in different blocks. |
signs |
Expected signs of the item loadings (1 or -1). |
set_block( items = c("i1", "i2", "i3"), traits = c("A", "B", "C") ) + set_block( items = c("i4", "i5", "i6"), traits = c("A", "B", "C") ) # Support items i1 and i4 were the same so that they have the same parameters set_block( items = c("i1", "i2", "i3"), traits = c("A", "B", "C"), names = c("item1", "item2", "item3") ) + set_block( items = c("i4", "i5", "i6"), traits = c("A", "B", "C"), names = c("item1", "item5", "item6") )
set_block( items = c("i1", "i2", "i3"), traits = c("A", "B", "C") ) + set_block( items = c("i4", "i5", "i6"), traits = c("A", "B", "C") ) # Support items i1 and i4 were the same so that they have the same parameters set_block( items = c("i1", "i2", "i3"), traits = c("A", "B", "C"), names = c("item1", "item2", "item3") ) + set_block( items = c("i4", "i5", "i6"), traits = c("A", "B", "C"), names = c("item1", "item5", "item6") )
Prepare blocks of items and incorporate information
about which item belongs to which trait from a pre-existing dataframe.
This is a wrapper function for set_block
, eliminating the need
to manually set each item, trait, name and sign (loading) info per block.
set_blocks_from_df( data, blocks = "block", items = "item", traits = "trait", names = items, signs = "sign" )
set_blocks_from_df( data, blocks = "block", items = "item", traits = "trait", names = items, signs = "sign" )
data |
A |
blocks |
Name of column vector denoting the block each item corresponds to. Each block must have an equal number of items. |
items |
Name of column vector denoting items to be combined into one block. Should correspond to variables in the data. |
traits |
Names of column vector denoting the traits to which each item belongs. |
names |
Optional column vector of item names in the output. Can be used to equate parameters of items across blocks, if the same item was used in different blocks. |
signs |
Name of column vector with expected signs of the item loadings (1 or -1). |
A block of items is a set of two or more items presented and answered together by fully ranking them or selecting the most and/or least favorite in a forced choice format. A whole test usually contains several blocks and items may reappear in different blocks.
block_info <- data.frame( block = rep(1:4, each = 3), items = c("i1", "i2", "i3", "i4", "i5", "i6", "i7", "i8", "i9", "i10", "i11", "i12"), traits = rep(c("t1", "t2", "t3"), times = 4), signs = c(1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1) ) blocks <- set_blocks_from_df( data = block_info, blocks = "block", items = "items", traits = "traits", signs = "signs" )
block_info <- data.frame( block = rep(1:4, each = 3), items = c("i1", "i2", "i3", "i4", "i5", "i6", "i7", "i8", "i9", "i10", "i11", "i12"), traits = rep(c("t1", "t2", "t3"), times = 4), signs = c(1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1) ) blocks <- set_blocks_from_df( data = block_info, blocks = "block", items = "items", traits = "traits", signs = "signs" )
Simulate Thurstonian IRT data
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") )
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") )
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 |
Phi |
Optional trait correlation matrix from which to sample
person factor scores. Only used if |
eta |
Optional person factor scores. If provided, argument
|
family |
Name of assumed the response distribution. Either
|
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.
|
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.
# 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)
# 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)
This data set contains synthetic data of the first 200 out of a total of 2000 participants on 4 triplets, originally generated as part of Brown and Maydeu-Olivares (2012). In each triplet, participants had to rank the three alternative items according to their preference. Responses were then converted into a set of dichotomous pairwise responses between all the three alternatives. More details can be found in Brown and Maydeu-Olivares (2012).
triplets
triplets
A data frame of 200 observations containing information on 12 variables. Overall, the 12 items measure 3 different traits. Items 1, 4, 7, and 10 load on trait 1, items 2, 5, 8, and 11 load on trait 2, and items 3, 6, 9, and 12 load on trait 3. Moreover, items 4, 9, and 11 are inverted.
Response preferences between item 1 and 2.
Response preferences between item 1 and 3.
Response preferences between item 2 and 3.
Response preferences between item 4 and 5.
Response preferences between item 4 and 6.
Response preferences between item 5 and 6.
Response preferences between item 7 and 8.
Response preferences between item 7 and 9.
Response preferences between item 8 and 9.
Response preferences between item 10 and 11.
Response preferences between item 10 and 12.
Response preferences between item 11 and 12.
Brown, A. & Maydeu-Olivares, A. (2012). Fitting a Thurstonian IRT model to forced-choice data using Mplus. Behavior Research Methods, 44, 1135–1147. DOI: 10.3758/s13428-012-0217-x
# load the data data("triplets") # define the blocks of items blocks <- set_block(c("i1", "i2", "i3"), traits = c("t1", "t2", "t3"), signs = c(1, 1, 1)) + set_block(c("i4", "i5", "i6"), traits = c("t1", "t2", "t3"), signs = c(-1, 1, 1)) + set_block(c("i7", "i8", "i9"), traits = c("t1", "t2", "t3"), signs = c(1, 1, -1)) + set_block(c("i10", "i11", "i12"), traits = c("t1", "t2", "t3"), signs = c(1, -1, 1)) # generate the data to be understood by 'thurstonianIRT' tdat <- make_TIRT_data( triplets, blocks, direction = "larger", format = "pairwise", family = "bernoulli", range = c(0, 1) ) # fit the data using Stan fit <- fit_TIRT_stan(tdat, chains = 1) print(fit) predict(fit)
# load the data data("triplets") # define the blocks of items blocks <- set_block(c("i1", "i2", "i3"), traits = c("t1", "t2", "t3"), signs = c(1, 1, 1)) + set_block(c("i4", "i5", "i6"), traits = c("t1", "t2", "t3"), signs = c(-1, 1, 1)) + set_block(c("i7", "i8", "i9"), traits = c("t1", "t2", "t3"), signs = c(1, 1, -1)) + set_block(c("i10", "i11", "i12"), traits = c("t1", "t2", "t3"), signs = c(1, -1, 1)) # generate the data to be understood by 'thurstonianIRT' tdat <- make_TIRT_data( triplets, blocks, direction = "larger", format = "pairwise", family = "bernoulli", range = c(0, 1) ) # fit the data using Stan fit <- fit_TIRT_stan(tdat, chains = 1) print(fit) predict(fit)