【发布时间】:2020-04-12 19:24:11
【问题描述】:
我一直在尝试使用 R Markdown 中的 Stargazer 包创建回归表,但我不断收到错误消息:NULL 的长度无法更改。
这是我的回归表代码:
Model_4 <- lm(formula = demsat ~ education + province + age + sex_r + ethnic + emp_status + sat_govt + ptfeel_cons, data = CES2015 )
probit.model <- glm(demsat ~ education + province + age + sex_r + ethnic + emp_status + sat_govt + ptfeel_cons, data = CES2015)
stargazer(Model_1, probit.model, title = "Table of Regression Model 1 to 4", style = "default", type = "latex")
这是它给我的输出,后面是错误消息:
length of NULL cannot be changedlength of NULL cannot be changedlength of NULL cannot be changedlength of NULL cannot be changedlength of NULL cannot be changed
% Table created by stargazer v.5.2.2 by Marek Hlavac, Harvard University. E-mail: hlavac at fas.harvard.edu
% Date and time: Sun, Apr 12, 2020 - 15:54:24
\begin{table}[!htbp] \centering
\caption{Table of Regression Model 1 to 4}
\label{}
\begin{tabular}{@{\extracolsep{5pt}}lcc}
\\[-1.8ex]\hline
\hline \\[-1.8ex]
& \multicolumn{2}{c}{\textit{Dependent variable:}} \\
\cline{2-3}
\\[-1.8ex] & \multicolumn{2}{c}{demsat} \\
\\[-1.8ex] & \textit{OLS} & \textit{normal} \\
\\[-1.8ex] & (1) & (2)\\
\hline \\[-1.8ex]
education & $-$0.014$^{***}$ & $-$0.014$^{***}$ \\
& (0.003) & (0.003) \\
& & \\
province & $-$0.002 & $-$0.002 \\
& (0.002) & (0.002) \\
& & \\
age & 0.00002 & 0.00002 \\
& (0.00002) & (0.00002) \\
& & \\
sex\_r & 0.003 & 0.003 \\
& (0.013) & (0.013) \\
& & \\
ethnic & 0.004$^{***}$ & 0.004$^{***}$ \\
& (0.001) & (0.001) \\
& & \\
emp\_status & 0.006$^{**}$ & 0.006$^{**}$ \\
& (0.003) & (0.003) \\
& & \\
sat\_govt & 0.250$^{***}$ & 0.250$^{***}$ \\
& (0.020) & (0.020) \\
& & \\
ptfeel\_cons & $-$0.012$^{***}$ & $-$0.012$^{***}$ \\
& (0.001) & (0.001) \\
& & \\
Constant & 2.945$^{***}$ & 2.945$^{***}$ \\
& (0.167) & (0.167) \\
& & \\
\hline \\[-1.8ex]
Observations & 3,911 & 3,911 \\
R$^{2}$ & 0.200 & \\
Adjusted R$^{2}$ & 0.199 & \\
Log Likelihood & & $-$7,464.311 \\
Akaike Inf. Crit. & & 14,946.620 \\
Residual Std. Error & 1.633 (df = 3902) & \\
F Statistic & 122.238$^{***}$ (df = 8; 3902) & \\
\hline
\hline \\[-1.8ex]
\textit{Note:} & \multicolumn{2}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\
\end{tabular}
\end{table}
这个错误是什么意思?我怎样才能让我的回归表出现?
谢谢。
【问题讨论】:
-
我已将其更新为实际代码
-
您已经向我们展示了创建
Model_4的代码,但您将Model_1传递给stargazer()。
标签: r-markdown linear-regression stargazer