Last chance! 50% off unlimited learning
Sale ends in
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)
Vector with values:
2nd moment
3rd moment
4th moment
skewness
kurtosis
variable to be analyzed
vector of weights if the input is a sample
is the input for a population (pop.sw=TRUE
) or for a sample (pop.sw=FALSE
)?
Richard Valliant, Jill A. Dever, Frauke Kreuter
The wtd.moments
evaluates this directly for
The weights should be scaled for estimating population totals. The sample can be obtained from any complex design.
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)
Run the code above in your browser using DataLab