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.
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())A numeric vector of exposure values, typically the output
of sim_exposure.
A non-negative numeric value specifying the average daily outcome count.
A character string that specifies the desired trend function. Options are:
"no trend": No trend, either seasonal or long-term (default).
"cos1": A seasonal trend only.
"cos2": A seasonal trend with variable amplitude across years.
"cos3": A seasonal trend with steadily decreasing amplitude over time.
"linear": A linear long-term trend with no seasonal trend.
"curvilinear": A curved long-term trend with no seasonal trend.
"cos1linear": A seasonal trend plus a linear long-term trend.
See the package vignette for examples of the shapes of these trends.
A numeric value specifying the slope of the trend, to be used
with trend = "linear" or trend = "cos1linear".
A numeric value specifying the amplitude of the seasonal trend. Must be between -1 and 1.
A non-negative numeric value specifying the relative risk (i.e., the relative risk per unit increase in the exposure).
A date of the format "yyyy-mm-dd" from which to begin simulating values
A R object name specifying a user-made custom function for baseline trend.
An R object name specifying a user-made custom function for relating baseline, relative risk, and exposure
A list of arguments and their values used in the user-specified custom baseline function
A list of arguments and their values used in the user-specified custom lambda function
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 n and lambda and output a vector of outcome
values.
A list of arguments besides n passed
to the user-created custom outcome draw function.
A dataframe with a simulated time series, with columns for
date, x (exposure), and outcome.
exp <- sim_exposure(n = 5, central = 100, sd = 10, amp = .6,
exposure_type = "continuous")
sim_outcome(exposure = exp, average_outcome = 22, trend = "linear")
Run the code above in your browser using DataLab