check.mpt: Check construction of MPT models.

Description Usage Arguments Details Value See Also Examples

View source: R/check.mpt.R

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

1
check.mpt(model.filename, restrictions.filename = NULL, model.type = c("easy", "eqn"))

Arguments

model.filename

A character vector specifying the location and name of the model file.

restrictions.filename

NULL or a character vector specifying the location and name of the restrictions file. Default is NULL which corresponds to no restrictions.

model.type

Character vector specifying whether the model file is formatted in the easy format ("easy"; i.e., each line represents all branches corresponding to a response category) or the traditional EQN syntax ("eqn"; see e.g., Stahl & Klauer, 2007). If the model filename ends with ".eqn" or ".EQN" the model is automatically treated as an EQN file.

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 FALSE, a warning is shown indicating in which trees the probabilities do not sum to 1.

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.model.categories - n.trees). The number of parameters can not be higher than this value for a model to be identifiable.

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

fit.mpt

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# 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)

MPTinR documentation built on July 13, 2021, 5:07 p.m.