generate_data: Generate data for simulation

View source: R/Individualized-Dynamic-Latent-Factor-Model.R

generate_dataR Documentation

Generate data for simulation

Description

This function generates simulated data in multiple time series with heterogeneity and non-stationarity. It includes 3 settings in Setion 5.3.

Usage

generate_data(n_patients, n_var, time, idx_x, idx_y, rank, k, N)

Arguments

n_patients

the number of patients

n_var

the number of X variables

time

maximum time

idx_x

indices for the x data, a sparse matrix

idx_y

indices for the y data, a sparse matrix

rank

rank for the random matrices

k

spline smoothness

N

number of knots in the splineS

Value

A list is returned, containing output_x and output_y as sparse matrices of x_data and y_data, spline knots, individualized dynamic latent factor, shared latent factor for X and Y.

References

Zhang, J., F. Xue, Q. Xu, J. Lee, and A. Qu. "Individualized dynamic latent factor model for multi-resolutional data with application to mobile health." Biometrika (2024): asae015.

Examples

library(splines)
#if (!require("BiocManager", quietly = TRUE))
#install.packages("BiocManager")
#BiocManager::install("SparseArray")
library(SparseArray)

I <- 3
J <- 5
time <- 1000
R <- 3
k <- 3
N <- 300
idx_x <- randomSparseArray(c(I, J, time), density=0.8)
idx_y_train <- randomSparseArray(c(I, 1, time), density=0.2)
idx_y_test <- randomSparseArray(c(I, 1, time), density=0.2)
generate_data(I, J, time, idx_x, idx_y_train, R, k, N)

IDLFM documentation built on June 8, 2025, 1 p.m.

Related to generate_data in IDLFM...