SimDifferentialConfounding: Simulating data with differential confounding.

Description Usage Arguments Examples

Description

Generate data with different variables are confounders of the exposure- response relationship at different exposure levels.

Usage

1
2
3
4
5
SimDifferentialConfounding(N, num_exper, XCcorr, varC, Xrange,
  exper_change = NULL, meanCexp1 = NULL, out_coef, interYexp1 = 0,
  bYX, Ysd = 1, overall_meanC = c("true", "observed"),
  XY_function = c("linear", "other"), XY_spec = NULL,
  center_covs = TRUE)

Arguments

N

Sample size.

num_exper

Number of experiments.

XCcorr

A matrix of 2 dimensions. Element ij corresponds to the correlation of variable Ci with exposure X in experiment j.

varC

A vector of length equal to the number of covariates, describing the variance of each of the C. We assume constant variance of C across experiments.

Xrange

Vector of length 2. These values correspond to the minimum and the maximum of the uniform distribution from which X is generated.

meanCexp1

A vector of length equal to the number of covariates including the marginal mean of each covariate in experiment 1. The mean of the covariates in the rest experiments is specified by the algorithm such that E(C|X=x) is continuous in x. If equal to NULL, 0 will be specified for all variables.

out_coef

A matrix of two dimensions. Element ij describes the coefficient of Ci in the outcome model of experiment j.

interYexp1

The intercept of the outcome model in experiment 1. The remaining intercepts are set such that the function E[Y | X = x] is continuous in x.

bYX

If XY_function is set to linear, bYX includes the coefficient of the exposure within each experiment and is of length num_exper. If XY_function is set to other, bYX is of length 1 and corresponds to the coefficient in front of the exposure term.

Ysd

A vector including the residual variance of the outcome model in each experiment. Defaults to 1.

overall_meanC

A string equal to 'true' or 'observed'. Defaults to 'true'. This argument controls whether we will use the analytical or the observed mean of C to ensure continuous ER at the points of the experiment configuration. If set to 'true', individual simulated data sets do not necessarily have a continuous ER, but they do in general. If set equal to the 'observed', each simulated data set has a continuous ER, that might be slightly different for every dataset. Both choices average to the same true ER, for a large sample size, or number of replicated data sets.

XY_function

String specifying whether the XY relationship is piece- wise linear (set 'linear'), or a continuous function supplied by the XY_spec arguement (set 'other').

XY_spec

Needs to be specified if XY_function is set to 'other'. It is the function that specifies the true ER relationship. Defaults to NULL.

center_covs

Logical. Whether the potential confounders should be centered before generating the outcome. Defaults to TRUE.

exper_range

The points of the exposure range Xrange at which differential confounding might occur.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
XCcorr <- matrix(c(0.4, 0.2, 0.2, 0), 2, 2)
out_coef <- matrix(c(0.2, 0.3, 0, 0.4), 2, 2)
bYX <- c(0, 0, 1, 2, 3)
sim <- SimDifferentialConfounding(N = 1000, num_exper = 2, XCcorr = XCcorr,
                                  varC = c(1, 1), Xrange = c(0, 10),
                                  exper_change = c(0, 4, 10),
                                  out_coef = out_coef, bYX = bYX)
f <- function(x) {
  return(x ^ 2)
}
sim <- SimDifferentialConfounding(N = 1000, num_exper = 2, XCcorr = XCcorr,
                                  varC = c(1, 1), Xrange = c(0, 10),
                                  exper_change = c(0, 4, 10),
                                  out_coef = out_coef, bYX = bYX,
                                  XY_function = 'other', XY_spec = f)

gpapadog/LERCA documentation built on June 4, 2019, 11:40 a.m.