Skip to contents

Creates synthetic 1D functional data with optional noise components and different coefficient patterns. Uses trapezoidal rule for integration.

Usage

data_generator_po_1d(
  n = 100,
  grid_points = 100,
  noise_sd = 0.015,
  rsq = 0.95,
  beta_type = c("sin", "gaussian"),
  n_missing = 1,
  min_distance = NULL
)

Arguments

n

Number of samples to generate. Default is 100.

grid_points

Number of points in the grid. Default is 100.

noise_sd

Standard deviation of measurement noise. Default is 0.015.

rsq

Desired R-squared value for the response. Default is 0.95.

beta_type

Type of coefficient function ("sin" or "gaussian"). Default is "sin".

n_missing

Number of missing segments per curve. Default is 1.

min_distance

Minimum length of missing segments. Default is NULL (auto-calculated).

Value

A list containing:

  • curves: List of n true (noiseless) curves

  • noisy_curves: List of n observed (noisy) curves

  • noisy_curves_miss: List containing curves with missing values

  • response: Vector of n response values

  • grid: Grid points

  • beta: True coefficient function

  • stochastic_components: Vector of a values used for each curve

Generate 1D Functional Data for Simulation Studies

Creates synthetic 1D functional data with optional noise components and different coefficient patterns. Uses the trapezoidal rule for numerical integration.

A list containing:

  • curves: Matrix of n true (noiseless) curves, each as a row.

  • noisy_curves: Matrix of n observed (noisy) curves, each as a row.

  • noisy_curves_miss: Matrix of noisy curves with missing values.

  • miss_points: Indices of the missing segments in the noisy curves.

  • missing_points: Details of the missing segments for each curve.

  • response: Vector of n response values.

  • grid: Grid points on which the curves are defined.

  • beta: Coefficient function applied to the curves.

  • stochastic_components: List of stochastic coefficients used for each curve.

Examples

# Generate basic 1D functional data with default parameters
data <- data_generator_po_1d(n = 10)
#> Error in 2 * pi * grid: non-numeric argument to binary operator

# Generate data with a Gaussian-shaped coefficient function
data <- data_generator_po_1d(n = 2, beta_type = "gaussian")
#> Error in match.arg(beta_type): 'arg' should be one of “sin”, “exp”, “naive”

# Generate data with higher grid resolution
data <- data_generator_po_1d(n = 2, grid_points = 200)
#> Error in 2 * pi * grid: non-numeric argument to binary operator

# Generate data with larger measurement noise
data <- data_generator_po_1d(n = 2, noise_sd = 0.05)
#> Error in 2 * pi * grid: non-numeric argument to binary operator

# Introduce missing segments in the curves
data <- data_generator_po_1d(n = 2, n_missing = 3, min_distance = 10)
#> Error in 2 * pi * grid: non-numeric argument to binary operator

# Generate data with low R-squared value
data <- data_generator_po_1d(n = 2, rsq = 0.8)
#> Error in 2 * pi * grid: non-numeric argument to binary operator