在做回归分析时,我注意到了一些非常奇怪的事情.基本上,当我独立地估计一个回归和purrr::map
函数中的同一个回归并提取元素时,我得到这两个对象是不相同的.我的问题是为什么会这样,或者是否应该这样.
我问这个问题的主要原因是,有些软件包在从purrr::map
个估算中提取信息时遇到问题,但在我单独估算时却没有.下面是一个小例子,其中包含一些无意义的回归:
library(fixest)
library(tidyverse)
## creating a formula for a regression example
formula <- as.formula(paste0(
"mpg", "~",
paste("cyl", collapse = "+"),
paste("|"), paste(c("gear", "carb"), collapse = "+")))
## estimating the regression and saying
mtcars_formula <- feols(formula, cluster = "gear", data = mtcars)
## estimating the same regression twice, but using map
mtcars_list_map <- map(list("gear", "gear"), ~ feols(formula, cluster = ., data = mtcars))
## extracting the first element of the list
is_identical_1 <- mtcars_list_map %>%
pluck(1)
## THESE ARE NOT IDENTIAL
identical(mtcars_formula, is_identical_1)
我也用fixest
个包裹来标记这个,只是因为这可能是特定于包裹的...