Re: [R] Loop through columns of outcomes

2013-11-12 Thread Kuma Raj
Very helpful, many thanks. On 12 November 2013 16:09, Rui Barradas wrote: > Hello, > > Once again, use lapply. > > mlist <- lapply(seq_along(m2), function(i) m2[[i]]) > names(mlist) <- paste0("mod", seq_along(mlist)) > > slist <- lapply(mlist, summary) > > > plist <- lapply(slist, `[[`, 'p.table'

Re: [R] Loop through columns of outcomes

2013-11-12 Thread Rui Barradas
Hello, Once again, use lapply. mlist <- lapply(seq_along(m2), function(i) m2[[i]]) names(mlist) <- paste0("mod", seq_along(mlist)) slist <- lapply(mlist, summary) plist <- lapply(slist, `[[`, 'p.table') Hope this helps, Rui Barradas Em 12-11-2013 13:28, Kuma Raj escreveu: Thanks for the s

Re: [R] Loop through columns of outcomes

2013-11-12 Thread Kuma Raj
Thanks for the script which works perfectly. I am interested to do model checking and also interested to extract the coefficients for linear and spline terms. For model checkup I could run this script which will give different plots to test model fit: gam.check(m2[[1]]). Thanks to mnel from SO I co

Re: [R] Loop through columns of outcomes

2013-11-12 Thread Rui Barradas
Hello, Use nested lapply(). Like this: m1 <- lapply(varlist0,function(v) { lapply(outcomes, function(o){ f <- sprintf("%s~ s(time,bs='cr',k=200)+s(temp,bs='cr') + Lag(%s,0:6)", o, v) gam(as.formula(f),family=quasipoisson,na.action=na.omit,data=df) })}) m1 <-

[R] Loop through columns of outcomes

2013-11-12 Thread Kuma Raj
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