50% off | Unlimited Data & AI Learning

Last chance! 50% off unlimited learning

Sale ends in


HEAT (version 1.2)

lagdata: Creating single lagged and moving average variables

Description

Function lagdata creates single lagged and moving average variables of the lag number that the user designate.

Usage

lagdata(data, varlist, laglength)

Arguments

data
Data includes lagged variables.
varlist
List of variables to be lagged.
laglength
Number of lag days.

Value

lagdata gives single lagged variables (varname_sxx, xx indicates lag length) and moving average variables (varname_mxx).

Details

Certain exposure on the previous days has an effect on the event on now day. This effect is referred to as the lagged effects. Studies wanting to estimate lagged effects would include the exposure value for previous days in the time series model, and those wanting to estimate cumulative effect of the same day and the previous days would include the moving average value of the exposure.

References

Dominici F. Time-series analysis of air pollution and mortality: a statistical review. Research report (Health Effects Institute), (123):3, 2004. Gasparrini A and Armstrong B. Time series analysis on the health effects of temperature: advancements and limitations. Environmental research, 110(6):633-638, 2010.

Examples

Run this code
# read the data
data(mort)
seoul = read6city(mort, 11)

# create lagged and moving average variables
seoul_lag = lagdata(seoul, c("meantemp", "mintemp", "meanpm10", "meanhumi"), 5)

Run the code above in your browser using DataLab