Table of Contents
Is the order of level names critical in xxmModel()?
Yes. The order of level names determines possible parent-child relationship among levels. For example,
myModel <- xxmModel(c("student","teacher"))
is correct for students nested within teachers. The following is incorrect:
myModel <- xxmModel(c("teacher", "student"))
Error: "Please check the number of rows and/or columns"
asdasd
What are the requirements for datasets?
For two level data structures, a single dataset is adequate. However with complex dependent data-structures it is most convenient to provide data for each level separately. Each dataset must include information about how each observation at that level is linked to an observation at a higher level. In general, datasets may have three types of variables:
- One or more columns of IDs or variables with linking information. ID columns are mandatory.
- Zero or more columns of dependent variables corresponding to the list of ys. (Optional)
- Zero or more columns of independent variables corresponding to the list of xs. (Optional).
A complete checklist to ensure that the data requirements are met:
- Each level must have a corresponding R dataset. To avoid confusion, the name of the dataset should match the level name.
- If a level does not have observed dependent or independent variables, the dataset should include a single column of level IDs.
- The first (1 + p) columns of a dataset include ID variables.
- First column is the ID column for the current level.
- The next p columns are the IDs for the parents of the current level.
- The names and order of the ID columns must match the corresponding level names declared in xxmModel.
- ID columns must be of type integer. Be careful, as R routinely converts categorical variables to a *factor* type.
- Dependent and independent variables must be of type numeric
- Use R command for examining structure of a dataset to ensure that the above requirements are met, e.g.
str(myLevel1Data)
andstr(myLevel2Data)
.