simdata_quantized: Simulate quantized exposures for testing methods

Description Usage Arguments Details Value See Also Examples

View source: R/base_simhelpers.R

Description

Simulate quantized exposures for testing methods

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
simdata_quantized(
  outcometype = c("continuous", "logistic", "survival"),
  n = 100,
  corr = NULL,
  b0 = 0,
  coef = c(1, 0, 0, 0),
  q = 4,
  yscale = 1,
  shape0 = 3,
  scale0 = 5,
  censtime = 4,
  ncheck = TRUE,
  ...
)

Arguments

outcometype

Character variable that is one of c("continuous", "logistic", "survival"). Selects what type of outcome should be simulated (or how). continuous = normal, continous outcome, logistic= binary outcome from logistic model, survival = right censored survival outcome from Weibull model.

n

Sample size

corr

NULL, or vector of correlations between the first exposure and subsequent exposures (if length(corr) < (length(coef)-1), then this will be backfilled with zeros)

b0

(continuous, binary outcomes) model intercept

coef

Vector of coefficients for the outcome (i.e. model coefficients for exposures). The length of this determines the number of exposures.

q

Number of levels or "quanta" of each exposure

yscale

(continuous outcomes) error scale (residual error) for normally distributed outcomes

shape0

(survival outcomes) baseline shape of weibull distribution rweibull

scale0

(survival outcomes) baseline scale of weibull distribution rweibull

censtime

(survival outcomes) administrative censoring time

ncheck

(logical, default=TRUE) adjust sample size if needed so that exposures are exactly evenly distributed (so that qgcomp::quantize(exposure) = exposure)

...

unused

Details

Simulate continuous (normally distributed errors), binary (logistic function), or event-time outcomes as a linear function

Value

a data frame

See Also

qgcomp.boot, and qgcomp.noboot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
set.seed(50)
qdat = simdata_quantized(
  outcomtype="continuous", 
  n=10000, corr=c(.9,.3), coef=c(1,1,0,0), 
  q = 8
)
cor(qdat)
qdat = simdata_quantized(
  outcomtype="continuous", 
  n=10000, corr=c(-.9,.3), coef=c(1,2,0,0), 
  q = 4
)
cor(qdat)
table(qdat$x1)
qgcomp.noboot(y~.,data=qdat)

qgcomp documentation built on Jan. 24, 2022, 5:08 p.m.