simdata_quantized_emm {qgcompint} | R Documentation |
Simulate quantized exposures for testing methods
Description
Simulate quantized exposures for testing methods
Usage
simdata_quantized_emm(
outcometype = c("continuous", "logistic", "survival"),
n = 100,
corr = NULL,
b0 = 0,
mainterms = c(1, 0, 0, 0),
prodterms = c(1, 0, 0, 0),
ztype = "binary",
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 |
mainterms |
beta coefficients for X in the outcome model at referent (0) level of interacting variable |
prodterms |
product term coefficients for interacting variable |
ztype |
type of interacting variable: "continuous", "binary", "categorical" |
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
set.seed(50)
qdat = simdata_quantized_emm(
outcomtype="continuous",
n=10000, corr=c(.9,.3,0,0), mainterms=c(1,1,0,0), prodterms=c(1,1,0,0),
q = 8
)
cor(qdat)
qdat = simdata_quantized_emm(
outcomtype="continuous",
n=10000, corr=c(-.9,.3,0,0), mainterms=c(1,2,0,0), prodterms=c(1,1,0,0),
q = 4
)
cor(qdat)
table(qdat$x1)
qgcomp.emm.noboot(y~x1+x2+x3+x4,expnms = c("x1", "x2", "x3", "x4"), emmvar = "z", data=qdat)