analyze_cat: Estimation of weighted proportions of categorical data

View source: R/analyzing.R

analyze_catR Documentation

Estimation of weighted proportions of categorical data

Description

Given categorical data and the weights for the individual observations, calculate estimated proportions by category and Goodman's multinomial confidence intervals.

Usage

analyze_cat(
  data,
  weights,
  id_var,
  cat_var,
  wgt_var,
  definitions = NULL,
  conf = 80,
  verbose = FALSE
)

Arguments

data

Data frame. Categorical data with the unique identifiers for each observation/row in the variable id_var and the assigned category for each observation/row in cat_var. Note that the unique identifiers are the link between data and weights

weights

Data frame. This must contain the weighting information using the variables id_var with a unique identifier for each observation/row and wgt_var with the relative numeric weight of each observation/row.

id_var

Character string. The name of the variable in data and weights that contains the unique identifiers for the observations. All values in data$id_var must appear in weights$id_var.

cat_var

Character string. The name of the variable in data that contains the category values as character strings.

wgt_var

Character string. The name of the variable in weights that contains the numeric weight values.

definitions

Conditionally optional character vector. The possible categories that the observation could've been classed into. This is NOT optional if there are categories that do not appear in data because no observations met their criteria because those categories must be included in the calculations. Must contain at least the values in code$cat_var but should include ALL possible categories.

conf

Numeric. The confidence level in percent. Defaults to 80.

verbose

Logical. If TRUE then the function will generate additional messages as it executes. Defaults to FALSE.

Value

A data frame containing the categories, counts of observations, weighted estimated proportions, and confidence intervals.


nstauffer/aim.analysis documentation built on Nov. 2, 2023, 12:52 a.m.