Dear all, 
  I am having difficulties using the seemingly-simple function lag. 
  I have a dataframe with several weather variables (maxitemp,
windspeed, rainfall etc), and the response variable (admissions). The
dataset is fairly large (1530 observations). I simply want to model the
response against a lag of a couple of the explanatory variables, say
maxitemp and rainfall. I would like to look at lagtimes of 4 days, i.e.
4 observations. My dataframe is called allengland. 
  I thought I would be able to do something like:
model1 <- lm(admissions~lag(maxitemp,4),data=allengland) 
  but when I compare this to a lag of 0 I have exactly the same output,
so I am clearly doing something wrong. 
  Could someone please point me in the right direction? The example in
the help for lag is not very detailed for what I need to do.
Thanks in advance,   

Robin Williams
Met Office summer intern - Health Forecasting
robin.williams@metoffice.gov.uk 

 

	[[alternative HTML version deleted]]

