check.mpt {MPTinR} | R Documentation |
Check construction of MPT models.
Description
A helper function which can aid in the process of constructing a MPT model file for MPTinR. It will check if the probabilities in each trees sum to 1 (if so, a tree is well constructed). If probabilities do not sum to 1, check.mpt
will return for which trees. Furthermore, it will return the number of parameters and their names (helpful in spotting typos), the number of categories and the number of dfs the model provides. Finally, you can also pass restrictions as an argument and will receive the number and names of the parameters after restrictions are applied.
Usage
check.mpt(model.filename, restrictions.filename = NULL, model.type = c("easy", "eqn"))
Arguments
model.filename |
A character |
restrictions.filename |
|
model.type |
Character vector specifying whether the model file is formatted in the easy format ( |
Details
As default, check.mpt
expects a model file in the easy format, but if the filename ends with .eqn or .EQN check.mpt
will expect the EQN format.
In case of inequality restrictions, the original parameters which are inequality restricted are replaced with dummy parameters starting with hankX
. When using fit.mpt
you will not notice this, as the output only shows the original parameters. In contrast, check.mpt
removes the original parameters and shows the dummy parameters called hankX
. Note that this does not change the number of parameters in the model.
For EQN model files, the output also contains two slots giving the ordering of trees (eqn.order.trees
) as well as categories (eqn.order.categories
).
Value
A list with
probabilites.eq.1 |
A logical value indicating whether or not the probabilities in each tree sum to 1. If |
n.trees |
Number of trees in the model. |
n.model.categories |
Total number of categories expected in a dataset for that model. |
n.independent.categories |
Number of independent response categories (i.e., independent data points) the model provides (i.e., |
n.params |
Number of parameters in the model. |
parameters |
Names of parameters in the model. |
eqn.order.trees |
Order of trees in EQN model files (omitted if model is not an EQN file). |
eqn.order.categories |
Order of trees in EQN model files (omitted if model is not an EQN file). |
If restrictions are present, the n.params
and parameters
are displayed for the unrestricted model (orig.model
) as well as for the restricted model (restr.model
).
See Also
Examples
# model of example 1 from example(fit.mpt)
model1 <- system.file("extdata", "rb.fig1.model", package = "MPTinR")
check.mpt(model1)
#model 1 in eqn format
model1.eqn <- system.file("extdata", "rb.fig1.model.eqn", package = "MPTinR")
check.mpt(model1.eqn)
#models of example 2 from example(fit.mpt)
model2 <- system.file("extdata", "rb.fig2.model", package = "MPTinR")
check.mpt(model2)
model2r.r.eq <- system.file("extdata", "rb.fig2.r.equal", package = "MPTinR")
check.mpt(model2, model2r.r.eq)
model2r.c.eq <- system.file("extdata", "rb.fig2.c.equal", package = "MPTinR")
check.mpt(model2, model2r.c.eq)