library(knitr) opts_knit$set(root.dir=normalizePath('../'))

\section{CTB/McGraw-Hill}

The data set contains results of an achievement test that measures different objectives and subskills of subjects in mathematics and science. The students had to respond to 56 multiple-choice items (31 mathematics, 25 science). For a description of the original data, see \cite{CTB}.

- Load data

library("structree") data(CTB, package="structree")

- Overview of the data

dim(CTB) str(CTB) nlevels(CTB$school) table(CTB$school)

There are 1500 grade 8 students from 35 schools. The response variable score is the overall test score, defined as the number of correctly solved items. Several variables characterise the schools and the students. For the analysis we use the covariate gender (male: 0, female: 1).

- Estimation of the model

mod_CTB <- structree(score~tr(1|school)+gender, data=CTB, family=gaussian, stop_criterion="pvalue", splits_max=34, alpha=0.05, trace=FALSE) # print mod_CTB

For school-specific intercepts one has to enter \texttt{tr(1|school)} into the formula.

- Number of Splits

```
mod_CTB$opts
```

The algorithm performs five splits, that is, forms six clusters regarding the intercept.

- Paths of Coefficients

plot(mod_CTB, paths=TRUE)

\pagebreak

- Estimated Clusters

plot(mod_CTB, result=TRUE, cex.txt=0.7, cex.main=1.2)

- Estimated Coefficients

```
coef(mod_CTB)
```

\section{National Survey in Guatemala}

The data set contains observations of children that were born in the 5-year-period before the National Survey of Maternal and Child Health in Guatemala in 1987. The data was also analysed by \cite{GUA}.

- Load data

library("structree") data(guPrenat, package="structree")

- Overview of the data

```
dim(guPrenat)
```

\pagebreak

str(guPrenat) nlevels(guPrenat$cluster) table(guPrenat$cluster)

There are 1211 children living in 45 communities. The response variable prenat is the indicator for modern prenatal care (prenat=1), for example by doctors or nurses, instead of traditional prenatal care (prenat=0). Several variables characterise the children's mothers and their families.

- Estimation of the model

mod_gua <- structree(prenat~tr(1|cluster)+indig+momEd+husEd+husEmpl+TV+motherAge+toilet,data=guPrenat,family=binomial(link="logit"),stop_criterion="pvalue",splits_max=10,alpha=0.05,trace=FALSE) # print mod_gua

For community-specific intercepts one has to enter \texttt{tr(1|cluster)} into the formula.

\pagebreak

- Number of Splits

```
mod_gua$opts
```

The algorithm performs two splits, that is, forms two clusters regarding the intercept.

- Estimated Clusters

plot(mod_gua, result=TRUE, cex.txt=0.7, cex.main=1.2)

- Estimated Coefficients

```
coef(mod_gua)
```

\begin{thebibliography}{xxxxxxx} \bibitem{CTB}De Boeck, P. and M. Wilson (2004). {\it Explanatory item response models: A generalized linear and nonlinear approach}. Springer Verlag. \bibitem{GUA}Rodriguez, G. and N. Goldman (2001). Improved estimation procedures for multilevel models with binary response: A case-study. {\it Journal of the Royal Statistical Society. Series A (Statistics in Society) 164(2)}, 339-355. \end{thebibliography}

**Any scripts or data that you put into this service are public.**

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.