Examples to use TSC in Fixed Effects Models"

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}.

  1. Load data
library("structree")
data(CTB, package="structree")
  1. 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).

  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.

  1. Number of Splits
mod_CTB$opts

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

  1. Paths of Coefficients
plot(mod_CTB, paths=TRUE)

\pagebreak

  1. Estimated Clusters
plot(mod_CTB, result=TRUE, cex.txt=0.7, cex.main=1.2)
  1. 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}.

  1. Load data
library("structree")
data(guPrenat, package="structree")
  1. 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.

  1. 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

  1. Number of Splits
mod_gua$opts

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

  1. Estimated Clusters
plot(mod_gua, result=TRUE, cex.txt=0.7, cex.main=1.2)
  1. 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}



Try the structree package in your browser

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

structree documentation built on July 2, 2020, 12:27 a.m.