简体   繁体   English

观星者-用户提供的系数和SE

[英]stargazer - user supplied coefficients and SE

I am using the stargazer package for regression outputs in R. I have a customized estimation procedure that does not result in a model object but only a vector of coefficients and standard errors. 我正在将stargazer软件包用于R中的回归输出。我有一个自定义的估计过程,该过程不会产生模型对象,而只会产生系数和标准误差的向量。 Is there a way I can supply these to stargazer and get a nicely formatted output table? 有什么办法可以将它们提供给stargazer并获得格式正确的输出表?

Example: 例:

dep.var <- "foo"
regressors <- c("bar", "baz", "xyz")
vec.coeffs <- c(1.2, 2.3, 3.4)
vec.se <- c(0.1, 0.1, 0.3)

Output should look akin to: 输出应类似于:

===============================================
                        Dependent variable:    
                    ---------------------------
                               foo            
-----------------------------------------------
bar                            1.200***                
                              (0.100)          

baz                            2.300***          
                              (0.100)  

xyz                            3.400***          
                              (0.300)         

-----------------------------------------------

Here's one suggestion: the main idea is to make a fake lm object, and then apply custom coefficients, SEs, etc. to the stargazer output: 这是一个建议:主要思想是制作一个假的lm对象,然后将自定义系数,SE等应用到stargazer输出中:

d <- as.data.frame(matrix(rnorm(10 * 4), nc = 4))
names(d) <- c(dep.var, regressors)
f <- as.formula(paste(dep.var, "~ 0 +", paste(regressors, collapse = "+")))
p <- lm(f, d)

stargazer(p, type = "text", 
  coef = list(vec.coeffs),
  se = list(vec.se),
  t = list(vec.coeffs / vec.se),
  omit.stat = "all")
# =================================
#           Dependent variable:    
#       ---------------------------
#                   foo            
# ---------------------------------
# bar            1.200***          
#                 (0.100)          

# baz            2.300***          
#                 (0.100)          

# xyz            3.400***          
#                 (0.300)          

# =================================
# =================================
# Note: *p<0.1; **p<0.05; ***p<0.01

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM