Description Usage Arguments Details Value Author(s) References See Also Examples
Fit a linear mixed-effects model (LMM) to each measured variable (e.g. metabolite) via lmer
function of lme4.
1 |
fix |
list or vector; list or vector of fixed effects |
random |
list or vector; list or vector of random effects |
data |
dataframe; a dataframe contains metadata and measured variables |
start |
integer; index of the first measured variable |
end |
integer; index of the last measured variable, If not given, all variables are fitted |
auto |
logical; automatically include only significant fixed effects based on chi-square test, |
major |
list or vector; list or vector of fixed effects always be included, if provided, |
pval |
numeric; value of significance level for chi-square test, |
... |
other arguments of |
The function processes a given data matrix (e.g. metabolomics data) by fitting a LMM to each measured variable via lmer
function of lme4.
Significance level of the fixed-effect term is assessed by chi-square test as implemented in drop1
.
If auto = FALSE
, all fixed effects are included in models.
If auto = TRUE
, only significant fixed effects with Pr(Chi) < pval
, are included in models.
If major
is provided, major
-fixed effects and significant fixed effects with Pr(Chi) < pval
are included in models.
Random effect must be provided to form LMMs. The random-effect term can be in several forms as given in Table 2 of Bates et al. (2015).
fitLmm
returns a LMM for each measured variable. Model information is returned as an object of class lmm2met
,
with the following components:
completeMod
= list of LMMs containing all given fixed and random effects
updateMod
= list of LMMs containing fixed and random effects, if auto = TRUE
or major
is provided
testRes
= list of outputs from chi-square tests
fittedDat
= a dataframe of processed data
rawDat
= a dataframe of original data
dataIndex
= vector of indices of the first and last measured variable
Kwanjeera W kwanjeera.wan@mahidol.ac.th
https://cran.r-project.org/web/packages/lme4/index.html
Bates, D., et al., Fitting Linear Mixed-Effects Models Using lme4. Journal of Statistical Software, 2015. 67(1): p. 1-48.
1 2 3 4 5 6 7 8 9 10 11 | ##Ex 1. LMMs containing all given fixed and random effects
#fitMet = fitLmm(fix=c('Sex','Age','BMI','Stage','Location','Tissue'),
#random='(1|Id)', data=adipose, start=10, end=14)
##Ex 2. LMMs containing only significant fixed effects and random effects
#fitMet = fitLmm(fix=c('Sex','Age','BMI','Stage','Location','Tissue'),
#random='(1|Id)', data=adipose, start=10, end=14, auto=TRUE)
##Ex 3. LMMs containing only significant fixed effects, Tissue effect and random effects
#fitMet = fitLmm(fix=c('Sex','Age','BMI','Stage','Location','Tissue'),
#random='(1|Id)', data=adipose, start=10, end=14, major='Tissue')
#structure(fitMet) #show lmm2met object
#summary(fitMet$updateMod[[1]]) #summarize outputs of fitting a LMM to variable X1
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.