emm | R Documentation |
Raw empirical moments for individual and grouped data.
emm(x, order = 1, ...)
## Default S3 method:
emm(x, order = 1, ...)
## S3 method for class 'grouped.data'
emm(x, order = 1, ...)
x |
a vector or matrix of individual data, or an object of class
|
order |
order of the moment. Must be positive. |
... |
further arguments passed to or from other methods. |
Arguments ...
are passed to colMeans
;
na.rm = TRUE
may be useful for individual data with missing
values.
For individual data, the k
th empirical moment is
\sum_{j = 1}^n x_j^k
.
For grouped data with group boundaries c_0, c_1, \dots,
c_r
and group frequencies n_1, \dots,
n_r
, the k
th empirical moment is
\frac{1}{n} \sum_{j = 1}^r \frac{n_j (c_j^{k + 1} - c_{j - 1}^{k + 1})}{%
(k + 1) (c_j - c_{j - 1})},
where n = \sum_{j = 1}^r n_j
.
A named vector or matrix of moments.
Vincent Goulet vincent.goulet@act.ulaval.ca and Mathieu Pigeon
Klugman, S. A., Panjer, H. H. and Willmot, G. E. (1998), Loss Models, From Data to Decisions, Wiley.
mean
and mean.grouped.data
for simpler
access to the first moment.
## Individual data
data(dental)
emm(dental, order = 1:3)
## Grouped data
data(gdental)
emm(gdental)
x <- grouped.data(cj = gdental[, 1],
nj1 = sample(1:100, nrow(gdental)),
nj2 = sample(1:100, nrow(gdental)))
emm(x) # same as mean(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.