Reputation: 39
I run the following regressions using the map2
function:
map2(listOfInvVolWeightedOtherStratPortfolioReturns,listOfValueAndMomentumFactorReturns,~lm((.y %>% select(-date) %>% as.matrix()) ~ (.x %>% select(-date) %>% as.matrix())) %>% summary())
The coefficient name for each reg in the list of reg outputs is .x %>% select(-date) %>% as.matrix()
:
Estimate
(Intercept) 0.01244429
.x %>% select(-date) %>% as.matrix() -0.81570351
How can I set the name of the coefficients, lets say to factor
, when I run the regressions to avoid this?
Upvotes: 1
Views: 50
Reputation: 685
Without a reprex this is tough but the following is more readable and I believe it should work:
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)
Upvotes: 1