| Title: | Generalized Hybrid Contrast Coding in Linear Models |
|---|---|
| Description: | Implements generalized hybrid contrast coding methods for K-level categorical predictors in linear models as established by Obulezi (2026)[cite: 3]. The package automates design matrix construction mixing dummy indicators and composite group contrasts, checks rank constraints via singular value decomposition, computes closed-form OLS parameter mappings, and estimates robust heteroscedastic covariance matrices[cite: 3]. |
| Authors: | Okechukwu J. Obulezi [aut, cre] |
| Maintainer: | Okechukwu J. Obulezi <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-10-09 11:28:27 UTC |
| Source: | https://github.com/cran/ghcclm |
Constructs a non-orthogonal, full-rank hybrid design matrix for qualitative factors with K >= 3 levels, combining dummy indicator columns with composite simple contrast vectors.
build_ghc_matrix(K, n, tol = 1e-12)build_ghc_matrix(K, n, tol = 1e-12)
K |
Positive integer. Total number of factor levels (K >= 3). |
n |
Integer vector of length K giving sub-sample sizes per group. |
tol |
Numeric tolerance threshold for SVD singular values to verify rank. |
A numeric design matrix of size N x K (where N = sum(n)) with class
attribute "ghc_matrix" and matrix attribute "C_operator".
XH <- build_ghc_matrix(K = 3, n = c(10, 10, 10)) attr(XH, "condition_number")XH <- build_ghc_matrix(K = 3, n = c(10, 10, 10)) attr(XH, "condition_number")
Computes linear regression parameters using analytical hybrid contrast mappings. Provides theoretical variance-covariance estimators under both homoscedasticity and heteroscedasticity.
ghc_lm(formula, data, robust = FALSE)ghc_lm(formula, data, robust = FALSE)
formula |
Object of class |
data |
Data frame containing continuous response and categorical predictor. |
robust |
Logical. If TRUE, computes Huber-White sandwich variance. |
An S3 object of class "ghc_lm" containing fitted metrics.
set.seed(123) dat <- data.frame( group = factor(rep(1:3, each = 10)), y = rnorm(30, mean = 50, sd = 5) ) mod <- ghc_lm(y ~ group, data = dat) summary(mod)set.seed(123) dat <- data.frame( group = factor(rep(1:3, each = 10)), y = rnorm(30, mean = 50, sd = 5) ) mod <- ghc_lm(y ~ group, data = dat) summary(mod)