continuous_exposure: Simulate continuous exposure data

Description Usage Arguments Value Examples

View source: R/sim_exposure.R

Description

Simulates a time series of continuous exposure values with or without a seasonal and / or long-term trend.

Usage

1
2
3
continuous_exposure(n, mu, sd = 1, trend = "no trend", slope, amp = 0.6,
  cust_expdraw = NULL, cust_expdraw_args = list(),
  start.date = "2000-01-01", ...)

Arguments

n

A non-negative integer specifying the number of days to simulate.

mu

A numeric value giving the mean exposure across all study days.

sd

A numeric value giving the standard deviation of the exposure values from the exposure trend line.

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.

cust_expdraw

A character string specifying a user-created function which determines the distribution of random noise off of the trend line. This function must have inputs "n" and "mean" and output a vector of simulated exposure values.

cust_expdraw_args

A list of arguments other than "n" and "mean" required by the cust_expdraw function.

start.date

A date of the format "yyyy-mm-dd" from which to begin simulating daily exposures

...

Optional arguments to a custom trend function

Value

A data frame with the dates and simulated daily exposure values from n days.

Examples

1
2
3
continuous_exposure(n = 5, mu = 100, sd = 10, trend = "cos1")
continuous_exposure(n=10, mu=3, trend="linear", slope = 2,
                    cust_expdraw=rnorm, cust_expdraw_args = list(sd=.5))

eesim documentation built on May 2, 2019, 7:30 a.m.