From f1d9db8777a8da9b3b10f6003953066d6b4bca46 Mon Sep 17 00:00:00 2001 From: nfrerebeau Date: Wed, 6 Sep 2023 12:48:06 +0200 Subject: [PATCH] Clean documentation --- R/AllClasses.R | 21 ++++- R/AllGenerics.R | 79 +++++++++---------- R/coerce.R | 6 +- R/outliers.R | 20 ++--- inst/examples/ex-outliers.R | 7 +- inst/tinytest/_tinysnapshot/plot_outliers.svg | 72 +++++++++-------- man/CompositionMatrix-class.Rd | 8 ++ man/LogRatio-class.Rd | 8 ++ man/OutlierIndex-class.Rd | 12 ++- man/aggregate.Rd | 2 +- man/as_amounts.Rd | 2 +- man/as_composition.Rd | 9 ++- man/as_graph.Rd | 2 +- man/covariance.Rd | 2 +- man/dist.Rd | 2 +- man/groups.Rd | 2 +- man/mahalanobis.Rd | 2 +- man/mean.Rd | 2 +- man/outliers.Rd | 28 +++---- man/pca_coda.Rd | 4 +- man/plot_coda.Rd | 2 +- man/plot_logratio.Rd | 2 +- man/plot_outliers.Rd | 9 ++- man/samples.Rd | 2 +- man/transform_alr.Rd | 4 +- man/transform_clr.Rd | 4 +- man/transform_ilr.Rd | 4 +- man/transform_inverse.Rd | 4 +- man/transform_lr.Rd | 4 +- man/transform_plr.Rd | 4 +- man/variation.Rd | 2 +- 31 files changed, 186 insertions(+), 145 deletions(-) diff --git a/R/AllClasses.R b/R/AllClasses.R index 6775bb3..ae1f0bc 100644 --- a/R/AllClasses.R +++ b/R/AllClasses.R @@ -42,6 +42,11 @@ NULL #' @slot samples A [`character`] vector to store the sample identifiers #' (allows duplicates in case of repeated measurements). #' @slot groups A [`character`] vector to store the group names (if any). +#' @section Coerce: +#' In the code snippets below, `x` is a `CompositionMatrix` object. +#' \describe{ +#' \item{`as.data.frame(x)`}{Coerces to a [`data.frame`].} +#' } #' @note #' This class inherits from [`matrix`]. #' @seealso [as_composition()] @@ -77,6 +82,11 @@ NULL #' @slot base A [`numeric`] matrix to store the basis of the transformation. #' @slot weights A [`numeric`] vector to store the weights assigned to the #' respective log-ratios. +#' @section Coerce: +#' In the code snippets below, `x` is a `LogRatio` object. +#' \describe{ +#' \item{`as.data.frame(x)`}{Coerces to a [`data.frame`].} +#' } #' @note #' These classes inherit from [`matrix`]. #' @seealso [transform_lr()], [transform_clr()], [transform_alr()], @@ -147,9 +157,14 @@ NULL #' @slot groups A [`character`] vector to store the group names (if any). #' @slot distances A [`numeric`] vector giving the squared Mahalanobis distance. #' @slot limit A [`numeric`] value giving the cut-off value used for outlier -#' detection. +#' detection (quantile of the Chi-squared distribution). #' @slot robust An [`logical`] scalar: were robust estimators used? -#' @slot df A (non-negative) [`numeric`] value giving the degrees of freedom. +#' @slot dof A (non-negative) [`numeric`] value giving the degrees of freedom. +#' @section Coerce: +#' In the code snippets below, `x` is a `OutlierIndex` object. +#' \describe{ +#' \item{`as.data.frame(x)`}{Coerces to a [`data.frame`].} +#' } #' @note #' These classes inherit from [`logical`]. #' @author N. Frerebeau @@ -165,7 +180,7 @@ NULL distances = "numeric", limit = "numeric", robust = "logical", - df = "integer" + dof = "integer" ), contains = "logical" ) diff --git a/R/AllGenerics.R b/R/AllGenerics.R index 48a8347..2796281 100644 --- a/R/AllGenerics.R +++ b/R/AllGenerics.R @@ -18,20 +18,21 @@ setGeneric("mahalanobis", package = "stats") #' group the samples. If `NULL` (the default), no grouping is stored. #' @param ... Currently not used. #' @details -#' The [CompositionMatrix-class] class has special slots -#' (see `vignette("nexus")`): +#' The [`CompositionMatrix-class`] class has special slots: #' #' * `samples` for repeated measurements/observation, #' * `groups` to group data by site/area. #' -#' When coercing a `data.frame` to a [CompositionMatrix-class] object, an +#' When coercing a `data.frame` to a [`CompositionMatrix-class`] object, an #' attempt is made to automatically assign values to these slots by mapping #' column names (case insensitive, plural insensitive). This behavior can be #' disabled by setting `options(nexus.autodetect = FALSE)` or overridden by #' explicitly specifying the columns to be used. +#' +#' See `vignette("nexus")`. #' @note #' All non-numeric variable will be removed. -#' @return A [CompositionMatrix-class] object. +#' @return A [`CompositionMatrix-class`] object. #' @example inst/examples/ex-coerce.R #' @author N. Frerebeau #' @docType methods @@ -45,7 +46,7 @@ setGeneric( #' Coerce to Amounts #' -#' @param from A [CompositionMatrix-class] object. +#' @param from A [`CompositionMatrix-class`] object. #' @param ... Currently not used. #' @return A [`numeric`] [`matrix`]. #' @example inst/examples/ex-coerce.R @@ -81,7 +82,7 @@ setGeneric( # Extract ====================================================================== ## Mutators -------------------------------------------------------------------- -#' Deal With Groups +#' Working With Groups #' #' Retrieves or defines the groups to which the observations belong. #' @param x An object from which to get or set `groups`. @@ -121,7 +122,7 @@ setGeneric( def = function(x, value) standardGeneric("set_groups<-") ) -#' Deal With Samples +#' Wirking With Samples #' #' Retrieves or defines the sample names. #' @param x An object from which to get or set `samples`. @@ -228,10 +229,10 @@ NULL #' Pairwise Log-Ratios (LR) #' #' Computes all pairwise log-ratio transformation. -#' @param object A [CompositionMatrix-class] object. +#' @param object A [`CompositionMatrix-class`] object. #' @param ... Currently not used. #' @return -#' A [LR-class] object. +#' A [`LR-class`] object. #' @references #' Aitchison, J. (1986). *The Statistical Analysis of Compositional Data*. #' London: Chapman and Hall. \doi{10.1007/978-94-009-4109-0}. @@ -253,13 +254,13 @@ setGeneric( #' Centered Log-Ratios (CLR) #' #' Computes CLR transformation. -#' @param object A [CompositionMatrix-class] object. +#' @param object A [`CompositionMatrix-class`] object. #' @param weights A [`logical`] scalar: sould a varying weight be used. If #' `FALSE` (the default), equally-weighted parts are used. Alternatively, a #' positive [`numeric`] vector of weights can be specified. #' @param ... Currently not used. #' @return -#' A [CLR-class] object. +#' A [`CLR-class`] object. #' @references #' Aitchison, J. (1986). *The Statistical Analysis of Compositional Data*. #' London: Chapman and Hall. \doi{10.1007/978-94-009-4109-0}. @@ -281,11 +282,11 @@ setGeneric( #' Additive Log-Ratios (ALR) #' #' Computes ALR transformation. -#' @param object A [CompositionMatrix-class] object. +#' @param object A [`CompositionMatrix-class`] object. #' @param j An [`integer`] giving the index of the rationing part (denominator). #' @param ... Currently not used. #' @return -#' An [ALR-class] object. +#' An [`ALR-class`] object. #' @references #' Aitchison, J. (1986). *The Statistical Analysis of Compositional Data*. #' London: Chapman and Hall. \doi{10.1007/978-94-009-4109-0}. @@ -307,14 +308,14 @@ setGeneric( #' Isometric Log-Ratios (ILR) #' #' Computes ILR transformations. -#' @param object A [CompositionMatrix-class] object. +#' @param object A [`CompositionMatrix-class`] object. #' @param ... Currently not used. #' @details #' The ILR transformation provides the coordinates of any composition with #' respect to a given orthonormal basis. `transform_ilr()` uses the orthonormal #' basis (Helmert matrix) originally defined by Egozcue *et al.* (2003). #' @return -#' An [ILR-class] object. +#' An [`ILR-class`] object. #' @references #' Egozcue, J. J., Pawlowsky-Glahn, V., Mateu-Figueras, G. & Barceló-Vidal, C. #' (2003). Isometric Logratio Transformations for Compositional Data Analysis. @@ -337,11 +338,11 @@ setGeneric( #' Pivot Log-Ratios (PLR) #' #' Computes PLR transformations. -#' @param object A [CompositionMatrix-class] object. +#' @param object A [`CompositionMatrix-class`] object. #' @param pivot An [`integer`] giving the index of the pivotal variable. #' @param ... Currently not used. #' @return -#' A [PLR-class] object. +#' A [`PLR-class`] object. #' @references #' Fišerová, E. & Hron, K. (2011). On the Interpretation of Orthonormal #' Coordinates for Compositional Data. *Mathematical Geosciences*, 43(4), @@ -369,10 +370,10 @@ setGeneric( #' Inverse Log-Ratio Transformation #' #' Computes inverse log-ratio transformations. -#' @param object A [CompositionMatrix-class] object. +#' @param object A [`CompositionMatrix-class`] object. #' @param ... Currently not used. #' @return -#' A [CompositionMatrix-class] object. +#' A [`CompositionMatrix-class`] object. #' @references #' Aitchison, J. (1986). *The Statistical Analysis of Compositional Data*. #' London: Chapman and Hall. \doi{10.1007/978-94-009-4109-0}. @@ -403,7 +404,7 @@ setGeneric( #' #' Splits the data into subsets, computes summary statistics for each, and #' returns the result. -#' @param x A [CompositionMatrix-class] object. +#' @param x A [`CompositionMatrix-class`] object. #' @param by A [`character`] string specifying the grouping element. It must be #' one of "`samples`" or "`groups`". Any unambiguous substring can be given. #' @param FUN A [`function`] to compute the summary statistics. @@ -419,7 +420,7 @@ NULL #' Compositional Mean #' -#' @param x A [CompositionMatrix-class] object. +#' @param x A [`CompositionMatrix-class`] object. #' @param ... Further argument to be passed to other methods. #' @details #' Closed vector of the columns geometric means. @@ -440,7 +441,7 @@ NULL #' @description #' * `variance()` computes the log-ratio variance matrix. #' * `covariance()` computes the log-ratio covariance matrix. -#' @param x A [CompositionMatrix-class] object. +#' @param x A [`CompositionMatrix-class`] object. #' @param method A [`character`] string indicating which correlation coefficient #' (or covariance) is to be computed (see [stats::cov()]). #' @param ... Currently not used. @@ -473,7 +474,7 @@ setGeneric( #' Variation Matrix #' #' Computes the compositional variation array. -#' @param object A [CompositionMatrix-class] object. +#' @param object A [`CompositionMatrix-class`] object. #' @param ... Currently not used. #' @return A [`matrix`]. #' @details @@ -498,7 +499,7 @@ setGeneric( #' Distances #' #' Computes the log-ratio variance matrix. -#' @param x A [CompositionMatrix-class] object. +#' @param x A [`CompositionMatrix-class`] object. #' @param method A [`character`] string specifying the distance measure to be #' used. See [stats::dist()] for the available distances. #' @param diag A [`logical`] scalar indicating whether the diagonal of the @@ -527,7 +528,7 @@ NULL #' Mahalanobis Distance #' #' Computes the squared Mahalanobis distance of all rows in `x`. -#' @param x A [CompositionMatrix-class] object. +#' @param x A [`CompositionMatrix-class`] object. #' @param center A [`numeric`] vector giving the mean vector of the #' distribution. If missing, will be estimated from `x`. #' @param cov A [`numeric`] matrix giving the covariance of the @@ -549,7 +550,7 @@ NULL #' Plot Compositional Data #' #' Displays a compositional bar chart. -#' @param x A [CompositionMatrix-class] object. +#' @param x A [`CompositionMatrix-class`] object. #' @param order An [`integer`] vector giving the index of the column to be used #' for the ordering of the data. #' @param decreasing A [`logical`] scalar: should the sort order be increasing @@ -581,7 +582,7 @@ NULL #' Plot Log-Ratios #' #' Displays a density plot. -#' @param x A [LogRatio-class] object. +#' @param x A [`LogRatio-class`] object. #' @param order A [`logical`] scalar: should the ratio be ordered? #' @param decreasing A [`logical`] scalar: should the sort order be increasing #' or decreasing? @@ -624,7 +625,7 @@ NULL #' Graph of Log-ratios #' #' Produces a graph of log-ratios. -#' @param object A [LogRatio-class] object. +#' @param object A [`LogRatio-class`] object. #' @param ... Currently not used. #' @return #' An \pkg{igraph} graph object. @@ -643,10 +644,10 @@ setGeneric( #' #' Computes a principal components analysis based on the singular value #' decomposition. -#' @param object A [LogRatio-class] object. +#' @param object A [`LogRatio-class`] object. #' @inheritParams dimensio::pca #' @return -#' A [dimensio::PCA-class] object. +#' A [`dimensio::PCA-class`] object. #' @example inst/examples/ex-pca.R #' @seealso [dimensio::pca()], [dimensio::biplot()] #' @author N. Frerebeau @@ -659,15 +660,13 @@ NULL # Outliers ===================================================================== #' Outlier Detection #' -#' @param object A [CompositionMatrix-class]. +#' @param object A [`CompositionMatrix-class`]. #' @inheritParams mahalanobis -#' @param level A length-one [`numeric`] vector giving the significance level. -#' `level` is used as a cut-off value for outlier detection: observations with -#' larger (squared) Mahalanobis distance are considered as potential outliers. -#' @param alpha A length-one [`numeric`] vector controlling the size of the -#' subsets over which the determinant is minimized (see -#' [robustbase::covMcd()]). Only used if `robust` is `TRUE`. -#' @param ... Currently not used. +#' @param quantile A length-one [`numeric`] vector giving the significance level. +#' `quantile` is used as a cut-off value for outlier detection: observations +#' with larger (squared) Mahalanobis distance are considered as potential +#' outliers. +#' @param ... Extra parameters to be passed to [robustbase::covMcd()]. #' @details #' An outlier can be defined as having a very large Mahalanobis distance from #' all observations. In this way, a certain proportion of the observations can @@ -684,7 +683,7 @@ NULL #' why a particular threshold should be applicable to all data sets #' (Filzmoser, Garrett, and Reimann 2005). #' @return -#' An [OutlierIndex-class] object. +#' An [`OutlierIndex-class`] object. #' @references #' Filzmoser, P., Garrett, R. G. & Reimann, C. (2005). Multivariate outlier #' detection in exploration geochemistry. *Computers & Geosciences*, @@ -718,7 +717,7 @@ setGeneric( #' Plot Outliers #' -#' @param x An [OutlierIndex-class] object. +#' @param x An [`OutlierIndex-class`] object. #' @param qq A [`logical`] scalar: should a quantile-quantile plot be produced? #' @param probs A length-two [`numeric`] vector representing probabilities. #' Corresponding quantile pairs define the line drawn (see [stats::qqline()]). diff --git a/R/coerce.R b/R/coerce.R index c50a882..ad00337 100644 --- a/R/coerce.R +++ b/R/coerce.R @@ -152,7 +152,7 @@ as.data.frame.CompositionMatrix <- function(x, ...) { z <- as.data.frame(methods::as(x, "matrix")) z$samples <- get_samples(x) - if (has_groups(x)) z$groups <- get_groups(x) + z$groups <- get_groups(x) z } @@ -162,7 +162,7 @@ as.data.frame.LogRatio <- function(x, ...) { z <- as.data.frame(methods::as(x, "matrix")) z$samples <- get_samples(x) - if (has_groups(x)) z$groups <- get_groups(x) + z$groups <- get_groups(x) z } @@ -173,7 +173,7 @@ as.data.frame.OutlierIndex <- function(x, ...) { data.frame( index = seq_along(y), sample = get_samples(x), - group = if (has_groups(x)) get_groups(x) else NA_character_, + group = get_groups(x), distance = x@distances, outlier = y, row.names = NULL, diff --git a/R/outliers.R b/R/outliers.R index 9af8058..9822c61 100644 --- a/R/outliers.R +++ b/R/outliers.R @@ -10,23 +10,23 @@ setMethod( f = "outliers", signature = c(object = "CompositionMatrix"), definition = function(object, center = NULL, cov = NULL, robust = FALSE, - alpha = 0.5, level = 0.975) { + quantile = 0.975, ...) { - df <- ncol(object) - 1L - distance <- sqrt(mahalanobis(object, center = center, cov = cov, - robust = robust, alpha = alpha)) - limit <- sqrt(stats::qchisq(p = level, df = df)) - out <- distance > limit + dof <- ncol(object) - 1L + d2 <- mahalanobis(object, center = center, cov = cov, ..., robust = robust) + d <- sqrt(d2) + limit <- sqrt(stats::qchisq(p = quantile, df = dof)) + out <- d > limit names(out) <- rownames(object) .OutlierIndex( out, samples = get_samples(object), groups = get_groups(object), - distances = distance, + distances = d, limit = limit, robust = robust, - df = df + dof = dof ) } ) @@ -45,7 +45,7 @@ plot.OutlierIndex <- function(x, qq = FALSE, limit = TRUE, panel.first = NULL, panel.last = NULL, ...) { ## Prepare data data <- as.data.frame(x) - dof <- x@df + dof <- x@dof khi <- stats::qchisq(stats::ppoints(nrow(data)), df = dof) i <- if (qq) order(data$distance) else seq_len(nrow(data)) data_x <- if (qq) khi else data$index @@ -59,7 +59,7 @@ plot.OutlierIndex <- function(x, qq = FALSE, limit = TRUE, ## Set plotting coordinates xlim <- range(data_x) ylim <- range(data_y) - graphics::plot.window(xlim = xlim, ylim = ylim, asp = 1) + graphics::plot.window(xlim = xlim, ylim = ylim, asp = if (qq) 1 else NA) ## Evaluate pre-plot expressions panel.first diff --git a/inst/examples/ex-outliers.R b/inst/examples/ex-outliers.R index f4ccbbc..d657319 100644 --- a/inst/examples/ex-outliers.R +++ b/inst/examples/ex-outliers.R @@ -1,6 +1,7 @@ -## Coerce to chemical data -data("hongite") -coda <- as_composition(hongite) +## Data from Day et al. 2011 +data("kommos", package = "folio") # Coerce to compositional data +kommos <- remove_NA(kommos, margin = 1) # Remove cases with missing values +coda <- as_composition(kommos, groups = 1) # Use ceramic types for grouping ## Detect outliers out <- outliers(coda) diff --git a/inst/tinytest/_tinysnapshot/plot_outliers.svg b/inst/tinytest/_tinysnapshot/plot_outliers.svg index b43fe8e..be60b0e 100644 --- a/inst/tinytest/_tinysnapshot/plot_outliers.svg +++ b/inst/tinytest/_tinysnapshot/plot_outliers.svg @@ -28,32 +28,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -67,15 +67,17 @@ 15 20 25 - - - - - --5 -0 -5 -10 + + + + + + +1.0 +1.5 +2.0 +2.5 +3.0 Index Standard Mahalanobis distance diff --git a/man/CompositionMatrix-class.Rd b/man/CompositionMatrix-class.Rd index 1653330..48bf583 100644 --- a/man/CompositionMatrix-class.Rd +++ b/man/CompositionMatrix-class.Rd @@ -23,6 +23,14 @@ the closure of the compositions).} \note{ This class inherits from \code{\link{matrix}}. } +\section{Coerce}{ + +In the code snippets below, \code{x} is a \code{CompositionMatrix} object. +\describe{ +\item{\code{as.data.frame(x)}}{Coerces to a \code{\link{data.frame}}.} +} +} + \examples{ ## Coerce to compositional data data("hongite") diff --git a/man/LogRatio-class.Rd b/man/LogRatio-class.Rd index 4eb1201..35c0ae7 100644 --- a/man/LogRatio-class.Rd +++ b/man/LogRatio-class.Rd @@ -45,6 +45,14 @@ respective log-ratios.} \note{ These classes inherit from \code{\link{matrix}}. } +\section{Coerce}{ + +In the code snippets below, \code{x} is a \code{LogRatio} object. +\describe{ +\item{\code{as.data.frame(x)}}{Coerces to a \code{\link{data.frame}}.} +} +} + \seealso{ \code{\link[=transform_lr]{transform_lr()}}, \code{\link[=transform_clr]{transform_clr()}}, \code{\link[=transform_alr]{transform_alr()}}, \code{\link[=transform_ilr]{transform_ilr()}}, \code{\link[=transform_plr]{transform_plr()}} diff --git a/man/OutlierIndex-class.Rd b/man/OutlierIndex-class.Rd index 1c02da1..02bbb9f 100644 --- a/man/OutlierIndex-class.Rd +++ b/man/OutlierIndex-class.Rd @@ -21,16 +21,24 @@ An S4 class to store the result of outlier detection. \item{\code{distances}}{A \code{\link{numeric}} vector giving the squared Mahalanobis distance.} \item{\code{limit}}{A \code{\link{numeric}} value giving the cut-off value used for outlier -detection.} +detection (quantile of the Chi-squared distribution).} \item{\code{robust}}{An \code{\link{logical}} scalar: were robust estimators used?} -\item{\code{df}}{A (non-negative) \code{\link{numeric}} value giving the degrees of freedom.} +\item{\code{dof}}{A (non-negative) \code{\link{numeric}} value giving the degrees of freedom.} }} \note{ These classes inherit from \code{\link{logical}}. } +\section{Coerce}{ + +In the code snippets below, \code{x} is a \code{OutlierIndex} object. +\describe{ +\item{\code{as.data.frame(x)}}{Coerces to a \code{\link{data.frame}}.} +} +} + \seealso{ Other classes: \code{\link{CompositionMatrix-class}}, diff --git a/man/aggregate.Rd b/man/aggregate.Rd index 6d1d39d..ae007b7 100644 --- a/man/aggregate.Rd +++ b/man/aggregate.Rd @@ -9,7 +9,7 @@ \S4method{aggregate}{CompositionMatrix}(x, by, FUN, ...) } \arguments{ -\item{x}{A \linkS4class{CompositionMatrix} object.} +\item{x}{A \code{\linkS4class{CompositionMatrix}} object.} \item{by}{A \code{\link{character}} string specifying the grouping element. It must be one of "\code{samples}" or "\code{groups}". Any unambiguous substring can be given.} diff --git a/man/as_amounts.Rd b/man/as_amounts.Rd index c7d02ce..7523826 100644 --- a/man/as_amounts.Rd +++ b/man/as_amounts.Rd @@ -12,7 +12,7 @@ as_amounts(from, ...) \S4method{as_amounts}{CompositionMatrix}(from) } \arguments{ -\item{from}{A \linkS4class{CompositionMatrix} object.} +\item{from}{A \code{\linkS4class{CompositionMatrix}} object.} \item{...}{Currently not used.} } diff --git a/man/as_composition.Rd b/man/as_composition.Rd index 1a59395..82097f4 100644 --- a/man/as_composition.Rd +++ b/man/as_composition.Rd @@ -27,24 +27,25 @@ If \code{NULL} (the default), row names will be used as sample IDs.} group the samples. If \code{NULL} (the default), no grouping is stored.} } \value{ -A \linkS4class{CompositionMatrix} object. +A \code{\linkS4class{CompositionMatrix}} object. } \description{ Coerces an object to a \code{CompositionMatrix} object. } \details{ -The \linkS4class{CompositionMatrix} class has special slots -(see \code{vignette("nexus")}): +The \code{\linkS4class{CompositionMatrix}} class has special slots: \itemize{ \item \code{samples} for repeated measurements/observation, \item \code{groups} to group data by site/area. } -When coercing a \code{data.frame} to a \linkS4class{CompositionMatrix} object, an +When coercing a \code{data.frame} to a \code{\linkS4class{CompositionMatrix}} object, an attempt is made to automatically assign values to these slots by mapping column names (case insensitive, plural insensitive). This behavior can be disabled by setting \code{options(nexus.autodetect = FALSE)} or overridden by explicitly specifying the columns to be used. + +See \code{vignette("nexus")}. } \note{ All non-numeric variable will be removed. diff --git a/man/as_graph.Rd b/man/as_graph.Rd index 36174d4..83000ff 100644 --- a/man/as_graph.Rd +++ b/man/as_graph.Rd @@ -18,7 +18,7 @@ as_graph(object, ...) \S4method{as_graph}{ILR}(object) } \arguments{ -\item{object}{A \linkS4class{LogRatio} object.} +\item{object}{A \code{\linkS4class{LogRatio}} object.} \item{...}{Currently not used.} } diff --git a/man/covariance.Rd b/man/covariance.Rd index 993c0f9..7ccd306 100644 --- a/man/covariance.Rd +++ b/man/covariance.Rd @@ -20,7 +20,7 @@ variance(x, ...) \S4method{covariance}{CompositionMatrix}(x, method = "pearson") } \arguments{ -\item{x}{A \linkS4class{CompositionMatrix} object.} +\item{x}{A \code{\linkS4class{CompositionMatrix}} object.} \item{...}{Currently not used.} diff --git a/man/dist.Rd b/man/dist.Rd index 417f200..bc0dc92 100644 --- a/man/dist.Rd +++ b/man/dist.Rd @@ -9,7 +9,7 @@ \S4method{dist}{CompositionMatrix}(x, method = "euclidean", diag = FALSE, upper = FALSE, p = 2) } \arguments{ -\item{x}{A \linkS4class{CompositionMatrix} object.} +\item{x}{A \code{\linkS4class{CompositionMatrix}} object.} \item{method}{A \code{\link{character}} string specifying the distance measure to be used. See \code{\link[stats:dist]{stats::dist()}} for the available distances.} diff --git a/man/groups.Rd b/man/groups.Rd index 85c97c7..d4be975 100644 --- a/man/groups.Rd +++ b/man/groups.Rd @@ -17,7 +17,7 @@ \alias{get_groups,OutlierIndex-method} \alias{set_groups<-,CompositionMatrix-method} \alias{set_groups,CompositionMatrix-method} -\title{Deal With Groups} +\title{Working With Groups} \usage{ has_groups(x) diff --git a/man/mahalanobis.Rd b/man/mahalanobis.Rd index 1353f8e..9197514 100644 --- a/man/mahalanobis.Rd +++ b/man/mahalanobis.Rd @@ -9,7 +9,7 @@ \S4method{mahalanobis}{CompositionMatrix}(x, center, cov, ..., robust = TRUE) } \arguments{ -\item{x}{A \linkS4class{CompositionMatrix} object.} +\item{x}{A \code{\linkS4class{CompositionMatrix}} object.} \item{center}{A \code{\link{numeric}} vector giving the mean vector of the distribution. If missing, will be estimated from \code{x}.} diff --git a/man/mean.Rd b/man/mean.Rd index e7cb40d..f1c75c1 100644 --- a/man/mean.Rd +++ b/man/mean.Rd @@ -9,7 +9,7 @@ \S4method{mean}{CompositionMatrix}(x, ...) } \arguments{ -\item{x}{A \linkS4class{CompositionMatrix} object.} +\item{x}{A \code{\linkS4class{CompositionMatrix}} object.} \item{...}{Further argument to be passed to other methods.} } diff --git a/man/outliers.Rd b/man/outliers.Rd index bdd0faa..7c926df 100644 --- a/man/outliers.Rd +++ b/man/outliers.Rd @@ -14,14 +14,14 @@ outliers(object, ...) center = NULL, cov = NULL, robust = FALSE, - alpha = 0.5, - level = 0.975 + quantile = 0.975, + ... ) } \arguments{ -\item{object}{A \linkS4class{CompositionMatrix}.} +\item{object}{A \code{\linkS4class{CompositionMatrix}}.} -\item{...}{Currently not used.} +\item{...}{Extra parameters to be passed to \code{\link[robustbase:covMcd]{robustbase::covMcd()}}.} \item{center}{A \code{\link{numeric}} vector giving the mean vector of the distribution. If missing, will be estimated from \code{x}.} @@ -32,16 +32,13 @@ distribution. If missing, will be estimated from \code{x}.} \item{robust}{A \code{\link{logical}} scalar: should robust location and scatter estimation be used (see \code{\link[robustbase:covMcd]{robustbase::covMcd()}})?} -\item{alpha}{A length-one \code{\link{numeric}} vector controlling the size of the -subsets over which the determinant is minimized (see -\code{\link[robustbase:covMcd]{robustbase::covMcd()}}). Only used if \code{robust} is \code{TRUE}.} - -\item{level}{A length-one \code{\link{numeric}} vector giving the significance level. -\code{level} is used as a cut-off value for outlier detection: observations with -larger (squared) Mahalanobis distance are considered as potential outliers.} +\item{quantile}{A length-one \code{\link{numeric}} vector giving the significance level. +\code{quantile} is used as a cut-off value for outlier detection: observations +with larger (squared) Mahalanobis distance are considered as potential +outliers.} } \value{ -An \linkS4class{OutlierIndex} object. +An \code{\linkS4class{OutlierIndex}} object. } \description{ Outlier Detection @@ -63,9 +60,10 @@ why a particular threshold should be applicable to all data sets (Filzmoser, Garrett, and Reimann 2005). } \examples{ -## Coerce to chemical data -data("hongite") -coda <- as_composition(hongite) +## Data from Day et al. 2011 +data("kommos", package = "folio") # Coerce to compositional data +kommos <- remove_NA(kommos, margin = 1) # Remove cases with missing values +coda <- as_composition(kommos, groups = 1) # Use ceramic types for grouping ## Detect outliers out <- outliers(coda) diff --git a/man/pca_coda.Rd b/man/pca_coda.Rd index a4241ae..245f411 100644 --- a/man/pca_coda.Rd +++ b/man/pca_coda.Rd @@ -30,7 +30,7 @@ ) } \arguments{ -\item{object}{A \linkS4class{LogRatio} object.} +\item{object}{A \code{\linkS4class{LogRatio}} object.} \item{center}{A \code{\link{logical}} scalar: should the variables be shifted to be zero centered?} @@ -57,7 +57,7 @@ internally normalized to sum 1} used.} } \value{ -A \link[dimensio:PCA-class]{dimensio::PCA} object. +A \code{\link[dimensio:PCA-class]{dimensio::PCA}} object. } \description{ Computes a principal components analysis based on the singular value diff --git a/man/plot_coda.Rd b/man/plot_coda.Rd index 885f901..0f4c484 100644 --- a/man/plot_coda.Rd +++ b/man/plot_coda.Rd @@ -22,7 +22,7 @@ ) } \arguments{ -\item{x}{A \linkS4class{CompositionMatrix} object.} +\item{x}{A \code{\linkS4class{CompositionMatrix}} object.} \item{order}{An \code{\link{integer}} vector giving the index of the column to be used for the ordering of the data.} diff --git a/man/plot_logratio.Rd b/man/plot_logratio.Rd index 6c176f5..1cc4360 100644 --- a/man/plot_logratio.Rd +++ b/man/plot_logratio.Rd @@ -26,7 +26,7 @@ ) } \arguments{ -\item{x}{A \linkS4class{LogRatio} object.} +\item{x}{A \code{\linkS4class{LogRatio}} object.} \item{order}{A \code{\link{logical}} scalar: should the ratio be ordered?} diff --git a/man/plot_outliers.Rd b/man/plot_outliers.Rd index 1e488b5..241ca1d 100644 --- a/man/plot_outliers.Rd +++ b/man/plot_outliers.Rd @@ -26,7 +26,7 @@ ) } \arguments{ -\item{x}{An \linkS4class{OutlierIndex} object.} +\item{x}{An \code{\linkS4class{OutlierIndex}} object.} \item{qq}{A \code{\link{logical}} scalar: should a quantile-quantile plot be produced?} @@ -72,9 +72,10 @@ displayed (invisibly return \code{x}). Plot Outliers } \examples{ -## Coerce to chemical data -data("hongite") -coda <- as_composition(hongite) +## Data from Day et al. 2011 +data("kommos", package = "folio") # Coerce to compositional data +kommos <- remove_NA(kommos, margin = 1) # Remove cases with missing values +coda <- as_composition(kommos, groups = 1) # Use ceramic types for grouping ## Detect outliers out <- outliers(coda) diff --git a/man/samples.Rd b/man/samples.Rd index 9e99d06..02533ce 100644 --- a/man/samples.Rd +++ b/man/samples.Rd @@ -17,7 +17,7 @@ \alias{get_samples,OutlierIndex-method} \alias{set_samples<-,CompositionMatrix-method} \alias{set_samples,CompositionMatrix-method} -\title{Deal With Samples} +\title{Wirking With Samples} \usage{ has_replicates(x) diff --git a/man/transform_alr.Rd b/man/transform_alr.Rd index c81898c..4bdd609 100644 --- a/man/transform_alr.Rd +++ b/man/transform_alr.Rd @@ -12,14 +12,14 @@ transform_alr(object, ...) \S4method{transform_alr}{CompositionMatrix}(object, j = ncol(object)) } \arguments{ -\item{object}{A \linkS4class{CompositionMatrix} object.} +\item{object}{A \code{\linkS4class{CompositionMatrix}} object.} \item{...}{Currently not used.} \item{j}{An \code{\link{integer}} giving the index of the rationing part (denominator).} } \value{ -An \linkS4class{ALR} object. +An \code{\linkS4class{ALR}} object. } \description{ Computes ALR transformation. diff --git a/man/transform_clr.Rd b/man/transform_clr.Rd index b0ce62a..62ac5d8 100644 --- a/man/transform_clr.Rd +++ b/man/transform_clr.Rd @@ -12,7 +12,7 @@ transform_clr(object, ...) \S4method{transform_clr}{CompositionMatrix}(object, weights = FALSE) } \arguments{ -\item{object}{A \linkS4class{CompositionMatrix} object.} +\item{object}{A \code{\linkS4class{CompositionMatrix}} object.} \item{...}{Currently not used.} @@ -21,7 +21,7 @@ transform_clr(object, ...) positive \code{\link{numeric}} vector of weights can be specified.} } \value{ -A \linkS4class{CLR} object. +A \code{\linkS4class{CLR}} object. } \description{ Computes CLR transformation. diff --git a/man/transform_ilr.Rd b/man/transform_ilr.Rd index 28a8c64..96a8c4b 100644 --- a/man/transform_ilr.Rd +++ b/man/transform_ilr.Rd @@ -12,12 +12,12 @@ transform_ilr(object, ...) \S4method{transform_ilr}{CompositionMatrix}(object) } \arguments{ -\item{object}{A \linkS4class{CompositionMatrix} object.} +\item{object}{A \code{\linkS4class{CompositionMatrix}} object.} \item{...}{Currently not used.} } \value{ -An \linkS4class{ILR} object. +An \code{\linkS4class{ILR}} object. } \description{ Computes ILR transformations. diff --git a/man/transform_inverse.Rd b/man/transform_inverse.Rd index 3da62f0..4b07d91 100644 --- a/man/transform_inverse.Rd +++ b/man/transform_inverse.Rd @@ -18,12 +18,12 @@ transform_inverse(object, ...) \S4method{transform_inverse}{ILR}(object) } \arguments{ -\item{object}{A \linkS4class{CompositionMatrix} object.} +\item{object}{A \code{\linkS4class{CompositionMatrix}} object.} \item{...}{Currently not used.} } \value{ -A \linkS4class{CompositionMatrix} object. +A \code{\linkS4class{CompositionMatrix}} object. } \description{ Computes inverse log-ratio transformations. diff --git a/man/transform_lr.Rd b/man/transform_lr.Rd index 1321363..2867d42 100644 --- a/man/transform_lr.Rd +++ b/man/transform_lr.Rd @@ -12,12 +12,12 @@ transform_lr(object, ...) \S4method{transform_lr}{CompositionMatrix}(object) } \arguments{ -\item{object}{A \linkS4class{CompositionMatrix} object.} +\item{object}{A \code{\linkS4class{CompositionMatrix}} object.} \item{...}{Currently not used.} } \value{ -A \linkS4class{LR} object. +A \code{\linkS4class{LR}} object. } \description{ Computes all pairwise log-ratio transformation. diff --git a/man/transform_plr.Rd b/man/transform_plr.Rd index f704d8d..a97f55b 100644 --- a/man/transform_plr.Rd +++ b/man/transform_plr.Rd @@ -12,14 +12,14 @@ transform_plr(object, ...) \S4method{transform_plr}{CompositionMatrix}(object, pivot = 1) } \arguments{ -\item{object}{A \linkS4class{CompositionMatrix} object.} +\item{object}{A \code{\linkS4class{CompositionMatrix}} object.} \item{...}{Currently not used.} \item{pivot}{An \code{\link{integer}} giving the index of the pivotal variable.} } \value{ -A \linkS4class{PLR} object. +A \code{\linkS4class{PLR}} object. } \description{ Computes PLR transformations. diff --git a/man/variation.Rd b/man/variation.Rd index 38ac806..69c5175 100644 --- a/man/variation.Rd +++ b/man/variation.Rd @@ -12,7 +12,7 @@ variation(object, ...) \S4method{variation}{CompositionMatrix}(object) } \arguments{ -\item{object}{A \linkS4class{CompositionMatrix} object.} +\item{object}{A \code{\linkS4class{CompositionMatrix}} object.} \item{...}{Currently not used.} }