multi_lm: Fit multiple linear models.

Description Usage Arguments Value Examples

View source: R/multi-lm.R

Description

For a constant set of explanatory variables (xs) and several dependent variables (ys), fit a linear model y ~ xs for each y in ys.

Usage

1
multi_lm(df, xs, ys, robust = TRUE)

Arguments

df

A data frame containing explanatory variables xs and dependent variables ys.

xs

A character vector. The explanatory variables. These must be the names of columns of df that are either numeric, factor or logical.

ys

A character vector. The dependent variables. These must be the names of numeric columns of df that are either numeric or factors.

robust

A flag. Use robust linear model MASS::rlm()? Can only be used with type = 1.

Value

A list of fitted linear models (the results of calls to stats::lm() or MASS::rlm()).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
if (rlang::is_installed("mirmisc")) {
  gars_data <- get_combined_cohort_data(c("ga", "rs"),
    gene_predicate = ~ median(.) > 0, log2 = TRUE
  ) %>%
    dplyr::mutate(
      cohort = factor(
        dplyr::if_else(startsWith(mirvie_id, "RS"), "RS", "GA")
      )
    ) %>%
    dplyr::filter(!is.na(meta_major_race), !is.na(meta_collectionga))
  xs <- c("cohort", "meta_major_race", "meta_collectionga")
  ys <- mirmisc::get_df_gene_names(gars_data)
  res <- multi_lm(gars_data, xs, ys)
}

mirvie/mirmodels documentation built on Jan. 14, 2022, 11:12 a.m.