Description Usage Arguments Details Value See Also Examples

View source: R/base_simhelpers.R

Simulate quantized exposures for testing methods

1 2 3 4 5 6 7 8 9 10 11 12 13 14 |

`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 |

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

a data frame

`qgcomp.boot`

, and `qgcomp.noboot`

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)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.