Friday, May 31, 2013

Loop over all columns for exploratory regression analysis in R



### all possible regression analysis for a given column
pTb = 1: length(tb[1,])
names(pTb) = names(tb)
 for( j in c(2:15,17:34) ) {
   m = lm( tb[, j] ~ tb$Cv.vs.Cb)
   sm = summary(m)
   pTb[j] = 1 - pf(sm$fsta[1], sm$fsta[2], sm$fsta[3])
 }
 pTb[pTb<0.05]


pTb[pTb<0.05]
         ARLS          Lmax        L0.all     CLS.vs.Tc      Cv.vs.Cb      Cb.vs.Cv 
 3.546097e-02  3.877701e-02  3.137392e-02  4.748623e-02  0.000000e+00  7.306331e-05 
Cb.vs.Cv.mean 
 5.729385e-04 

No comments:

Post a Comment