Title: | Estimation of Tree-Based Item Response Models |
---|---|
Description: | Helper functions and example data sets to facilitate the estimation of IRTree models from data with different shape and using different software. |
Authors: | Zhaojun Li, Ivailo Partchev and Paul De Boeck |
Maintainer: | Ivailo Partchev <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.0.0 |
Built: | 2024-11-04 05:52:39 UTC |
Source: | https://github.com/cran/irtrees |
Helper functions and example data sets to facilitate the estimation
of tree-based item Response models of the GLMM family with function
glmer
from the lme4
package
Ivailo Partchev <[email protected]>
De Boeck, P. and Partchev, I. (2012). IRTrees: Tree-Based Item Response Models of the GLMM Family, Journal of Statistical Software – Code Snippets, 48(1), 1–28. https://www.jstatsoft.org/v48/c01/.
Expands a wide-form matrix of item responses to a long-form data frame of sub-item responses
dendrify(mat, cmx)
dendrify(mat, cmx)
mat |
An integer matrix of IRT responses (columns represent items, rows represent respondents) |
cmx |
A mapping matrix with as many rows as there are response options for the items. |
A data frame with one row per sub-item response
Ivailo Partchev
De Boeck, P. and Partchev, I. (2012). IRTrees: Tree-Based Item Response Models of the GLMM Family, Journal of Statistical Software – Code Snippets, 48(1), 1–28. https://www.jstatsoft.org/v48/c01/.
mapping <- cbind(c(0,1,1), c(NA,0,1)) str(linrespT <- dendrify(linresp, mapping))
mapping <- cbind(c(0,1,1), c(NA,0,1)) str(linrespT <- dendrify(linresp, mapping))
Expands a wide-form file of item responses to a long-form file supporting structural mappings among latent variables
exogenize(mat, cmx, items=seq_len(ncol(mat)), endnode, crossitem=NULL)
exogenize(mat, cmx, items=seq_len(ncol(mat)), endnode, crossitem=NULL)
mat |
An integer matrix of IRT responses (columns represent items, rows represent respondents) |
cmx |
The mapping matrix. |
items |
A numeric vector with the column positions of all items
(measurement variables) in |
endnode |
A factor with the same length as |
crossitem |
A factor with the same length as |
A data frame with columns:
person |
a factor identifying the respondent; |
item |
a factor identifying the items; |
exo1 to exoS |
dummy variables identifying the internal nodes: these play the same role as |
endnode |
a factor identifying the end nodes and thus the endogeneous latent variables; |
crossitem |
a factor produced only for crossed designs, identifying the items that are crossed
with |
value |
the binary item responses. |
Ivailo Partchev
De Boeck, P. and Partchev, I. (2012). IRTrees: Tree-Based Item Response Models of the GLMM Family, Journal of Statistical Software – Code Snippets, 48(1), 1–28. https://www.jstatsoft.org/v48/c01/.
str(linlatT <- exogenize(linlat, cbind(c(1,0,0), c(1,1,0), c(0,1,0), c(0,1,1), c(0,0,1)), endnode = rep(1:3, each=10), cross = rep(1:10, 3)))
str(linlatT <- exogenize(linlat, cbind(c(1,0,0), c(1,1,0), c(0,1,0), c(0,1,1), c(0,0,1)), endnode = rep(1:3, each=10), cross = rep(1:10, 3)))
Convert a tree description in mermaid format into a mapping matrix that can be used with the remaining functions in the package.
graph2mx(td)
graph2mx(td)
td |
tree description in mermaid format |
the mapping matrix
Simulated example data set for a model with sequential-order latent variable models.
An IRT response matrix with 300 persons and 30 binary items.
De Boeck, P. and Partchev, I. (2012). IRTrees: Tree-Based Item Response Models of the GLMM Family, Journal of Statistical Software – Code Snippets, 48(1), 1–28. https://www.jstatsoft.org/v48/c01/.
str(linlat) str(linlatT <- exogenize(linlat, cbind(c(1,0,0), c(1,1,0), c(0,1,0), c(0,1,1), c(0,0,1)), endnode = rep(1:3, each=10), cross = rep(1:10, 3)))
str(linlat) str(linlatT <- exogenize(linlat, cbind(c(1,0,0), c(1,1,0), c(0,1,0), c(0,1,1), c(0,0,1)), endnode = rep(1:3, each=10), cross = rep(1:10, 3)))
Simulated example data set with linear hierarchical categories.
An IRT response matrix with 300 persons and 10 three-category items.
De Boeck, P. and Partchev, I. (2012). IRTrees: Tree-Based Item Response Models of the GLMM Family, Journal of Statistical Software – Code Snippets, 48(1), 1–28. https://www.jstatsoft.org/v48/c01/.
str(linresp) mapping <- cbind(c(0,1,1), c(NA,0,1)) str(linrespT <- dendrify(linresp, mapping))
str(linresp) mapping <- cbind(c(0,1,1), c(NA,0,1)) str(linrespT <- dendrify(linresp, mapping))
Recode a long format data frame to a long format IRTRees data frame in the case when items may have different tree structures
LtoL_multi.tree( data, cmx_list, item_list, id.col, item.col, resp.col, covar.col = NULL, time.col = NULL )
LtoL_multi.tree( data, cmx_list, item_list, id.col, item.col, resp.col, covar.col = NULL, time.col = NULL )
data |
a long-format (person-item-response) data set |
cmx_list |
a list including all tree structures |
item_list |
a list of vectors, with a length matching the length of |
id.col |
the person ID column |
item.col |
the item ID column |
resp.col |
the response column |
covar.col |
columns containing covariates |
time.col |
the time column. If not NULL, |
Many examples of mapping matrices are given in the vignette. Columns may be specified by numeric index or by name. Response categories must be coded with consecutive integers starting from 1, not 0. Missing data should be properly represented as NA.
Recode a long format data frame to a long format IRTrees data frame in the case when items have the same tree structure
LtoL_single.tree( data, cmx, id.col, item.col, resp.col, covar.col = NULL, time.col = NULL )
LtoL_single.tree( data, cmx, id.col, item.col, resp.col, covar.col = NULL, time.col = NULL )
data |
a long-format (person-item-response) data set |
cmx |
a a category-by-node mapping matrix |
id.col |
the person ID column |
item.col |
the item ID column |
resp.col |
the response column |
covar.col |
columns containing covariates |
time.col |
the time column. If not NULL, |
Many examples of mapping matrices are given in the vignette. Columns may be specified by numeric index or by name. Response categories must be coded with consecutive integers starting from 1, not 0. Missing data should be properly represented as NA.
Recode a long format data frame to a wide format IRTRees data frame in the case when items may have different tree structures
LtoW_multi.tree( data, cmx_list, item_list, id.col, item.col, resp.col, covar.col = NULL, time.col = NULL )
LtoW_multi.tree( data, cmx_list, item_list, id.col, item.col, resp.col, covar.col = NULL, time.col = NULL )
data |
a long-format (person-item-response) data set |
cmx_list |
a list including all tree structures |
item_list |
a list of vectors, with a length matching the length of |
id.col |
the person ID column |
item.col |
the item ID column |
resp.col |
the response column |
covar.col |
columns containing covariates |
time.col |
the time column. If not NULL, |
Many examples of mapping matrices are given in the vignette. Columns may be specified by numeric index or by name. Response categories must be coded with consecutive integers starting from 1, not 0. Missing data should be properly represented as NA.
Recode a long format data frame to a wide format IRTrees data frame in the case when items have the same tree structure
LtoW_single.tree( data, cmx, id.col, item.col, resp.col, covar.col = NULL, time.col = NULL )
LtoW_single.tree( data, cmx, id.col, item.col, resp.col, covar.col = NULL, time.col = NULL )
data |
a long-format (person-item-response) data set |
cmx |
a a category-by-node mapping matrix |
id.col |
the person ID column |
item.col |
the item ID column |
resp.col |
the response column |
covar.col |
columns containing covariates |
time.col |
the time column. If not NULL, |
Many examples of mapping matrices are given in the vignette. Columns may be specified by numeric index or by name. Response categories must be coded with consecutive integers starting from 1, not 0. Missing data should be properly represented as NA.
Simulated example data set for a model with nested hierarchical latent variables.
An IRT response matrix with 300 persons and 30 binary items.
De Boeck, P. and Partchev, I. (2012). IRTrees: Tree-Based Item Response Models of the GLMM Family, Journal of Statistical Software – Code Snippets, 48(1), 1–28. https://www.jstatsoft.org/v48/c01/.
str(neslat) str(neslatT <- exogenize(neslat, cbind(c(1,1,1), c(1,0,0), c(0,1,0), c(0,0,1)), endnode=rep(1:3, each = 10)))
str(neslat) str(neslatT <- exogenize(neslat, cbind(c(1,1,1), c(1,0,0), c(0,1,0), c(0,0,1)), endnode=rep(1:3, each = 10)))
Simulated example data set with nested hierarchical categories.
data(nesresp)
data(nesresp)
An IRT response matrix with 300 persons and 10 four-category items.
De Boeck, P. and Partchev, I. (2012). IRTrees: Tree-Based Item Response Models of the GLMM Family, Journal of Statistical Software – Code Snippets, 48(1), 1–28. https://www.jstatsoft.org/v48/c01/.
str(nesresp) head(nesresp) str(nesrespT <- dendrify(nesresp, cbind(c(0,0,1,1), c(0,1,NA,NA), c(NA,NA,0,1)))) head(nesrespT, 20)
str(nesresp) head(nesresp) str(nesrespT <- dendrify(nesresp, cbind(c(0,0,1,1), c(0,1,NA,NA), c(NA,NA,0,1)))) head(nesrespT, 20)
Convert an IRT response matrix in the wide format to a data frame in the long format. In the wide format each row corresponds to a respondent and each column to an item.
tolong(mat)
tolong(mat)
mat |
an integer IRT response matrix (i.e. a wide format) |
a long-format data frame
Item responses to a questionaire on verbal aggression. These data are used throughout De Boeck and Wilson, Explanatory Item Response Models (Springer, 2004) to illustrate various forms of item response models.
A data matrix with 316 persons, 24 three-category items, and two person covariates (trait anger and gender).
http://bear.soe.berkeley.edu/EIRM/
De Boeck and Wilson (2004), Explanatory Item Response Models, Springer.
str(VerbAgg2) mapping <- cbind(c(1,1,1), diag(3)) str(VerbAgg2T <- exogenize(VerbAgg2[,-c(1,2)], mapping, endnode=rep(1:3, 8)))
str(VerbAgg2) mapping <- cbind(c(1,1,1), diag(3)) str(VerbAgg2T <- exogenize(VerbAgg2[,-c(1,2)], mapping, endnode=rep(1:3, 8)))
Item responses to a questionaire on verbal aggression. These data are used throughout De Boeck and Wilson, Explanatory Item Response Models (Springer, 2004) to illustrate various forms of item response models.
A data matrix with 316 persons, 24 three-category items, and two person covariates (trait anger and gender).
http://bear.soe.berkeley.edu/EIRM/
De Boeck and Wilson (2004), Explanatory Item Response Models, Springer.
str(VerbAgg3) mapping <- cbind(c(0,1,1), c(NA,0,1)) str(VerbAgg3T <- dendrify(VerbAgg3[,-c(1,2)], mapping))
str(VerbAgg3) mapping <- cbind(c(0,1,1), c(NA,0,1)) str(VerbAgg3T <- dendrify(VerbAgg3[,-c(1,2)], mapping))
Recode a wide format data frame to a long format IRTRees data frame in the case when items may have different tree structures
WtoL_multi.tree( data, cmx_list, id.col, resp.col_list, covar.col = NULL, time.col = NULL )
WtoL_multi.tree( data, cmx_list, id.col, resp.col_list, covar.col = NULL, time.col = NULL )
data |
a wide-format (person-by-item) data set |
cmx_list |
a list including all tree structures |
id.col |
the ID column |
resp.col_list |
a list of vectors, with a length matching the length of |
covar.col |
columns containing covariates |
time.col |
the time column when there are repeated (longitudinal) data |
Many examples of mapping matrices are given in the vignette. Columns may be specified by numeric index or by name. Response categories must be coded with consecutive integers starting from 1, not 0. Missing data should be properly represented as NA.
Recode a wide format data frame to a long format IRTrees data frame in the case when all items have the same tree structure
WtoL_single.tree( data, cmx, id.col, resp.col, covar.col = NULL, time.col = NULL )
WtoL_single.tree( data, cmx, id.col, resp.col, covar.col = NULL, time.col = NULL )
data |
a wide-format (person-by-item) data set |
cmx |
a a category-by-node mapping matrix |
id.col |
the ID column |
resp.col |
the columns containing the item responses |
covar.col |
columns containing covariates |
time.col |
the time column when there are repeated (longitudinal) data |
Many examples of mapping matrices are given in the vignette. Columns may be specified by numeric index or by name. Response categories must be coded with consecutive integers starting from 1, not 0. Missing data should be properly represented as NA.
Recode a wide format data frame to a wide format IRTRees data frame in the case when items may have different tree structures
WtoW_multi.tree( data, cmx_list, id.col = NULL, resp.col_list, covar.col = NULL, time.col = NULL )
WtoW_multi.tree( data, cmx_list, id.col = NULL, resp.col_list, covar.col = NULL, time.col = NULL )
data |
a wide-format (person-by-item) data set |
cmx_list |
a list including all tree structures |
id.col |
the ID column |
resp.col_list |
a list of vectors, with a length matching the length of |
covar.col |
columns containing covariates |
time.col |
the time column when there are repeated (longitudinal) data |
Many examples of mapping matrices are given in the vignette. Columns may be specified by numeric index or by name. Response categories must be coded with consecutive integers starting from 1, not 0. Missing data should be properly represented as NA.
Recode a wide format data frame to a wide format IRTrees data frame in the case when all items have the same tree structure
WtoW_single.tree( data, cmx, id.col = NULL, resp.col = NULL, covar.col = NULL, time.col = NULL )
WtoW_single.tree( data, cmx, id.col = NULL, resp.col = NULL, covar.col = NULL, time.col = NULL )
data |
a wide-format (person-by-item) data set |
cmx |
a a category-by-node mapping matrix |
id.col |
the ID column |
resp.col |
the columns containing the item responses |
covar.col |
columns containing covariates |
time.col |
the time column when there are repeated (longitudinal) data |
Many examples of mapping matrices are given in the vignette. Columns may be specified by numeric index or by name. Response categories must be coded with consecutive integers starting from 1, not 0. Missing data should be properly represented as NA.