sdc_loglinear {SDCNway}R Documentation

Calculates file-level risk measures using a loglinear model.

Description

Calculates file-level risk measures using a loglinear model.

Usage

sdc_loglinear(
  data,
  weight,
  varpool,
  degree = 2,
  numiter = 40,
  epsilon = 0.001,
  blanks_as_missing = TRUE,
  output_filename = NULL
)

## S3 method for class 'sdc_loglinear'
print(x, summary_outfile = NULL, ...)

## S3 method for class 'sdc_loglinear'
plot(x, plotpath = NULL, plotvar1 = character(0), plotvar2 = character(0), ...)

Arguments

data

Data frame containing the data to be evaluated.

weight

Column name for sampling weights.

varpool

Vector of column names to be used in model.

degree

Highest degree of interaction terms to be used in the model.

numiter

Maximum number of iterations to run iterative proportional fitting for the loglinear model.

epsilon

Maximum deviation allowed between observed and fitted margins.

blanks_as_missing

If TRUE, character and factor variables that are blank or pure whitespace are treated as missing values.

output_filename

Name of the csv file to save the data set with record-level risk measures, .tau1_rec and .tau2_rec, attached. NULL if no output file is to be saved.

x

Object of class sdc_loglinear, as returned by sdc_loglinear.

summary_outfile

Name of summary output .txt file. If not NULL, console output is copied to the file. Default is NULL (no logging of output). Errors and warnings are not diverted (consider running in batch mode if logging is needed).

...

Currently unused. For NextMethod compatibility.

plotpath

Directory to save plots. Plots are saved as jpeg files (quality = 100%). If the directory does not exist, it is first created. If plotpath is NULL (default), plots are not saved.

plotvar1

A vector of names of discrete variables for boxplots. If none, boxplots are not produced.

plotvar2

A vector of names of continuous variables for scatterplots. If none, scatterplots are not produced.

Details

The data should not contain any missing values among varpool variables or the weight variable.

Value

An object of type sdc_loglinear containing calculated risk measures.

Methods (by generic)

Examples

data(exampledata)
vars <- c("BORNUSA", "CENREG", "DAGE3", "DRACE3", "EDUC3", "GENDER")
wgt <- "WEIGHT"

results <- sdc_loglinear(exampledata, wgt, vars, degree=3)
print(results)
plot(results, plotvar1="BORNUSA", plotvar2="WEIGHT")

[Package SDCNway version 1.0.1 Index]