R/lmm_lcmm.R

Defines functions lmm.lcmm

Documented in lmm.lcmm

#' Title
#'
#' @param model
#' @param formul
#' @param data
#' @param link
#' @param range
#' @param subject
#'
#' @return
#' @export
#'
#' @importFrom lcmm lcmm
#'
#' @examples
lmm.lcmm <- function(model, formul, data, link = "linear", range = NULL, subject){

  if (class(model)!="lcmm"){

    if (!is.null(model$range)){
      range <- model$range
    }

    if (!is.null(model$link)){
      link <- model$link
    }

    cat("lcmm modelling...")

    model.output <- lcmm(fixed = model$fixed, random = model$random,
                         subject = subject, data = data,
                         link = link, range = range, verbose = FALSE)

    pred.RE <- predRE.lcmm(model = model.output, formul = model, data = data, subject = subject)

    return(list(model.output = model.output, pred.RE = pred.RE))

  }else{

    pred.RE <- predRE.lcmm(model = model, formul = formul, data = data, subject = subject)

    return(list(model.output = model, pred.RE = pred.RE))

  }

}
anthonydevaux/hdlandmark documentation built on Jan. 11, 2023, 8:01 a.m.