sim_data {dlim}R Documentation

Simulate Data

Description

Simulate data to use with the dlim package. There are different effect modification scenarios to choose for simulation.

Usage

sim_data(
  x,
  L = NULL,
  modifiers,
  noise = 1,
  type = 2,
  SNR,
  ncovariates = 0,
  gamma = 1
)

Arguments

x

a time series vector of length n or matrix of lagged exposures for n individuals (class "numeric", "matrix")

L

a vector of length 1 containing the number of lag terms. This is required if x is vector, and is not used if x is a matrix (class "numeric")

modifiers

vector of length n containing modifying values (class "numeric")

noise

a vector of length 1 containing the standard deviation for a normal distribution with mean 0 used to add noise to the simulated response values. Must proivde if SNR is not provided (class "numeric")

type

a vector containing the number 1, 2, 3, or 4 for simulation modification type: none, linear, non-linear shift, non-linear shift with linear scale (class "numeric")

SNR

The signal-to-noise ratio. If SNR is provided, but noise is not, noise is reset to be the standard deviation of the response, before adding noise. (class "numeric")

ncovariates

number of covariates to add to the model, numeric vector of length 1.

gamma

True coefficient for the main effect of the modifier (class "numeric")

Value

This returns a list of 8 items:

x

a lagged exposure matrix. If x was a matrix, it is unchanged. (class "matrix")

L

a numeric vector of length 1 containing the number of lag terms (class "numeric")

modifiers

the modifiers argument (class "numeric")

y

a numeric vector of length nrow(x) containing the perturbed simulated response values. (class "numeric")

betas

a matrix containing true coefficients for each lag/modifier combination, with each row representing a lag and each column a modifier (class "matrix")

betas_cumul

a numeric vector of length L+1 containing cumulative true coefficients for the lag terms, summed over modifiers (class "numeric")

Z

covariates (class "matrix")

gammas

true coefficients for the covariates (class "numeric")

See Also

sim_dlim

Type vignette('dlimOverview') for a detailed description.


[Package dlim version 0.1.0 Index]