make.quantile.matrix: Making Quantiles of Correlated Index

Description Usage Arguments Details Value Note See Also Examples

View source: R/make_quantile_matrix_WQS.R

Description

Scores quantiles from a numeric matrix. If the matrix has values missing between zero and some threshold, say the detection limit, all these missing values (indicated by NA) are placed into the first quantile.

Usage

1
2
3
4
5
6
7
make.quantile.matrix(
  X,
  n.quantiles,
  place.bdls.in.Q1 = if (anyNA(X)) TRUE else FALSE,
  ...,
  verbose = FALSE
)

Arguments

X

A numeric matrix. Any missing values are indicated by NA's.

n.quantiles

An integer specifying the number of quantiles in categorizing the columns of X, e.g. in quartiles (q = 4), deciles (q = 10), or percentiles (q = 100). Default: 4L.

place.bdls.in.Q1

Logical; if TRUE or X has any missing values, missing values in X are placed in the first quantile of the weighted sum. Otherwise, the data is complete (no missing data) and the data is equally split into quantiles.

...

further arguments passed to or from other methods.

verbose

Logical; if TRUE, prints more information. Useful to check for any errors in the code. Default: FALSE.

Details

Produces sample quantiles for a matrix X using quantile() function. Names are kept and the 7th quantile algorithm is used. As ties between quantiles may exist, .bincode() is used.

When there is missing data (as indicated by NA's), make.quantile.matrix places all of the censored data into the first quantile. The remaining quantiles are evenly spread over the observed data. A printed message is displaced what the function does.

Value

A matrix of quantiles with rows = nrow(X) and with columns = n.quantiles.

Note

Developed as an accessory function for estimate.wqs().

See Also

quantile

Other wqs: analyze.individually(), coef.wqs(), do.many.wqs(), estimate.wqs.formula(), estimate.wqs(), plot.wqs(), print.wqs()

Examples

1
2
3
4
5
6
7
8
9
# Example 1: Make quantiles for first nine chemicals using complete chemical data
data(simdata87)
q <- make.quantile.matrix(simdata87$X.true[, 1:9], 4)
q <- apply(q, 2, as.factor)
summary(q)

# Example 2: Place missing values of first nine chemicals in first quantiles
q2 <- make.quantile.matrix(simdata87$X.bdl[, 1:9], 4, verbose = TRUE)
summary(q2)

miWQS documentation built on April 3, 2021, 1:06 a.m.