【问题标题】:RPy boolean values for texregtexreg 的 RPy 布尔值
【发布时间】:2013-11-16 13:09:37
【问题描述】:

我正在使用texreg package 为我的 R 线性模型打印 LaTeX 表格。软件包的默认设置包括打印许多与我的分析无关的内容。幸运的是,该软件包提供了关闭许多功能的开关。

我通过反复试验发现,在 R 中设置为 single.row=TRUE 的东西可以在 RPy 中设置为 single_row=True

正如您在我的 notebook example here 中看到的那样,它适用于 single_row,并且在随后的乳胶打印中,置信区间与我的值打印在同一行。

选项include_loglikinclude_deviance 应该控制是否打印对数似然和偏差。因为我不比较模型,所以我不需要这些。我尝试通过多种不同的方法将它们设置为 false,但它不起作用。

显然,一切都在纯 R 中完美运行:

> texreg(lm, include.deviance=FALSE, include.loglik=FALSE)
Computing profile confidence intervals ...
Computing confidence intervals at a confidence level of 0.95. Use argument "method = 'boot'" for bootstrapped CIs.

\begin{table}
\begin{center}
\begin{tabular}{l c }
\hline
                         & Model 1 \\
\hline
(Intercept)              & $1.85^{*}$       \\
                         & $[1.60;\ 2.10]$  \\
COIem-hard               & $0.54^{*}$       \\
                         & $[0.38;\ 0.69]$  \\
COIsc-10                 & $0.19^{*}$       \\
                         & $[0.03;\ 0.34]$  \\
COIsc-14                 & $-0.04$          \\
                         & $[-0.20;\ 0.11]$ \\
COIsc-18                 & $-0.04$          \\
                         & $[-0.20;\ 0.12]$ \\
COIsc-22                 & $-0.01$          \\
                         & $[-0.16;\ 0.15]$ \\
COIsc-26                 & $-0.13$          \\
                         & $[-0.29;\ 0.02]$ \\
COIsc-6                  & $0.64^{*}$       \\
                         & $[0.48;\ 0.79]$  \\
\hline
AIC                      & 2342.49          \\
BIC                      & 2392.70          \\
Num. obs.                & 1120             \\
Num. groups: ID          & 7                \\
Variance: ID.(Intercept) & 0.08             \\
Variance: Residual       & 0.45             \\
\hline
\multicolumn{2}{l}{\scriptsize{$^*$ 0 outside the confidence interval}}
\end{tabular}
\caption{Statistical models}
\label{table:coefficients}
\end{center}
\end{table}

您能帮我通过RPy 关闭这些开关吗?

【问题讨论】:

    标签: python r rpy2 texreg


    【解决方案1】:

    这是因为这些命名参数没有在 R 函数 texreg::texreg 的签名中定义(这些参数通过省略号 ... 传递),rpy2 无法进行安全的转换尝试。

    我通过反复试验发现,在 R 中设置为 single.row=TRUE 的 thisgs 在 RPy 中可以设置为 single_row=True。

    查阅文档是可以考虑的替代方法。查看: http://rpy.sourceforge.net/rpy2/doc-2.3/html/robjects_functions.html

    【讨论】:

    • 好的,所以这个“落在‘...’中的参数需要将它们的 R 名称传递给构造函数”让我相信这项任务并非不可能。我已经尝试了提议的**{'include.loglik': False},它奏效了!请将此添加到您的帖子中,以便我可以批准它作为我的答案。
    猜你喜欢
    • 2011-04-13
    • 2017-04-08
    • 1970-01-01
    • 2018-01-24
    • 2015-06-17
    • 2011-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多