Learn R Programming

AdapDiscom (version 1.0.0)

compute.xtx: Compute X'X Matrix

Description

Compute X'X Matrix

Usage

compute.xtx(x, robust = 0, k_value = 1.5)

Value

Covariance matrix

Arguments

x

Matrix, input data matrix

robust

Integer, 0 for classical estimate, 1 for Huber robust estimate

k_value

Numeric, tuning parameter for Huber function

Examples

Run this code
# Create sample data with missing values
set.seed(123)
x <- matrix(rnorm(100), 20, 5)
x[sample(100, 10)] <- NA  # Introduce missing values

# Classical covariance estimation
xtx_classical <- compute.xtx(x, robust = 0)
print(round(xtx_classical, 3))

# Robust covariance estimation
xtx_robust <- compute.xtx(x, robust = 1, k_value = 1.5)
print(round(xtx_robust, 3))

Run the code above in your browser using DataLab