sim_outcome {eesim} | R Documentation |
Simulate outcome
Description
Simulates daily outcome counts for each study day based on user specifications
for average outcome count, any underlying trends in expected outcome counts, and
the association between exposure and outcome. This function starts from a vector of
expected outcome count on each study day and simulates through a draw from a Poisson
distribution based on this expected daily value. If desired, a user can also use
a custom function to customize this stage of the simulation; see the vignette for
eesim
for more details and examples.
Usage
sim_outcome(exposure, average_outcome = NULL, trend = "no trend",
slope = 1, amp = 0.6, rr = 1.01, start.date = "2000-01-01",
cust_base_func = NULL, cust_lambda_func = NULL, cust_base_args = list(),
cust_lambda_args = list(), cust_outdraw = NULL,
cust_outdraw_args = list())
Arguments
exposure |
A numeric vector of exposure values, typically the output
of |
average_outcome |
A non-negative numeric value specifying the average daily outcome count. |
trend |
A character string that specifies the desired trend function. Options are:
See the package vignette for examples of the shapes of these trends. |
slope |
A numeric value specifying the slope of the trend, to be used
with |
amp |
A numeric value specifying the amplitude of the seasonal trend. Must be between -1 and 1. |
rr |
A non-negative numeric value specifying the relative risk (i.e., the relative risk per unit increase in the exposure). |
start.date |
A date of the format "yyyy-mm-dd" from which to begin simulating values |
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 |
Value
A dataframe with a simulated time series, with columns for
date
, x
(exposure), and outcome
.
Examples
exp <- sim_exposure(n = 5, central = 100, sd = 10, amp = .6,
exposure_type = "continuous")
sim_outcome(exposure = exp, average_outcome = 22, trend = "linear")