geomean: Calculates the geometric mean or geometric standard... In FSA: Simple Fisheries Stock Assessment Methods

Description

Calculates the geometric mean or standard deviation of a vector of numeric values.

Usage

 1 2 3 geomean(x, na.rm = FALSE, zneg.rm = FALSE) geosd(x, na.rm = FALSE, zneg.rm = FALSE)

Arguments

 x Vector of numeric values. na.rm Logical indicating whether to remove missing values or not. zneg.rm Logical indicating whether to ignore or remove zero or negative values found in x.

Details

The geometric mean is computed by log transforming the raw data in x, computing the arithmetic mean of the transformed data, and back-transforming this mean to the geometric mean by exponentiating.

The geometric standard deviation is computed by log transforming the raw data in x, computing the arithmetic standard deviation of the transformed data, and back-transforming this standard deviation to the geometric standard deviation by exponentiating.

Value

A numeric value that is the geometric mean or geometric standard deviation of the numeric values in x.

Note

This function is largely an implementation of the code suggested by Russell Senior on R-help in November, 1999.