sdc_loglinear_iter: sdc_loglinear_iter

View source: R/loglinear.R

sdc_loglinear_iterR Documentation

sdc_loglinear_iter

Description

Calculates file-level risk measures using a loglinear model with forward stepwise variable selection for interaction terms.

Usage

sdc_loglinear_iter(
  data,
  weight,
  varpool,
  numiter = 40,
  epsilon = 0.01,
  fixed_pi = TRUE,
  intermediate_fname = "__loglin_intermediate__.rds",
  restart = FALSE,
  delta = NULL,
  verbose = TRUE,
  blanks_as_missing = TRUE,
  output_filename = NULL
)

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

## S3 method for class 'sdc_loglinear_iter'
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.

numiter

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

epsilon

Maximum deviation allowed between observed and fitted margins.

fixed_pi

If TRUE, sampling rate assumed to be the same across cells.

intermediate_fname

Name of intermediate rds file. At each iteration of variable selection, the results so far are saved to this file. This file allows for the process to be restarted if interrupted.

restart

If TRUE, restart an interrupted run.

delta

Stopping condition for variable selection. If the relative change in all risk measures is smaller than delta, stop iteration. If NULL iteration continues till all variables are used or goodness of fit measures are all negative.

verbose

If TRUE, print updates to console at each iteration of the variable selection process.

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_iter, 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.

Value

An object of type sdc_loglinear_iter containing calculated risk measures.

Methods (by generic)

  • print: S3 print method for sdc_loglinear_iter objects

    Prints summary of iterative loglinear fit.

  • plot: S3 plot method for sdc_loglinear_iter objects

    Produces boxplots and scatterplots of record-level risk measures, tau1 and tau2.

Examples

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

results <- sdc_loglinear_iter(exampledata, wgt, vars)
print(results)

SDCNway documentation built on Oct. 13, 2026, 1:06 a.m.