【问题标题】:R markdown "texreg"R降价“texreg”
【发布时间】:2014-09-11 04:33:32
【问题描述】:

我想通过使用以下 cmets 获得回归结果的乳胶表;

Analysis1 <- glm(y~x, data=data1, family=quasibinomial(link="logit"))    
summary(Analysis1)
texreg(list(Analysis1),dcolumn = TRUE, booktabs = TRUE,
       use.packages = TRUE, label = "tab:1", 
       caption = "Regression Estimation Results",float.pos = "hb")

然而,这个“texreg”命令给出的是原始输出而不是干净的表;

\begin{table}[ht]
\centering
\begin{tabular}{rrrrr}
  \hline
 & Estimate & Std. Error & t value & Pr($>$$|$t$|$) \\ 
  \hline
(Intercept) & 0.7686 & 0.0125 & 61.37 & 0.0000 \\ 
  x & -0.0166 & 0.0069 & -2.41 & 0.0170 \\ 
   \hline
\end{tabular}
\end{table}

您能帮我如何在 R 中使用 texreg 命令获得干净的回归结果表吗?

【问题讨论】:

    标签: r texreg


    【解决方案1】:

    您没有提供一个最小的独立示例。但是,如果我使用glm 帮助页面上提供的示例,它似乎确实有效。请看以下结果。

    library("texreg")  # tested with version 1.33.2
    
    counts <- c(18,17,15,20,10,20,25,13,12)
    outcome <- gl(3,1,9)
    treatment <- gl(3,3)
    Analysis1 <- glm(counts ~ outcome + treatment, family = poisson())
    
    texreg(Analysis1, dcolumn = TRUE, booktabs = TRUE,
        use.packages = TRUE, label = "tab:1", 
        caption = "Regression Estimation Results", float.pos = "hb")
    

    这给出了以下输出,我相信这是正确的。

    \usepackage{booktabs}
    \usepackage{dcolumn}
    
    \begin{table}[hb]
    \begin{center}
    \begin{tabular}{l D{.}{.}{3.5}@{} }
    \toprule
                   & \multicolumn{1}{c}{Model 1} \\
    \midrule
    (Intercept)    & 3.04^{***} \\
                   & (0.17)     \\
    outcome2       & -0.45^{*}  \\
                   & (0.20)     \\
    outcome3       & -0.29      \\
                   & (0.19)     \\
    treatment2     & 0.00       \\
                   & (0.20)     \\
    treatment3     & 0.00       \\
                   & (0.20)     \\
    \midrule
    AIC            & 56.76      \\
    BIC            & 57.75      \\
    Log Likelihood & -23.38     \\
    Deviance       & 5.13       \\
    Num. obs.      & 9          \\
    \bottomrule
    \multicolumn{2}{l}{\scriptsize{$^{***}p<0.001$, $^{**}p<0.01$, $^*p<0.05$}}
    \end{tabular}
    \caption{Regression Estimation Results}
    \label{tab:1}
    \end{center}
    \end{table}
    

    如果您使用相同的代码得到不同的输出,请报告您使用的是哪个texreg 版本。如果您使用相同的版本,但您自己的示例产生的结果看起来不同,请提供一个最小的独立示例。

    【讨论】:

      猜你喜欢
      • 2019-03-25
      • 2015-10-27
      • 2021-10-05
      • 1970-01-01
      • 1970-01-01
      • 2016-07-25
      • 2012-08-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多