Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

weighted.mean.circular

Weighted Mean Direction


Description

Returns the weighetd mean direction of a vector of circular data.

Usage

## S3 method for class 'circular'
weighted.mean(x, w, na.rm=FALSE,
  control.circular=list(), ...)

Arguments

x

a vector. The object is coerced to class circular.

w

a numerical vector of weights the same length as x giving the weights to use for elements of x.

na.rm

logical, indicating if NA's should be omitted.

control.circular

the attribute of the resulting object.

...

further arguments passed to or from other methods.

Details

Each observation is treated as a unit vector, or point on the unit circle. The resultant vector of the observations is found, and the direction of the resultant vector is returned. An NA is returned if the weighted resultant length is less than .Machine.

If w is missing then all elements of x are given the same weight, otherwise the weights coerced to numeric by as.numeric and normalized to sum to one.

Missing values in w are not handled specially and so give a missing value as the result. However, zero weights are handled specially and the corresponding x values are omitted from the computation.

Value

Returns the weighted mean direction of the data as an object of class circular with the attribute given by control.circular or from x if missed in control.circular.

Author(s)

Claudio Agostinelli

See Also

Examples

# Compute the weighted mean direction of a random sample of observations.
x <- circular(runif(50, circular(0), pi))
w <- runif(50, 0, 1)
weighted.mean(x, w)

circular

Circular Statistics

v0.4-93
GPL-2
Authors
Ulric Lund <ulund@calpoly.edu> [aut], Claudio Agostinelli <claudio.agostinelli@unitn.it> [aut, cre], Hiroyoshi Arai <h_arai@aoni.waseda.jp> [ctb], Alessando Gagliardi <gagliardi@stud.unive.it> [ctb], Eduardo Garcia Portugues <edgarcia@est-econ.uc3m.es> [ctb], Dimitri Giunchi <dimitri.giunchi@unipi.it> [ctb], Jean-Olivier Irisson <irisson@normalesup.org> [ctb], Matthew Pocernich <pocernic@ucar.edu> [ctb], Federico Rotolo [ctb]
Initial release
2017-06-26

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.