micomp: Multiple independent comparisons of observations

View source: R/micomp.R

micompR Documentation

Multiple independent comparisons of observations

Description

Performs multiple independent comparisons of output observations.

Usage

micomp(
  outputs,
  ve_npcs,
  comps,
  concat = F,
  centscal = "range",
  lim_npcs = TRUE,
  mnv_test = "Pillai",
  ...
)

Arguments

outputs

A vector with the labels of each output, or an integer with the number of outputs (in which case output labels will be assigned automatically).

ve_npcs

Percentage (0 < ve_npcs < 1) of variance explained by the q principal components (i.e. number of dimensions) used in MANOVA, or the number of principal components (ve_npcs > 1, must be integer). Can be a vector, in which case the MANOVA test will be applied multiple times, one per specified variance to explain / number of principal components.

comps

A list of lists, where each list contains information regarding an individual comparison. Each list can have one of two configurations:

  1. Lists with the first configuration are used to load data from files, and require the following fields:

    name

    A string specifying the comparison name.

    folders

    Vector of folder names where to read files from. These are recycled if length(folders) < length(files).

    files

    Vector of filenames (with wildcards) to load in each folder.

    lvls

    Vector of level or group names, must be the same length as files, i.e. each file set will be associated with a different group. If not given, default group names will be set.

  2. Lists with the second configuration are used to load data from environment variables, and require the following fields:

    name

    A string specifying the comparison name.

    grpout

    Either an object of class grpoutputs or a list with the following two fields:

    data

    List of all outputs, where tags correspond to output names and values correspond to the output data. Output data is a n x m matrix, where n is the total number of output observations and m is the number of variables (i.e. output length).

    obs_lvls

    Levels or groups associated with each observation.

concat

Create an additional, concatenated output? Ignored for sublists passed in the comps which follow the second configuration.

centscal

Method for centering and scaling outputs if concat is TRUE. It can be one of "center", "auto", "range" (default), "iqrange", "vast", "pareto" or "level". Centering and scaling is performed by the centerscale function.

lim_npcs

Limit number of principal components used for MANOVA to minimum number of observations per group?

mnv_test

The name of the test statistic to be used in MANOVA, as described in summary.manova.

...

Options passed to read.table, which is used to read the files specified in lists using the first configuration in the comp parameter.

Value

An object of class micomp, which is a two-dimensional list of cmpoutput objects. Rows are associated with individual outputs, while columns are associated with separate comparisons.

Examples


# Create a micomp object from existing files and folders

dir_nl_ok <-
  system.file("extdata", "nl_ok", package = "micompr")
dir_jex_ok <-
  system.file("extdata", "j_ex_ok", package = "micompr")
dir_jex_noshuff <-
  system.file("extdata", "j_ex_noshuff", package = "micompr")
dir_jex_diff <-
  system.file("extdata", "j_ex_diff", package = "micompr")
files <- glob2rx("stats400v1*.tsv")

mic <- micomp(7, 0.8,
              list(list(name = "NLOKvsJEXOK",
                        folders = c(dir_nl_ok, dir_jex_ok),
                        files = c(files, files),
                        lvls = c("NLOK", "JEXOK")),
                   list(name = "NLOKvsJEXNOSHUFF",
                        folders = c(dir_nl_ok, dir_jex_noshuff),
                        files = c(files, files),
                        lvls = c("NLOK", "JEXNOSHUFF")),
                   list(name = "NLOKvsJEXDIFF",
                        folders = c(dir_nl_ok, dir_jex_diff),
                        files = c(files, files),
                        lvls = c("NLOK", "JEXDIFF"))),
              concat = TRUE)


# Create a micomp object from package datasets (i.e. grpoutputs objects)
# directly

mic <- micomp(c("o1", "o2", "o3", "o4"), 0.9,
              list(list(name = "NLOKvsJEXOK", grpout = pphpc_ok),
                   list(name = "NLOKvsJEXNOSHUFF", grpout = pphpc_noshuff),
                   list(name = "NLOKvsJEXDIFF", grpout = pphpc_diff)))

# Create a micomp object using manually inserted data

mic <- micomp(6, 0.5, list(
  list(name = "NLOKvsJEXOK",
       grpout = list(data = pphpc_ok$data,
                     obs_lvls = pphpc_ok$obs_lvls)),
  list(name = "NLOKvsJEXNOSHUFF",
       grpout = list(data = pphpc_noshuff$data,
                     obs_lvls = pphpc_noshuff$obs_lvls)),
  list(name = "NLOKvsJEXDIFF",
       grpout = list(data = pphpc_diff$data,
                     obs_lvls = pphpc_diff$obs_lvls))))


fakenmc/micompr documentation built on Aug. 6, 2024, 8:29 p.m.