2014-09-11 85 views
1

我想通过使用以下注释得到回归结果的乳胶表;R markdown“texreg”

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命令获得干净的回归结果表吗?

回答

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版本所使用。如果您使用的是相同的版本,但您自己的示例会产生看起来不同的结果,请提供一个最小的自包含示例。