% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/methylationLME_steps.R
\name{fitMethylationLMEModels}
\alias{fitMethylationLMEModels}
\title{Fit CpG-wise mixed-effects models for longitudinal methylation analyses}
\usage{
fitMethylationLMEModels(
  preparedData,
  nCores = 1L,
  libPath = NULL,
  lmeLibs = "lme4,lmerTest",
  correlationStructure = "none",
  correlationVar = NULL,
  verbose = FALSE,
  logs = FALSE,
  log_dir = NULL,
  log_file = "log_methylationLME.txt"
)
}
\arguments{
\item{preparedData}{Object returned by \code{prepareMethylationLMEData()}.}

\item{nCores}{Integer. Maximum number of worker processes to use. Automatic
fitting uses the empirical lme4 or nlme crossover and caps workers by
available CpGs and detected physical cores.}

\item{libPath}{Character vector or \code{NULL}. Optional library paths forwarded
to worker processes.}

\item{lmeLibs}{Character vector or comma-separated string of package names to
check on worker processes. The default is \code{'lme4,lmerTest'}.}

\item{correlationStructure}{Character. Residual correlation structure used
when \code{lmeLibs} selects \code{'nlme'}. One of \code{'none'}, \code{'AR1'}, or \code{'CAR1'}.}

\item{correlationVar}{Character or \code{NULL}. Variable used to order repeated
observations within \code{personVar} for \code{AR1} or \code{CAR1} residual correlation
structures. Must be supplied explicitly for \code{AR1} or \code{CAR1}.}

\item{verbose}{Logical. If \code{TRUE}, emit progress messages with \code{message()}.}

\item{logs}{Logical. If \code{TRUE}, write the same messages to a log file.}

\item{log_dir}{Character or \code{NULL}. Directory used for the log file when
\code{logs = TRUE}.}

\item{log_file}{Character. File name used when \code{logs = TRUE}.}
}
\value{
A list with class \code{'dnaEPICO_methylationLME_models'}
containing fitted model lists, model formulas, and counts of failed CpG
fits.
}
\description{
Fit one linear mixed-effects model per CpG for each phenotype requested in
the
object returned by \code{prepareMethylationLMEData()}.
}
\examples{
ex <- dnaEPICO:::exampleMethylationLMEStateDnaEpico()
model_results <- fitMethylationLMEModels(
    preparedData = ex$preparedData,
    nCores = 1,
    verbose = FALSE,
    logs = FALSE
)
names(model_results$fits)

}
