胶乳产量(R)

cczfrluj  于 2022-12-09  发布在  其他
关注(0)|答案(2)|浏览(126)

我正在使用stargazer包在一个唯一的表中表示一些回归输出,问题是它给了我一个LATEX输出(我在这方面是新手)
为了更好地解释

stargazer(reg_a, reg_b, reg_c,  reg_d, reg_e, align=TRUE)

它会将此作为输出

% Table created by stargazer v.5.2.3 by Marek Hlavac, Social Policy Institute. E-mail: marek.hlavac at gmail.com
% Date and time: ven, mar 17, 2023 - 16:11:49
% Requires LaTeX packages: dcolumn 
\begin{table}[!htbp] \centering 
  \caption{} 
  \label{} 
\begin{tabular}{@{\extracolsep{5pt}}lD{.}{.}{-3} D{.}{.}{-3} D{.}{.}{-3} D{.}{.}{-3} } 
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
 & \multicolumn{4}{c}{\textit{Dependent variable:}} \\ 
\cline{2-5} 
\\[-1.8ex] & \multicolumn{4}{c}{log(tpens)} \\ 
\\[-1.8ex] & \multicolumn{1}{c}{(1)} & \multicolumn{1}{c}{(2)} & \multicolumn{1}{c}{(3)} & \multicolumn{1}{c}{(4)}\\ 
\hline \\[-1.8ex] 
 sex & 0.265^{***} & 0.170^{***} & 0.171^{***} & 0.170^{***} \\ 
  & (0.010) & (0.010) & (0.010) & (0.010) \\ 
  & & & & \\ 
 eta & -0.003^{***} & -0.001 & -0.001^{*} & -0.001^{*} \\ 
  & (0.001) & (0.001) & (0.001) & (0.001) \\ 
  & & & & \\ 
 ireg & -0.008^{***} & -0.006^{***} & -0.005^{***} & -0.005^{***} \\ 
  & (0.001) & (0.001) & (0.001) & (0.001) \\ 
  & & & & \\ 
 studio\_lev2 & 0.129^{***} & 0.115^{***} & 0.114^{***} & 0.114^{***} \\ 
  & (0.014) & (0.013) & (0.013) & (0.013) \\ 
  & & & & \\ 
 studio\_lev3 & 0.422^{***} & 0.406^{***} & 0.403^{***} & 0.404^{***} \\ 
  & (0.022) & (0.021) & (0.021) & (0.021) \\ 
  & & & & \\ 
 type\_jobManager & 0.473^{***} & 0.426^{***} & 0.422^{***} & 0.422^{***} \\ 
  & (0.023) & (0.022) & (0.022) & (0.022) \\ 
  & & & & \\ 
 type\_jobMiddle-class\_worker & 0.204^{***} & 0.170^{***} & 0.166^{***} & 0.166^{***} \\ 
  & (0.014) & (0.014) & (0.014) & (0.014) \\ 
  & & & & \\ 
 type\_jobSelf-Employed & -0.134^{***} & -0.178^{***} & -0.182^{***} & -0.182^{***} \\ 
  & (0.013) & (0.012) & (0.012) & (0.012) \\ 
  & & & & \\ 
 sector & 0.049^{***} & 0.050^{***} & 0.050^{***} & 0.050^{***} \\ 
  & (0.005) & (0.004) & (0.004) & (0.004) \\ 
  & & & & \\ 
 acontrib &  & 0.016^{***} & 0.016^{***} & 0.016^{***} \\ 
  &  & (0.001) & (0.001) & (0.001) \\ 
  & & & & \\ 
 dislav &  &  & -0.088^{***} & -0.089^{***} \\ 
  &  &  & (0.016) & (0.017) \\ 
  & & & & \\ 
 nesplav &  &  &  & 0.003 \\ 
  &  &  &  & (0.009) \\ 
  & & & & \\ 
 Constant & 6.876^{***} & 6.191^{***} & 6.233^{***} & 6.229^{***} \\ 
  & (0.048) & (0.052) & (0.052) & (0.053) \\ 
  & & & & \\ 
\hline \\[-1.8ex] 
Observations & \multicolumn{1}{c}{5,936} & \multicolumn{1}{c}{5,812} & \multicolumn{1}{c}{5,812} & \multicolumn{1}{c}{5,812} \\ 
R$^{2}$ & \multicolumn{1}{c}{0.416} & \multicolumn{1}{c}{0.488} & \multicolumn{1}{c}{0.490} & \multicolumn{1}{c}{0.490} \\ 
Adjusted R$^{2}$ & \multicolumn{1}{c}{0.415} & \multicolumn{1}{c}{0.487} & \multicolumn{1}{c}{0.489} & \multicolumn{1}{c}{0.489} \\ 
Residual Std. Error & \multicolumn{1}{c}{0.321 (df = 5926)} & \multicolumn{1}{c}{0.299 (df = 5801)} & \multicolumn{1}{c}{0.298 (df = 5800)} & \multicolumn{1}{c}{0.298 (df = 5799)} \\ 
F Statistic & \multicolumn{1}{c}{468.804$^{***}$ (df = 9; 5926)} & \multicolumn{1}{c}{552.450$^{***}$ (df = 10; 5801)} & \multicolumn{1}{c}{507.248$^{***}$ (df = 11; 5800)} & \multicolumn{1}{c}{464.915$^{***}$ (df = 12; 5799)} \\ 
\hline 
\hline \\[-1.8ex] 
\textit{Note:}  & \multicolumn{4}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\ 
\end{tabular} 
\end{table}

我已经尝试安装Requires LaTeX packages: dcolumn,但没有任何变化...我仍然会将此代码作为输出
我怎样才能从这段代码中看到表呢?

0h4hbjxa

0h4hbjxa1#

stargazer用latex代码创建了一个表格,所以如果你想看到输出,你可以创建一个Rmarkdown pdf文档,在代码块中包含results = 'asis',下面是一些使用内置datasetattitude的可复制代码:

---
output: pdf_document
---

```{r, results='asis'}
library(stargazer)
stargazer(attitude)

输出:

![](https://i.stack.imgur.com/YqujU.png)
xuo3flqw

xuo3flqw2#

如果问题是如何在控制台上获得文本输出,请使用type = "text"

library(stargazer)
fm <- lm(demand ~ Time, BOD)
stargazer(fm, type = "text")

给出:

===============================================
                        Dependent variable:    
                    ---------------------------
                              demand           
-----------------------------------------------
Time                          1.721*           
                              (0.639)          
                                               
Constant                      8.521**          
                              (2.659)          
                                               
-----------------------------------------------
Observations                     6             
R2                             0.645           
Adjusted R2                    0.556           
Residual Std. Error       3.085 (df = 4)       
F Statistic             7.265* (df = 1; 4)     
===============================================
Note:               *p<0.1; **p<0.05; ***p<0.01

或使用HTML在浏览器中显示:

library(htmltools)
library(stargazer)

fm <- lm(demand ~ Time, BOD)
html_print(HTML(stargazer(fm, type = "html")))

相关问题