[英]Using list of LM estimates as stargazer input
I'm trying to use stargazer
over a several LM estimates at once, say "OLS1",...,"OLS5". 我正在尝试一次对几个LM估计值使用
stargazer
,例如“ OLS1”,...,“ OLS5”。 I would usually insert them as separate arguments at the beginning of the stargazer input. 我通常将其作为单独的参数插入到注视者输入的开头。 What I'm looking for is a way to input them all with a list that contains them all, being one argument.
我正在寻找一种通过包含所有参数的列表输入所有参数的方法。 Something like
就像是
stargazer(list,...)
stargazer arguments explanation states that 观星者的论点解释说
one or more model objects (for regression analysis tables) or data frames/vectors/matrices (for summary statistics, or direct output of content).
一个或多个模型对象(用于回归分析表)或数据框/向量/矩阵(用于汇总统计信息或内容的直接输出)。 They can also be included as lists (or even lists within lists).
它们也可以作为列表(甚至列表中的列表)包括在内。
I was wondering what is the correct way to gather LM estimates in a list so that this would work. 我想知道在列表中收集LM估计值的正确方法是什么,这样才能奏效。 When I just save the results in a list I get the following error
当我只将结果保存在列表中时,出现以下错误
Error in list.of.objects[[i]] : subscript out of bounds
I will mention that I create the elements storing the estimate using assign
. 我将提到,我使用
assign
创建了存储估算值的元素。 EG: 例如:
assign(some_string,lm(...))
So what I have is a string, called some_string, and I want to put the LM result names some_string inside a list. 因此,我拥有的是一个名为some_string的字符串,我想将LM结果名称some_string放入列表中。 Using
get
doesn't help with that. 使用
get
并没有帮助。
EDIT: I think you want mget
编辑:我想你想
mget
library(stargazer)
Y <- rnorm(100)
X <- rnorm(100)
assign("string_1", lm(Y ~ X))
assign("string_2", lm(Y ~ X))
my_list <- mget(x = c("string_1", "string_2"))
stargazer(my_list)
works for me? 为我工作?
library(stargazer)
Y <- rnorm(100)
X <- rnorm(100)
fit_1 <- lm(Y ~ X)
fit_2 <- lm(Y ~ X)
stargazer(list(fit_1, fit_2))
did you name your list list
? 您为清单
list
命名了吗? maybe it's grabbing the function? 也许是抢功能?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.