simulate {AuxSurvey}R Documentation

Simulate Survey Data with Discretized Auxiliary Variables

Description

This function simulates survey data with discretized auxiliary variables. It generates a population dataset with continuous and binary outcomes, and includes auxiliary variables that are discretized into multiple categories. The function also generates a subset of the population as a sample, based on the propensity scores.

Usage

simulate(N = 3000, discretize = c(3, 5, 10), setting = c(1, 2, 3), seed = NULL)

Arguments

N

Number of population units to simulate. Default is 3000.

discretize

A scale specifying the number of categories for discretizing continuous variables. The function discretizes both X and W into the specified categories. Default is a number among ⁠(3, 5, 10)⁠.

setting

A numeric value to specify the simulation setting. The settings define different relationships between the outcome variables and the covariates. Possible values are 1, 2, 3, and 4. Default is a number among c(1, 2, 3).

seed

An optional random seed for reproducibility. Default is NULL.

Details

The function supports multiple simulation settings, where each setting modifies the relationships between the outcome variables and the covariates.

Value

A list containing two elements:

Examples

# Simulate survey data with setting 1 and discretizing variables 3 categories
data = simulate(N = 3000, discretize = 3, setting = 1, seed = 123)

# Extract population and sample datasets
population = data$population
samples = data$samples

# Examine the simulated population data
head(population)


[Package AuxSurvey version 1.0 Index]