Learn R Programming

RealSurvSim (version 1.0.0)

data_simul_KDE: Kernel Density Estimation-based Data Simulation

Description

Simulates data based on the kernel density estimation (KDE) of given data. KDE is a non-parametric way to estimate the probability density function of a random variable. This function applies the accept-reject method to generate values that follow the estimated density of the original dataset.

Usage

data_simul_KDE(orig_vals, n = NULL, kernel = "gaussian")

Value

Numeric vector of n simulated values.

Arguments

orig_vals

Numeric vector of values from the original dataset.

n

Integer, number of observations to simulate. If NULL, the function simulates the same number of observations as in the original dataset. Defaults to NULL.

kernel

Character, specifying the kernel to be used for KDE. Defaults to "gaussian".

Examples

Run this code
original_data <- c(rnorm(100, mean = 50, sd = 10))
simulated_data <- data_simul_KDE(original_data, n = 100)

Run the code above in your browser using DataLab