fit_lmx: Fit lm, lme, or lmer

fit_lmxR Documentation

Fit lm, lme, or lmer

Description

Fit lm, lme, or lmer

Usage

fit_lmx(
  object,
  fit,
  formula = as.formula("~ subgroup"),
  drop = varlevels_dont_clash(object, all.vars(formula)),
  codingfun = contr.treatment.explicit,
  coefs = model_coefs(object, formula = formula, drop = drop, codingfun = codingfun),
  block = NULL,
  opt = "optim",
  weightvar = if ("weights" %in% assayNames(object)) "weights" else NULL,
  statvars = c("effect", "p", "se", "t")[1:2],
  ftest = if (is.null(coefs)) TRUE else FALSE,
  sep = FITSEP,
  suffix = paste0(sep, fit),
  verbose = TRUE,
  plot = FALSE
)

fit_lm(
  object,
  formula = as.formula("~ subgroup"),
  drop = varlevels_dont_clash(object, all.vars(formula)),
  codingfun = contr.treatment.explicit,
  design = NULL,
  block = NULL,
  weightvar = if ("weights" %in% assayNames(object)) "weights" else NULL,
  statvars = c("effect", "p", "se", "t")[1:2],
  sep = FITSEP,
  suffix = paste0(sep, "lm"),
  coefs = model_coefs(object, formula = formula, drop = drop, codingfun = codingfun),
  contrasts = NULL,
  ftest = if (is.null(coefs)) TRUE else FALSE,
  verbose = TRUE,
  plot = FALSE
)

fit_lme(
  object,
  formula = as.formula("~ subgroup"),
  drop = varlevels_dont_clash(object, all.vars(formula)),
  codingfun = contr.treatment.explicit,
  design = NULL,
  block = NULL,
  weightvar = if ("weights" %in% assayNames(object)) "weights" else NULL,
  opt = "optim",
  statvars = c("effect", "p", "se", "t")[1:2],
  sep = FITSEP,
  suffix = paste0(sep, "lme"),
  coefs = model_coefs(object, formula = formula, drop = drop, codingfun = codingfun),
  contrasts = NULL,
  ftest = if (is.null(coefs)) TRUE else FALSE,
  verbose = TRUE,
  plot = FALSE
)

fit_lmer(
  object,
  formula = as.formula("~ subgroup"),
  drop = varlevels_dont_clash(object, all.vars(formula)),
  codingfun = contr.treatment.explicit,
  design = NULL,
  block = NULL,
  weightvar = if ("weights" %in% assayNames(object)) "weights" else NULL,
  statvars = c("effect", "p", "se", "t")[1:2],
  sep = FITSEP,
  suffix = paste0(sep, "lmer"),
  coefs = model_coefs(object, formula = formula, drop = drop, codingfun = codingfun),
  contrasts = NULL,
  ftest = if (is.null(coefs)) TRUE else FALSE,
  verbose = TRUE,
  plot = FALSE
)

Arguments

object

SummarizedExpriment

fit

'lm', 'lme', or 'lmer'

formula

formula

drop

TRUE or FALSE

codingfun

coding function

coefs

NULL or stringvector

block

NULL or svar

opt

optimizer used in fit_lme: 'optim' (more robust) or 'nlminb'

weightvar

NULL or svar

statvars

character vector: subset of c('effect', 'p', 'fdr', 't')

ftest

TRUE or FALSE

sep

string

suffix

string: pvar suffix ("lm" in "p~t2~lm")

verbose

TRUE or FALSE

plot

TRUE or FALSE

design

NULL

contrasts

unused. only to allow generic get(fitfun)(contrasts)

Value

SummarizedExperiment

Examples

file <- system.file('extdata/atkin.metabolon.xlsx', package = 'autonomics')
object <- read_metabolon(file)
fit_lm(     object, formula = ~subgroup)
fit_limma(  object, formula = ~subgroup)
fit_limma(  object, formula = ~subgroup, block = 'Subject' )
fit_lme(    object, formula = ~subgroup, block = 'Subject' )
fit_lmer(   object, formula = ~subgroup, block = 'Subject' )
# fit_lme(  object, formula = ~subgroup, block = ~1|Subject) # needs fine-tuning
# fit_lmer( object, formula = ~subgroup + (1|Subject))       # needs fine-tuning

bhagwataditya/importomics documentation built on Nov. 28, 2024, 8:28 a.m.