sim_outcome: Simulate outcome

Description Usage Arguments Value Examples

View source: R/customizable_functions.R

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

1
2
3
4
5
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 sim_exposure.

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:

  • "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.

slope

A numeric value specifying the slope of the trend, to be used with trend = "linear" or trend = "cos1linear".

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 n and lambda and output a vector of outcome values.

cust_outdraw_args

A list of arguments besides n passed to the user-created custom outcome draw function.

Value

A dataframe with a simulated time series, with columns for date, x (exposure), and outcome.

Examples

1
2
3
exp <- sim_exposure(n = 5, central = 100, sd = 10, amp = .6,
                    exposure_type = "continuous")
sim_outcome(exposure = exp, average_outcome = 22, trend = "linear")

eesim documentation built on June 4, 2017, 1:03 a.m.