Last data update: 2014.03.03

R: Creating single lagged and moving average variables
lagdataR Documentation

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.

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.

Value

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

Author(s)

Youn-Hee Lim, Il-Sang Ohn, and Ho Kim

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

# 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)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(HEAT)
Loading required package: splines
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/HEAT/lagdata.Rd_%03d_medium.png", width=480, height=480)
> ### Name: lagdata
> ### Title: Creating single lagged and moving average variables
> ### Aliases: lagdata
> 
> ### ** Examples
> 
> # 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)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>