Stargazer()不适合页面

时间:2017-05-18 10:53:26

标签: r latex stargazer

下午好,我试图找到这个问题的答案,尽管没有任何信息。关键是我想把模型的输出(3个模型)放在latex文件中。虽然,当我使用stargazer()做这样的事情时,它会导致2个问题 - 首先,当我想要显示3个模型或更多时,结果表格不适合页面,特别是 - 到目前为止向右,第二,当我有很多变量时,它也不适合页面,所以很多变量都没有显示出来。怎么处理呢?

 \usepackage{dcolumn} 
 \begin{table}[!htbp] \centering 
 \caption{Results} 
  \label{} 
\begin{tabular}{@{\extracolsep{5pt}}lD{.}{.}{-3} D{.}{.}{-3} } 
  \\[-1.8ex]\hline 
 \hline \\[-1.8ex] 
  & \multicolumn{2}{c}{\textit{Dependent variable:}} \\ 
\cline{2-3} 
\\[-1.8ex] & \multicolumn{2}{c}{log(Price)} \\ 
\\[-1.8ex] & \multicolumn{1}{c}{\textit{OLS}} & \multicolumn{1}{c}
 {\textit{panel}} \\ 
 & \multicolumn{1}{c}{\textit{}} & \multicolumn{1}{c}{\textit{linear}} 
 \\ 
 \\[-1.8ex] & \multicolumn{1}{c}{(1)} & \multicolumn{1}{c}{(2)}\\ 
 \hline \\[-1.8ex] 
 Coll & 0.513^{***} & 0.019 \\ 
 & (0.028) & (0.039) \\ 
 & & \\ 
 Constant & 0.110^{***} &  \\ 
 & (0.038) &  \\ 
 & & \\ 
 \hline \\[-1.8ex] 
 Observations & \multicolumn{1}{c}{14,727} & \multicolumn{1}{c}{14,727} \\ 
  R$^{2}$ & \multicolumn{1}{c}{0.256} & \multicolumn{1}{c}{0.011} \\ 
  Adjusted R$^{2}$ & \multicolumn{1}{c}{0.255} & \multicolumn{1}{c}{-0.341} \\ 
  Residual Std. Error & \multicolumn{1}{c}{0.297 (df = 14699)} &  \\ 
  F Statistic & \multicolumn{1}{c}{187.710$^{***}$ (df = 27; 14699)} & 
  \multicolumn{1}{c}{14.477$^{***}$ (df = 8; 10868)} \\ 
  \hline 
  \hline \\[-1.8ex] 
  \textit{Note:}  & \multicolumn{2}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; 
  $^{***}$p$<$0.01} \\ 
  \end{tabular} 
  \end{table} 

这里我基本上只提供了一个样本,只有2个变量较少的模型(只是为了方便),但是,当我使用它们时,它不适合页面。

1 个答案:

答案 0 :(得分:3)

尝试将tabular部分包裹在scalebox内。所以它会是这样的:

 \begin{table}[!htbp] \centering 
 \caption{Results} 
  \label{} 
\scalebox{0.85}{
\begin{tabular}{@{\extracolsep{5pt}}lD{.}{.}{-3} D{.}{.}{-3} } 
  \\[-1.8ex]\hline 
 \hline \\[-1.8ex] 
  & \multicolumn{2}{c}{\textit{Dependent variable:}} \\ 
\cline{2-3} 
\\[-1.8ex] & \multicolumn{2}{c}{log(Price)} \\ 
\\[-1.8ex] & \multicolumn{1}{c}{\textit{OLS}} & \multicolumn{1}{c}
 {\textit{panel}} \\ 
 & \multicolumn{1}{c}{\textit{}} & \multicolumn{1}{c}{\textit{linear}} 
 \\ 
 \\[-1.8ex] & \multicolumn{1}{c}{(1)} & \multicolumn{1}{c}{(2)}\\ 
 \hline \\[-1.8ex] 
 Coll & 0.513^{***} & 0.019 \\ 
 & (0.028) & (0.039) \\ 
 & & \\ 
 Constant & 0.110^{***} &  \\ 
 & (0.038) &  \\ 
 & & \\ 
 \hline \\[-1.8ex] 
 Observations & \multicolumn{1}{c}{14,727} & \multicolumn{1}{c}{14,727} \\ 
  R$^{2}$ & \multicolumn{1}{c}{0.256} & \multicolumn{1}{c}{0.011} \\ 
  Adjusted R$^{2}$ & \multicolumn{1}{c}{0.255} & \multicolumn{1}{c}{-0.341} \\ 
  Residual Std. Error & \multicolumn{1}{c}{0.297 (df = 14699)} &  \\ 
  F Statistic & \multicolumn{1}{c}{187.710$^{***}$ (df = 27; 14699)} & 
  \multicolumn{1}{c}{14.477$^{***}$ (df = 8; 10868)} \\ 
  \hline 
  \hline \\[-1.8ex] 
  \textit{Note:}  & \multicolumn{2}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; 
  $^{***}$p$<$0.01} \\ 
  \end{tabular} 
}
  \end{table} 

我将比例设置为0.85,但你可以玩它。如果打印件太小并且表格仍然不合适,请尝试使用longtable包,以便将表格分布在多个页面上。