wtd.moments | R Documentation |

Compute the 2nd, 3rd, 4th moments, skewness, and kurtosis of a variable from either population or sample input

```
wtd.moments(y, w=NULL, pop.sw=TRUE)
```

`y` |
variable to be analyzed |

`w` |
vector of weights if the input is a sample |

`pop.sw` |
is the input for a population ( |

The `r^{th}`

population moment is defined as `m_r = (1/N) \sum_{k \in U} (y_k - \bar{y}_U)^r`

where *U* is the set of population units, *N* is the population size, and `\bar{y}_U`

is the population mean. When the input is for the whole population, `wtd.moments`

evaluates this directly for `r=2, 3, 4`

. When the input is for a sample, the `r^{th}`

moment is estimated as `\hat{m}_r = (K/\hat{N}) \sum_{k \in s} ( w_k (y_k - \hat{\bar{y}}_U)^r ), r=2, 3, 4`

where `s`

is the set of sample units, `w_k`

is the weight for sample unit `k`

, `\hat{N} = \sum_s w_k`

, and `\hat{\bar{y}}_U = \sum_{k \in s} w_k y_k / \hat{N}`

. When `r=2`

, `K=n/(n-1)`

so that the estimator equals the unbiased variance estimator if the sample is a simple random sample; if `r=3,4`

, then `K=1`

. The function also computes or estimates the population skewness, defined as `m_3/m_2^{3/2}`

and the population kurtosis, `m_4/m_2^2`

.

The weights should be scaled for estimating population totals. The sample can be obtained from any complex design.

Vector with values:

`m2` |
2nd moment |

`m3` |
3rd moment |

`m4` |
4th moment |

`skewness` |
skewness |

`kurtosis` |
kurtosis |

Richard Valliant, Jill A. Dever, Frauke Kreuter

Valliant, R., Dever, J., Kreuter, F. (2018, sect. 3.4). *Practical Tools for Designing and Weighting Survey Samples, 2nd edition*. New York: Springer.

`wtdvar`

```
require(PracTools)
wtd.moments(y = hospital$y, w = NULL)
require(sampling)
sam <- strata(data = labor, stratanames = "h", size = c(30, 20, 10), method = c("srswor"),
description=TRUE)
samdat <- labor[sam$ID_unit,]
wtd.moments(y = samdat$WklyWage, w = 1/sam$Prob, pop.sw=FALSE)
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.