View source: R/cellwiseWeights.R
unpack | R Documentation |
This function transforms a dataset X with cellwise weights W to an extended data matrix U with the same number of columns but more rows, and containing more NA's. Its rows have the case weights v.
unpack(X,W)
X |
An |
W |
An |
A list with components:
U
unpacked data matrix, with the same columns as X
but typically more rows.
V
vector with the rowwise (=casewise) weights of U
.
P.J. Rousseeuw
P.J. Rousseeuw (2023). Analyzing cellwise weighted data. Econometrics and Statistics, appeared online. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.ecosta.2023.01.007")}(link to open access pdf)
weightedEM
,
cwLocScat
X <- matrix(c(2.8, 5.3, 4.9, 7.4,
2.3, 5.7, 4.3, 7.2,
2.5, 5.1, 4.4, 7.6), nrow = 3, byrow = TRUE)
W <- matrix(c(0.8, 1.0, 0.3, 0.4,
0.3, 0.5, 0.9, 0.5,
1.0, 0.6, 0, 0.7), nrow = 3, byrow = TRUE)
rownames(X) <- rownames(W) <- c("A", "B", "C")
colnames(X) <- colnames(W) <- c("V1", "V2", "V3", "V4")
X
W
out <- unpack(X, W)
cbind(out$U, out$v)
# For more examples, we refer to the vignette:
## Not run:
vignette("cellwise_weights_examples")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.