clusterQp: Cluster-Specific Sample Quantiles

View source: R/clusterQp.R

clusterQpR Documentation

Cluster-Specific Sample Quantiles

Description

Sample quantiles in each cluster of observations.

Usage

clusterQp(
  formula,
  data,
  f_sum_ = mean.default,
  probs = seq.int(from = 0.01, to = 0.99, by = 0.01),
  ...
)

Arguments

formula

formula, including response y, cluster(s) c's, cluster-specific covariate(s) x's to be retained, and cluster-specific covariate(s) z's to be removed from data, e.g.,

y ~ 1 | c1

cluster c_1, without cluster-specific covariate

y ~ 1 | c1/c2

cluster c_1, and cluster c_2 nested in c_1, without cluster-specific covariate

y ~ x1 + x2 | c1

cluster c_1, and cluster-specific covariates x_1 and x_2

y ~ . | c1

cluster c_1, and all (supposedly cluster-specific) covariates from data

y ~ . - z1 - z2 | c1

cluster c_1, and all (supposedly cluster-specific) covariates, except for z_1 and z_2, from data

data

data.frame

f_sum_

function to summarize the sample quantiles from lower-level cluster c_2 (if present), such as mean.default (default), median.default, max, min, etc.

probs

double vector, probabilities \mathbf{p} = (p_1,\cdots,p_N)' shared across all clusters, where the cluster-specific sample quantiles of response y are calculated. Default seq(.01, .99, by = .01)

...

additional parameters of function quantile

Value

Function clusterQp returns an aggregated data.frame, in which

  • the highest cluster c_1 and cluster-specific covariate(s) x's are retained.

    • If the input formula takes form of y ~ . | c1 or y ~ . - z1 | c1, then all covariates (except for z_1) are considered cluster-specific;

    • Sample quantiles from lower-level clusters (e.g., c_2) are point-wise summarized using function f_sum_.

  • response y is removed; instead, a double matrix of N columns stores the cluster-specific sample quantiles. This matrix

    • is named after the parsed expression of response y in formula;

    • colnames are the probabilities \mathbf{p}, for the ease of subsequent programming.

Examples

# see ?`Qindex-package` for examples

Qindex documentation built on April 4, 2025, 2:14 a.m.