Repeat regression with varying dependent variable

后端 未结 3 1622
北海茫月
北海茫月 2021-01-22 17:58

I\'ve searched both Stack and google for a solution, none found to solve my problem.

I have about 40 dependent variables, for which I aim to obtain adjusted means (lsmea

3条回答
  •  情话喂你
    2021-01-22 18:06

    Here is another option using lapply.

    dependents <- c('outcome1', 'outcome2')
    lst <- lapply(dependents, function(x) {
             fit <- lm(paste(x,'~', 'var1+var2+var3'), data=df)
             summary(lsmeans(fit, 'var1', data=df))})
    Map(cbind, lst, outcome = seq_along(dependents))
    

提交回复
热议问题