运行 回归时避免不恰当的系数名称

Avoid unseemly coefficient name when running regression

我 运行 使用 map2 函数进行以下回归:

map2(listOfInvVolWeightedOtherStratPortfolioReturns,listOfValueAndMomentumFactorReturns,~lm((.y %>% select(-date) %>% as.matrix()) ~ (.x %>% select(-date) %>% as.matrix())) %>% summary())

reg 输出列表中每个 reg 的系数名称是 .x %>% select(-date) %>% as.matrix():

                                            Estimate
(Intercept)                               0.01244429
.x %>% select(-date) %>% as.matrix()     -0.81570351

当我 运行 回归以避免这种情况时,我如何设置系数的名称,比如说 factor

没有 reprex 这很难,但下面的可读性更强,我相信它应该有效:

myFun <- function(x, y) {
  x <- x %>%
    select(-date) %>%
    as.matrix()
  y <- y %>%
    select(-date) %>%
    as.matrix()
  res <- lm(y ~ x) %>%
    summary()
  return(res)
}
map2(listOfInvVolWeightedOtherStratPortfolioReturns,
     listOfValueAndMomentumFactorReturns,
     myFun)