I have asked this question on SO, but it attracted no response, thus I am
cross- posting it here with the hope that someone would help.
I want to estimate the effect of pm10 and o3 on three outcome(death, cvd
and resp). What I want to do is run one model for each of the main
predictors (pm10 and o3) and each outcome(death, cvd and resp). Thus I
expect to obtain 6 models. The script below works for one outcome (death)
and I wish to use it for more dependent variables.
library(quantmod)
library(mgcv)
library(dlnm)
df <- chicagoNMMAPS
outcomes<- c("death", "cvd", "resp ")
varlist0 <- c("pm10", "o3")
m1 <- lapply(varlist0,function(v) {
f <- sprintf("death~ s(time,bs='cr',k=200)+s(temp,bs='cr') +
Lag(%s,0:6)",v)
gam(as.formula(f),family=quasipoisson,na.action=na.omit,data=df)
})
Thanks
[[alternative HTML version deleted]]