Penicillin

Penicillin: Random-Intercept, Cross-Classified model

The penicillin example included with lme4 is designed to examine variability between multiple samples of penicillin. In this example the outcome variable,diameter, refers to the diameter of the disc in a petri dish which is successfully treated by Penicillin. There are two cross-classified parent levels: the plate, or Petri dish, used and the sample of Penicillin. Level-1 is response, level-2 is called Plate, and level-3 is Sample.

\[ y_{i(u,v)} = \nu + 1\times \eta_u^{p}+ 1\times\eta_v^{s} + e_{i(u,v)}, \]

\[ e \sim N(0, \Theta^{1,1}) \] \[ \eta^{p} \sim N(0, \Psi^{p}) \] \[ \eta^{s} \sim N(0, \Psi^{s}) \]

Path Diagram

alt Penicillin.xxmModel

xxM representation

\[ y^{1}_i = \nu^1 + 1_{i,j}^{1,2}  \times \eta_j^{2}+ 1_{i,k}^{1,3} \times\eta_k^{3} + e_{i}^1 \]

\[ e^1 \sim N(0, \Theta_{1,1}) \] \[ \eta^{2} \sim N(0, \Psi^{2,2}) \] \[ \eta^{3} \sim N(0, \Psi^{3.3}) \]

Note:

  • Subscripts ${i, j, k}$ are not really necessary.
  • Coefficients $1_{i,j}^{1,2}$ and $1_{i,k}^{1,3}$ are included for clarity. These are just fixed factor-loadings in the model.

A general multivariate cross-classified model may be simply represented as:

\[ y^{1} = \nu^1 + \Lambda^{1,2}  \times \eta^{2}+ \Lambda^{1,3} \times\eta^{3} + e^1 \]

xxM Model Matrices

Level-1 (Response): Within matrices

Residual Covariance Matrix

We have a single dependent variable and hence a single parameter level-1 residual variance \( (\Theta_{1,1}) \) at level-1. The residual covariance or theta matrix is a (1×1) matrix:

\[
\Theta^{1,1} =
\begin{bmatrix}
\theta^{1,1}_{1,1}
\end{bmatrix}
\]

Observed Variable Intercept

In this model, plate and sample both reflect deviations from, but do not capture, the grand mean (intercept) of the dependent variable diameter. As a result, we must estimate a fixed effect for the observed intercept. The estimate is a 1×1 matrix with a single element:

\[
\nu^{1} =
\begin{bmatrix}
\nu_{1}^{1}
\end{bmatrix}
\]

Level-2 (Plate): Within Matrices

At the Plate level, we have a single latent variable: the random-intercept of plate. Since this latent variable has a mean of 0, it is unneccesary to estimate the parameter. As a result, the only estimated parameter within the Plate level is the latent factor covariance matrix.

Latent Factor Covariance Matrix

The latent covariance matrix is a (1×1) matrix with single variance of the intercept:

\[
\Psi^{2,2}=
\begin{bmatrix}
\psi_{1,1}^{2,2}
\end{bmatrix}
\]

Level-3 (Sample): Within Matrices

At the Sample level, we have a single latent variable: the random-intercept of sample. As with the Plate level, this latent variable has a mean of 0 and it is unneccesary to estimate the parameter. The only estimated parameter within the Sample level is the latent factor covariance matrix.

Latent Factor Covariance Matrix

The latent covariance matrix is a (1×1) matrix with single variance of the intercept:

\[
\Psi^{3,3}=
\begin{bmatrix}
\psi_{1,1}^{3,3}
\end{bmatrix}
\]

Across level matrices: Plate to Response

Across-level factor-loading matrix

The factor-loading matrix \( (\Lambda^{1,2}) \) has a single element fixed to 1.0.

\[
\Lambda^{1,2} =
\begin{bmatrix}
1.0_{i,u}^{1,2}
\end{bmatrix}
\]

Across level matrices: Sample to Response

Across-level factor-loading matrix

The factor-loading matrix \( (\Lambda^{1,3}) \) has a single element fixed to 1.0.

\[
\Lambda^{1,3} =
\begin{bmatrix}
1.0_{i,v}^{1,3}
\end{bmatrix}
\]

Code Listing

“xxM”“SAS:“R:

xxM

Load xxM

xxM library needs to be loaded first.

Prepare R datasets

For this analysis, we use data packaged with lme4.
For analysis with xxM separate diameter, plate, and sample datasets are created as follows:

response dataset includes the following columns:

  • response Unique response IDs (integer)
  • plate IDs for the parent level (integer)
  • sample IDs for the parent level (integer)
  • diameter the dependent varaible (numeric)

plate dataset includes the following columns:

  • plate Unique plate IDs (integer)

sample dataset includes the following columns:

  • sample Unique sample IDs (integer)

Construct R-matrices

For each parameter matrix, construct three related matrices:

  1. pattern matrix: A matrix indicating free or fixed parameters.
  2. value matrix: with start or fixed values for corresponding parameters.
  3. label matrix: with user friendly label for each parameter. label matrix is optional.

Construct model

xxmModel() is used to declare level names. The function returns a model object that is passed as a parameter to subsequent statements. Variable name for the return value can be anything.

Add submodels

For each declared level xxmSubmodel() is invoked to add corresponding submodel to the model object. The function adds three types of information to the model object:

  • parents declares a list of all parents of the current level.
    • Levels with the independent variables are the parent levels.
    • Level with the dependent variable is the child level.
  • variables declares names of observed dependent (ys), observed independent (xs) and latent variables (etas) for the level.
  • data R data object for the current level.

Add within-level matrices

For each declared level xxmWithinMatrix() is used to add within-level parameter matrices. For each parameter matrix, the function adds the three matrices constructed earlier:

  • pattern
  • value
  • label (optional)

Add across-level matrices

Pairs of levels that share parent-child relationship have regression relationships. xxmBetweenMatrix() is used to add corresponding rergession matrices connecting the two levels.

  • Level with the independent variable is the parent level.
  • Level with the dependent variable is the child level.

For each parameter matrix, the function adds the three matrices constructed earlier:

  • pattern
  • value
  • label (optional)

Estimate model parameters

Estimation process is initiated by xxmRun(). If all goes well, a q&d summary of the results is printed.

Estimate profile-likelihood confidence intervals

Once parameters are estimated, confidence intervals are estimated by invoking xxmCI(). Depending on the the number of observations and the complexity of the model, xxmCI() may take a long time to compute. xxmCI() also prints a summary of parameter estimates and CIS.

View results

A summary of results may be retrived as an R list by a call to xxmSummary(). The returned list has two elements:

  1. fit is a list with five elements:
    • deviance is \( -2 Log Likelihood \) for the maximum likelihood fit function.
    • nParameters is the total number of unique parameters.
    • nObservations is the total number of observations across all levels.
    • aic is Akaike’s Information Criterion or AIC computed as \( -2ll + 2*p \).
    • bic is Bayesian Information Criterion or BIC computed as \( -2ll + p*\log(n) \).
  2. estimates is a single table of free parameter estimates
    All xxM parameters have superscripts {child, parent} and subscripts {to, from}. xxM adds a descriptive parameter label if one is not already provided by the user.

Free model object

xxM model object may hog a significant amount of RAM outside of R’s workspace. This memory will automatically be released, when the workspace is cleared by a call to rm(list=ls()) or at the end of the R session. Alternatively, it is recommended that xxmFree() may be called to release the memory.

alt Penicillin.results

Proc Mixed

R: lmer