knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%",
  fig.width=6, 
  fig.height=4
)

skewlmm skewlmm GitHub link

CRAN_Status_Badge

The goal of skewlmm is to fit skew robust linear mixed models, using scale mixture of skew-normal linear mixed models with possible within-subject dependence structure, using an EM-type algorithm. In addition, some tools for model adequacy evaluation are available.

For more information about the model formulation and estimation, please see Schumacher, F. L., Lachos, V. H., and Matos, L. A. (2021). Scale mixture of skew‐normal linear mixed models with within‐subject serial dependence. Statistics in Medicine. DOI: 10.1002/sim.8870.

Installation

You can install skewlmm from GitHub with:

remotes::install_github("fernandalschumacher/skewlmm")

Or you can install the released version of skewlmm from CRAN with:

install.packages("skewlmm")

Example

This is a basic example which shows you how to fit a SMSN-LMM:

library(skewlmm)
dat1 <- as.data.frame(nlme::Orthodont)
fm1 <- smsn.lmm(dat1, formFixed = distance ~ age, formRandom = ~ age,
                groupVar = "Subject", distr = "st",
                control = lmmControl(quiet = TRUE))
summary(fm1)
plot(fm1)

Several methods are available for SMSN and SMN objects, such as: print, summary, plot, fitted, residuals, predict, and update.

Some tools for goodness-of-fit assessment are also available, for example:

acf1<- acfresid(fm1, calcCI = TRUE)
plot(acf1)
plot(mahalDist(fm1), nlabels = 2)
healy.plot(fm1, calcCI = TRUE)

Furthermore, to fit a SMN-LMM one can use the following:

fm2 <- smn.lmm(dat1, formFixed = distance ~ age, formRandom = ~ age,
               groupVar = "Subject", distr = "t",
               control = lmmControl(quiet = TRUE))
summary(fm2)

Now, for performing a LRT for testing if the skewness parameter is 0 ($\text{H}_0: \lambda_i=0, \forall i$), one can use the following:

lr.test(fm1,fm2)

By default, the functions smsn.lmm and smn.lmm now use the DAAREM method (a method for EM accelaration, for details see help(package="daarem")) for estimation, to improve the computational performance. This method usually greatly reduces the convergence time, but its use can result in numerical errors, specially for small samples. In this cases, the EM algorithm can be used, as follows:

fm2EM <- smn.lmm(dat1, formFixed = distance ~ age, formRandom = ~ age, distr = 't',
                 groupVar = "Subject", control = lmmControl(algorithm = "EM", 
                                                            quiet = TRUE))
fm2EM

Also, we can fit a t-LMM with diagonal scale matrix for the random effects by using:

fm2diag <- update(fm2, covRandom = "pdDiag")
fm2diag

We can compare the information criteria for all fitted models using the criteria function, as follows:

criteria(list(`ST-LMM` = fm1, `t-LMM` = fm2, `t-LMM(EM)` = fm2EM, `t-LMM-diag` = fm2diag))

For more examples, see help(smsn.lmm) and help(smn.lmm).

Handling censored/missing observations

An extension of the methods to account for censoring in SMSN-LMM is under development. Tools for accommodating left, right, or interval censored observations in the symmetrical family SMN-LMM are now available using the function smn.clmm.

For more information on censored models, we refer to Matos, L. A., Prates, M. O., Chen, M. H., and Lachos, V. H. (2013). Likelihood-based inference for mixed-effects models with censored response using the multivariate-t distribution. Statistica Sinica. DOI: 10.5705/ss.2012.043.



fernandalschumacher/lmmsmsn documentation built on Jan. 21, 2025, 1:24 a.m.