RegSDCcomp: Regression-based SDC Tools - Component score correlation...

View source: R/RegSDCcomp.R

RegSDCcompR Documentation

Regression-based SDC Tools - Component score correlation control

Description

Implementation of equation 8 in the paper.

Usage

RegSDCcomp(
  y,
  compCorr = NA,
  x = NULL,
  doSVD = FALSE,
  makeunique = TRUE,
  ensureIntercept = TRUE
)

Arguments

y

Matrix of confidential variables

compCorr

Required component score correlations (possibly recycled)

x

Matrix of non-confidential variables

doSVD

SVD when TRUE and QR when FALSE

makeunique

Parameter to be used in GenQR

ensureIntercept

Whether to ensure/include a constant term. Non-NULL x is subjected to EnsureIntercept

Details

NA component score correlation means independent random. Input matrices are subjected to EnsureMatrix.

Value

Generated version of y

Author(s)

Øyvind Langsrud

Examples

x <- matrix(1:10, 10, 1)
y <- matrix(rnorm(30) + 1:30, 10, 3)

# Same as IPSO (RegSDCipso)
RegSDCcomp(y, NA, x)

# Using QR and SVD
yQR <- RegSDCcomp(y, c(0.1, 0.2, NA), x)
ySVD <- RegSDCcomp(y, c(0.1, 0.2, NA), x, doSVD = TRUE)

# Calculation of residuals
r <- residuals(lm(y ~ x))
rQR <- residuals(lm(yQR ~ x))
rSVD <- residuals(lm(ySVD ~ x))

# Correlations for two first components as required
diag(cor(GenQR(r)$Q, GenQR(rQR)$Q))
diag(cor(GenQR(r, doSVD = TRUE)$Q, GenQR(rSVD, doSVD = TRUE)$Q))

# Identical covariance matrices
cov(yQR) - cov(ySVD)
cov(rQR) - cov(rSVD)

# Identical regression results
summary(lm(y[, 1] ~ x))
summary(lm(yQR[, 1] ~ x))
summary(lm(ySVD[, 1] ~ x))

RegSDC documentation built on Aug. 19, 2022, 9:08 a.m.

Related to RegSDCcomp in RegSDC...