微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

即使受支持,Stargazer 也无法识别 tobit

如何解决即使受支持,Stargazer 也无法识别 tobit

我想让 stargazer 打印一个 AER::tobit 回归(底部的数据)。

require(AER)
require(stargazer)
s1.tobit <- AER::tobit(taxrate ~ Votewon + industry + size + urbanisation + Vote,left=12,right=33,data=DF)
stargazer(s1.tobit)

% Error: Unrecognized object type.

根据小插图,这应该没问题:https://cran.r-project.org/web/packages/stargazer/vignettes/stargazer.pdf

enter image description here

有人可以帮我解决正在发生的事情吗?

数据

DF <- structure(list(country = c("C","C","J","B","F","E","D","I","H","G","A","F"),year = c(2005,2010,2005,2005),sales = c(15.48,12.39,3.72,23.61,4,31.87,25.33,7.64,-0.26,2.9,15.48,2.9),industry = c("D",urbanisation = c("B","B"),size = c(1,1,5,2,3,5),base_rate = c(14L,14L,19L,30L,20L,29L,24L,17L,33L,23L,20L),taxrate = c(12L,12L,21L,18L,32L,22L,25L,Vote = c(0,1),Votewon = c(0,1)),class = "data.frame",row.names = c(NA,-100L))

## convert variables to factors beforehand
DF[c(1,6,9,10)] <- lapply(DF[c(1,10)],factor)

解决方法

使用 stargazer v5.2.2 和 AER v1.2-9 只有当您将 AER:: 放在 tobit 前面时才有效,这很奇怪。也许您应该编写错误报告,但我强烈建议您使用 texreg 而不是 stargazer

require(AER)
require(stargazer)
m1.tobit <- AER::tobit(taxrate ~ votewon + industry + size + urbanisation + vote,left=12,right=33,data=DF)
> stargazer(m1.tobit)

% Error: Unrecognized object type.

m2.tobit <- tobit(taxrate ~ votewon + industry + size + urbanisation + vote,data=DF)
> stargazer(m2.tobit)

% Table created by stargazer v.5.2.2 by Marek Hlavac,Harvard University. E-mail: hlavac at fas.harvard.edu
% Date and time: Sat,Jan 16,2021 - 20:13:07
\begin{table}[!htbp] \centering 
  \caption{} 
  \label{} 
\begin{tabular}{@{\extracolsep{5pt}}lc} 
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
 & \multicolumn{1}{c}{\textit{Dependent variable:}} \\ 
\cline{2-2} 
\\[-1.8ex] & taxrate \\ 
\hline \\[-1.8ex] 
 votewon & $-$1.593 \\ 
  & (1.558) \\ 
  & \\ 
 industryE & $-$0.787 \\ 
  & (1.446) \\ 
  & \\ 
 industryF & $-$2.861$^{*}$ \\ 
  & (1.515) \\ 
  & \\ 
 size & $-$0.552 \\ 
  & (0.447) \\ 
  & \\ 
 urbanisationB & $-$1.703 \\ 
  & (1.525) \\ 
  & \\ 
 urbanisationC & $-$3.097$^{*}$ \\ 
  & (1.689) \\ 
  & \\ 
 vote & 4.176$^{***}$ \\ 
  & (1.615) \\ 
  & \\ 
 Constant & 25.257$^{***}$ \\ 
  & (1.934) \\ 
  & \\ 
\hline \\[-1.8ex] 
Observations & 100 \\ 
Log Likelihood & $-$299.532 \\ 
Wald Test & 13.061$^{*}$ (df = 7) \\ 
\hline 
\hline \\[-1.8ex] 
\textit{Note:}  & \multicolumn{1}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\ 
\end{tabular} 
\end{table} 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。