Learn R Programming

RegSDC (version 0.4.0)

IpsoExtra: Extended variant of RegSDCipso

Description

Possible to generate several y's and to re-scale residuals.

Usage

IpsoExtra(
  y,
  x = NULL,
  ensureIntercept = TRUE,
  returnParts = FALSE,
  nRep = 1,
  resScale = NULL,
  digits = 9,
  rmse = NULL
)

Arguments

y

Matrix of confidential variables

x

Matrix of non-confidential variables

ensureIntercept

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

returnParts

Alternative output two matrices: yHat (fitted) and yRes (generated residuals).

nRep

Integer, when >1, several y's will be generated. Extra columns in output.

resScale

Residuals will be scaled by resScale

digits

Digits used to detect perfect fit (caused by fitted values as input). This checking will be done only when rmse is in input. When perfect fit, rmse will be used instead of resScale.

rmse

Desired root mean square error (residual standard error). Will be used when resScale is NULL or cannot be used (see parameter digits). This parameter is possible only when single y variable.

Value

Generated version of y

Examples

Run this code
# NOT RUN {
x <- matrix(1:5, 5, 1)
y <- matrix(10 * (sample(7:39, 15) + 4 * (1:15)), 5, 3)
colnames(y) <- paste("y", 1:3, sep = "")
y1 <- y[, 1, drop = FALSE]

IpsoExtra(y, x)  # Same as RegSDCipso(y, x)

IpsoExtra(y, x, resScale = 0)  # Fitted values (whole numbers in this case)
IpsoExtra(y, x, nRep = 2, resScale = 1e-05)  # Downscaled residuals 

ySynth <- IpsoExtra(y1, x, nRep = 2, rmse = 0.25)  # Downscaled residuals 
summary(lm(ySynth ~ x))  # Identical regression results with Residual standard error: 0.25

IpsoExtra(fitted(lm(y1 ~ x)), x, nRep = 2, resScale = 0.1)  # resScale no effect since perfect fit
IpsoExtra(fitted(lm(y1 ~ x)), x, nRep = 2, resScale = 0.1, rmse = 2)  # with warning

# Using data in the paper
IpsoExtra(RegSDCdata("sec7y"), RegSDCdata("sec7x"))  # Similar to Y*
IpsoExtra(RegSDCdata("sec7y"), RegSDCdata("sec7x"), rmse = 1)
# }

Run the code above in your browser using DataLab