simulate_fps_data: Simulate functional propensity score data

View source: R/simulate_fps.R

simulate_fps_dataR Documentation

Simulate functional propensity score data

Description

Generates a synthetic dataset for testing and illustrating the FPScausal workflow.

Usage

simulate_fps_data(
  n = 200,
  setting = c("LL", "LN", "NL", "NN"),
  outcome_type = c("scalar", "functional"),
  p_scalar = 3,
  include_functional_cov = TRUE,
  domain = c(0, 1),
  seed = NULL
)

Arguments

n

Integer. Number of subjects (default 200).

setting

Character. One of '"LL"', '"LN"', '"NL"', '"NN"', where the first letter controls the treatment-confounder relationship and the second controls the confounder-outcome relationship. Default '"LL"'.

outcome_type

Character. Either '"scalar"' or '"functional"'. Default '"scalar"'.

p_scalar

Integer. Number of scalar confounders. Default 3.

include_functional_cov

Logical. If 'TRUE' (default), include one functional covariate D(t) in the returned list.

domain

Numeric vector c(a, b) giving the time domain of the functional objects. Default c(0, 1), matching the paper's simulation study. Change this to use a different time range (e.g. c(50, 70) for age in years). The 51 evaluation points are always equally spaced within domain.

seed

Integer or NULL. Random seed for reproducibility.

Details

**Treatment** X_i(t) is built from 6 Fourier eigenfunctions with eigenvalues (16, 12, 8, 4, 1, 0.5). **Scalar confounders** C_i are 3-dimensional vectors whose relationship to X's FPC scores is either linear or quadratic. An optional **functional covariate** D_i(t) is generated from 4 Fourier components. The **scalar outcome** is Y_i = 1 + integral(beta(t) * X_i(t)) + g(C_i) + N(0,25), and the **functional outcome** is Y_i(t) = mu0(t) + integral(mu(s,t) * X_i(s) ds) + h(D_i) + GP_error.

The four settings ("LL", "LN", "NL", "NN") vary whether the treatment-confounder ("L"inear / "N"onlinear) and confounder-outcome ("L"inear / "N"onlinear) relationships are linear or quadratic.

Value

A named list with:

X

n x 51 matrix. Observed treatment trajectories on [0,1].

Y

If 'outcome_type = "scalar"': numeric vector of length n. If 'outcome_type = "functional"': n x 51 matrix.

C

n x p_scalar matrix. Scalar confounders.

D

n x 51 matrix. Functional covariate (if 'include_functional_cov = TRUE', else 'NULL').

t_grid

Numeric vector of 51 equally-spaced points on [0,1].

true_beta

True causal effect. For scalar outcome: numeric vector of length 51. For functional outcome: 51 x 51 matrix mu(s,t).

setting

The 'setting' argument used.

outcome_type

The 'outcome_type' argument used.

Examples

dat <- simulate_fps_data(n = 100, setting = "LL", outcome_type = "scalar",
                         seed = 42)
str(dat)


FPScausal documentation built on Aug. 9, 2026, 9:07 a.m.