我正在从 R 中可用的 ei.MD.bayes(作为 eiPack 的一部分)生成生态推断估计值。我想操纵细胞计数估计值(即平均值、标准误差、2.5% 和 97.5%)以便打印它们在使用 stargazer 的表中。我已经解决了这个问题,但现在面临的问题是我有两个对象(一个具有平均值和标准误差,另一个具有 2.5% 和 97.5% 的信息。)它们具有相同的变量(即行名称),但观星者将它们打印在两个不同的表中。
下面是我正在使用的 stargazer 命令的示例以及它产生的输出。您会注意到两个表中的行名称相同,但 stargazer 想要在两个不同的表中打印两个对象。我想要一张表中的所有四列('Mean'、'SD'、'2.5%'、'97.5%')。
library(foreign)
library(stargazer)
library(coda)
library(eiPack)
tune.nocov <- tuneMD(cbind(ndc, npp, thirdparty, reject, novote12) ~ cbind(agona, ahafo, ahanta, akuapem, akwamu), data = STATA, ntunes = 10, totaldraws = 10000)
out.nocov <- ei.MD.bayes(cbind(ndc, npp, thirdparty, reject, novote12) ~ cbind(agona, ahafo, ahanta, akuapem, akwamu), covariate = NULL, data = STATA, tune.list = tune.nocov, ret.mcmc = TRUE, ret.beta = 'd')
summary <- summary(out.nocov)
names(summary)
[1] "draws" "acc.ratios" "call" "short"
try1 <- summary[['draws']]
names(try1)
[1] "Alpha" "Beta" "Cell.counts"
cell.counts <- summary(draws$Cell.counts)
names(cell.counts)
[1] "statistics" "quantiles" "start" "end" "thin"
[6] "nchain"
stargazer(cell.counts$statistics, cell.counts$quantiles
, omit = c('Naive SE' , 'Time-series SE', '25%', '50%', '75%'),
summary = FALSE)
\begin{table}[!htbp] \centering
\caption{}
\label{}
\begin{tabular}{@{\extracolsep{5pt}} ccccc}
\\[-1.8ex]\hline
\hline \\[-1.8ex]
& Mean & SD \\
\hline \\[-1.8ex]
ccount.agona.ndc & $18,277.450$ & $1,330.555$ \\
ccount.ahafo.ndc & $22,831.210$ & $1,473.978$ \\
ccount.ahanta.ndc & $35,175.080$ & $1,543.445$ \\
ccount.akuapem.ndc & $146,127.300$ & $4,245.508$ \\
ccount.akwamu.ndc & $4,075.178$ & $745.696$ \\
\hline \\[-1.8ex]
\end{tabular}
\end{table}
\begin{table}[!htbp] \centering
\caption{}
\label{}
\begin{tabular}{@{\extracolsep{5pt}} cccccc}
\\[-1.8ex]\hline
\hline \\[-1.8ex]
& 2.5\% & 97.5\% \\
\hline \\[-1.8ex]
ccount.agona.ndc & $15,884.210$ & $20,678.420$ \\
ccount.ahafo.ndc & $20,296.790$ & $25,612.700$ \\
ccount.ahanta.ndc & $32,282.440$ & $37,814.850$ \\
ccount.akuapem.ndc & $137,438.300$ & $154,081.700$ \\
ccount.akwamu.ndc & $2,873.071$ & $5,689.897$ \\
\hline \\[-1.8ex]
\end{tabular}
\end{table}