Description Usage Arguments Value References Examples
View source: R/customizable_functions.R
Creates a collection of synthetic datasets that follow a set of user-specified conditions (e.g., exposure mean and variance, average daily outcome count, long-term and seasonal trends in exposure and outcome, association between exposure and outcome). These synthetic datasets can be used to investigate performance of a specific model or to estimate power or required sample size for a hypothetical study.
1 2 3 4 5 6 7 | create_sims(n_reps, n, rr, central, average_outcome, sd = NULL, exposure_type,
exposure_trend, exposure_slope = 1, exposure_amp = NULL,
outcome_trend = NULL, outcome_slope = 1, outcome_amp = NULL,
start.date = "2000-01-01", cust_exp_func = NULL, cust_exp_args = NULL,
cust_expdraw = NULL, cust_expdraw_args = NULL, cust_base_func = NULL,
cust_lambda_func = NULL, cust_base_args = NULL, cust_lambda_args = NULL,
cust_outdraw = NULL, cust_outdraw_args = NULL)
|
n_reps |
An integer specifying the number of datasets to simulate (e.g.,
|
n |
An integer specifying the number of days to simulate (e.g., |
rr |
A non-negative numeric value specifying the relative risk (i.e., the relative risk per unit increase in the exposure). |
central |
A numeric value specifying the mean probability of exposure (for binary data) or the mean exposure value (for continuous data). |
average_outcome |
A non-negative numeric value specifying the average daily outcome count. |
sd |
A non-negative numeric value giving the standard deviation of the exposure values from the exposure trend line (not the total standard deviation of the exposure values). |
exposure_type |
A character string specifying the type of exposure. Choices are "binary" or "continuous". |
exposure_trend |
A character string specifying a seasonal and / or long-term trend for
expected mean exposure. See the vignette for
Options for binary exposure are:
|
exposure_slope |
A numeric value specifying the linear slope of the
exposure, to be used with |
exposure_amp |
A numeric value specifying the amplitude of the exposure trend. Must be between -1 and 1 for continuous exposure or between -0.5 and 0.5 for binary exposure. Positive values will simulate a pattern with higher values at the time of the year of the start of the dataset (typically January) and lowest values six months following that (typically July). Negative values can be used to simulate a trend with lower values at the time of year of the start of the dataset and higher values in the opposite season. |
outcome_trend |
A character string specifying the seasonal trend in health outcomes. Options are the same as for continuous exposure data. |
outcome_slope |
A numeric value specifying the linear slope of the
outcome trend, to be used with |
outcome_amp |
A numeric value specifying the amplitude of the outcome trend. Must be between -1 and 1. |
start.date |
A date of the format "yyyy-mm-dd" from which to begin simulating daily exposures |
cust_exp_func |
An R object name specifying the name of a custom trend function to generate exposure data |
cust_exp_args |
A list of arguments and their values for the user-specified custom exposure function. |
cust_expdraw |
An R object specifying a user-created function
which determines the distribution of random noise off of the trend line.
This function must have inputs |
cust_expdraw_args |
A list of arguments other than |
cust_base_func |
A R object name specifying a user-made custom function for baseline trend. |
cust_lambda_func |
An R object name specifying a user-made custom function for relating baseline, relative risk, and exposure |
cust_base_args |
A list of arguments and their values used in the user-specified custom baseline function |
cust_lambda_args |
A list of arguments and their values used in the user-specified custom lambda function |
cust_outdraw |
An R object name specifying a user-created function to
randomize the outcome values off of the baseline for outcome values. This
function must take inputs |
cust_outdraw_args |
A list of arguments besides |
A list object of length n_rep
, in which each list element is one of the
synthetic datasets simulated under the input conditions. Each synthetic dataset includes
columns for for date (date
), daily exposure (x
), and daily outcome count
(outcome
).
Bateson TF, Schwartz J. 1999. Control for seasonal variation and time trend in case-crossover studies of acute effects of environmental exposures. Epidemiology 10(4):539-544.
1 2 3 4 | create_sims(n_reps=3, n=100, central = 100, sd = 10,
exposure_type="continuous", exposure_trend = "cos1",
exposure_amp = .6, average_outcome = 22,
outcome_trend = "no trend", outcome_amp = .6, rr = 1.01)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.