efficient looping logistic regression in R

后端 未结 1 2034
予麋鹿
予麋鹿 2021-01-06 17:53

I\'m trying to run multiple logistic regression analyses for each of ~400k predictor variables. I would like to capture the outputs of each run into a row/column of an outpu

相关标签:
1条回答
  • 2021-01-06 18:12

    It will be faster if you use apply instead of a for loop:

    t(apply(mydatamatrix, 2,
            function(x)
              coef(summary(glm(mydataframe$O1 ~ x + as.factor(mydataframe$P2), 
                               family=binomial)))[2, 1:4]))
    
    0 讨论(0)
提交回复
热议问题