marginStats: Stats for initial weights, calibrated weights, and margins.

View source: R/calmarFunctions.R

marginStatsR Documentation

Stats for initial weights, calibrated weights, and margins.

Description

Just like calibrationMarginStats, gives stats about the calibration process: differences between totals after/before calibration and margins. Totals for categorical variables are displayed in percentages. The last column, named "difference", shows the difference (in percentage points) between initial estimates and margins (if colCalibratedWeights is NULL) or between calibrated estimates and margins (if colCalibratedWeights is not NULL). Output is a dataframe, which might be more convenient to export than a list (e.g. for integration into reports).

Usage

marginStats(
  data,
  marginMatrix,
  pct = FALSE,
  popTotal = NULL,
  colWeights,
  colCalibratedWeights = NULL,
  calibThreshold = 1
)

Arguments

data

dataframe containing the survey data

marginMatrix

matrix of margins

pct

Set this to true if margins for categorical variables are written in percentages

popTotal

total of population, useful if margins are entered in relative value

colWeights

name of weights column in the dataframe

colCalibratedWeights

name of calibrated weights column in the dataframe (if applicable)

calibThreshold

If difference between calibration estimate and margin differ more than this parameter, calibration is considered to have failed

Value

Dataframe containing stats on weights and margins

See Also

calibrationMarginStats


haroine/gaston documentation built on June 4, 2023, 8:24 p.m.