如何将这些表格与添加“样本大小”结合起来?

如何将这些表格与添加“样本大小”结合起来?

我有两个表格,如何才能像图中这样合并呢?我只需要在我的“绩效衡量”表格前面添加一列“样本量”,然后我的两个表格就对应不同的样本量了。

这是我的两个表的代码:

\begin{table}[h!]
\centering
\begin{tabular}{|c|c c |c c|}\hline
\multirow{2}{*}{\parbox{6em}{\centering Performance}} & \multicolumn{2}{c|}{ML}  &  \multicolumn{2}{c|}{M}   \\\cline{2-5}
       & $\hat{\mu}$ & $\sigma$ & $\hat{\mu}$ & $\hat{\sigma}$ \\\hline
  $\widehat{\text{MSE}}$ & $0.117$ & $64$ & $\underset{(0.009)}{0.121}$ & $\underset{(0.006)}{0.094}$ \\ $\widehat{\text{Bias}}$ & $\underset{(0.015)}{ 0.041}$ & $\underset{67}$   & $\underset{57}$   & $\underset{83}$ \\
$\widehat{\text{SD}}$ & $\underset{340}$   & $\underset{44}$   & $3$  & $95$ \\
\hline
\end{tabular}
\caption{Estimates}
\label{5}
\end{table}
\begin{table}[h!]
\centering
\begin{tabular}{|c|c c |c c|}\hline
\multirow{2}{*}{\parbox{6em}{\centering Performance}} & \multicolumn{2}{c|}{ML}  &  \multicolumn{2}{c|}{M}   \\\cline{2-5}
       & $\hat{\mu}$ & $\sigma$ & $\hat{\mu}$ & $\hat{\sigma}$ \\\hline
  $\widehat{\text{MSE}}$ & $0.117$ & $64$ & $\underset{(0.009)}{0.121}$ & $\underset{(0.006)}{0.094}$ \\ $\widehat{\text{Bias}}$ & $\underset{(0.015)}{ 0.041}$ & $\underset{67}$   & $\underset{57}$   & $\underset{83}$ \\
$\widehat{\text{SD}}$ & $\underset{340}$   & $\underset{44}$   & $3$  & $95$ \\
\hline
\end{tabular}
\caption{Estimates}
\label{5}
\end{table}

答案1

  • 我猜您正在寻找以下内容:

在此处输入图片描述

对于上表,我合并了机器人提供的表并为其添加了新的第一列。

\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs, multirow}

\usepackage{tabularray}

\begin{document}
    \begin{table}[ht]
    \centering
    \setlength\tabcolsep{4pt}
\begin{tabular}{@{} p{4em} p{7em} cc cc @{}}
    \toprule
\multirow{2.2}{=}{Sample size}
    & \multirow{2.2}{=}{Performance measure}
        & \multicolumn{2}{c}{MLE}  &  \multicolumn{2}{c}{MM}            \\
    \cmidrule(r){3-4}\cmidrule(l){5-6}
    &   & $\hat{\mu}$ & $\hat{\sigma}$ & $\hat{\mu}$ & $\hat{\sigma}$   \\
    \midrule
10   & $\widehat{\text{MSE}}$
        & $\underset{(0.009)}{0.117}$
            & $\underset{(0.004)}{0.064}$
                & $\underset{(0.009)}{0.121}$
                    & $\underset{(0.006)}{0.094}$                       \\
    & $\widehat{\text{Bias}}$
        & $\underset{(0.015)}{ 0.041}$
            & $\underset{(0.011)}{-0.067}$
                & $\underset{(0.015)}{ 0.057}$
                    & $\underset{(0.013)}{ -0.083}$                     \\
    & $\widehat{\text{SD}}$
        & $\underset{(0.011)}{0.340}$
            & $\underset{(0.007)}{0.244}$
                & $\underset{( 0.011)}{ 0.343}$
                    & $\underset{(0.009)}{0.295}$                       \\
    & $\text{RE}$ & $1.000$   & $1.000$   & $0.967$  & $0.681$          \\
    & 95\% CI of $\widehat{\text{MSE}}$
        & $[0.100,0.134]$
            & $[0.057,0.071]$
                & $[0.103,0.138]$
                    & $[0.082,0.105]$                                   \\
    \addlinespace[9pt]
%
15   & $\widehat{\text{MSE}}$
        & $\underset{(0.009)}{0.117}$
            & $\underset{(0.004)}{0.064}$
                & $\underset{(0.009)}{0.121}$
                    & $\underset{(0.006)}{0.094}$                       \\
    & $\widehat{\text{Bias}}$
        & $\underset{(0.015)}{ 0.041}$
            & $\underset{(0.011)}{-0.067}$
                & $\underset{(0.015)}{ 0.057}$
                    & $\underset{(0.013)}{ -0.083}$                     \\
    & $\widehat{\text{SD}}$
        & $\underset{(0.011)}{0.340}$
            & $\underset{(0.007)}{0.244}$
                & $\underset{( 0.011)}{ 0.343}$
                    & $\underset{(0.009)}{0.295}$                       \\
    & $\text{RE}$ & $1.000$   & $1.000$   & $0.967$  & $0.681$          \\
    & 95\% CI of $\widehat{\text{MSE}}$
        & $[0.100,0.134]$
            & $[0.057,0.071]$
                & $[0.103,0.138]$
                    & $[0.082,0.105]$                                   \\
    \bottomrule
\end{tabular}
\caption{Estimates of three performance measures for sample size 10 and 15.}
\label{tab:n5}
    \end{table}

\end{document}
  • 但是,对于您的表格,我会使用tabularraysiunitx打包。使用它们,数字在小数点处对齐,并且表格主体代码更简单/更短:
\documentclass{article}

\usepackage{tabularray}
\UseTblrLibrary{amsmath, booktabs, siunitx}

\begin{document}
 
    \begin{table}[h!]
    \centering
\sisetup{
    table-align-text-before=false, 
    input-open-uncertainty =,
    input-close-uncertainty=,
    table-format={(}-1.3{$^{)}$}
    }

    \begin{tblr}{colsep=4pt,
                 colspec={@{} Q[c, wd=4em]   
                              Q[l, wd=7em, mode=math]
                              *{4}{S}},
                 row{1} = {guard, mode=text},
                 row{2} = {guard, mode=math},
                 row{odd[3-X]}  ={belowsep=-4pt},
                 row{even[3-X]} ={font=\footnotesize, belowsep=2pt}
                 }
    \toprule
\SetCell[r=2]{c}   Sample size
    &   \SetCell[r=2]{c}    Performance measure
            &   \SetCell[c=2]{c}    MLE
                        &           &   \SetCell[c=2]{c}    MM
                                                &               \\
    \cmidrule[r]{3-4}\cmidrule[l]{5-6}
    &   & \hat{\mu} & \hat{\sigma}  & \hat{\mu} & \hat{\sigma}  \\
    \midrule
%
10  &   \widehat{\mathrm{MSE}}
        &  0.117    &  0.064        &  0.121    & 0.094     \\
    &   & (0.009)   & (0.004)       & (0.009)   & (0.006)   \\   
    &   \widehat{\mathrm{Bias}}
        &  0.041    & -0.067        &  0.057    & -0.083    \\
    &   & (0.015)   & (0.011)       & (0.015)   & (0.013)   \\
    &   \widehat{\text{SD}} 
        &  0.340    &  0.244        &  0.343    &  0.295    \\
    &   & (0.011)   & (0.007)       & (0.011)   & (0.009)   \\
    &   \mathrm{RE}
        &  1.000    &  1.000        &  0.967    &  0.681    \\
\SetRow{guard, abovesep=6pt, font=\normalsize}
    & \text{95\% CI of }\widehat{\text{MSE}} 
        & [0.100, 0.134] 
                    & [0.057, 0.071] 
                                    & [0.103, 0.138] 
                                                & [0.082, 0.105]    \\                                 
    \addlinespace[6pt]
%
15  &   \widehat{\mathrm{MSE}}
        &  0.117    &  0.064        &  0.121    & 0.094     \\
    &   & (0.009)   & (0.004)       & (0.009)   & (0.006)   \\
    &   \widehat{\mathrm{Bias}}
        &  0.041    & -0.067        &  0.057    & -0.083    \\
    &   & (0.015)   & (0.011)       & (0.015)   & (0.013)   \\
    &   \widehat{\text{SD}}
        &  0.340    &  0.244        &  0.343    &  0.295    \\
    &   & (0.011)   & (0.007)       & (0.011)   & (0.009)   \\
    &   \mathrm{RE}
        &  1.000    &  1.000        &  0.967    &  0.681    \\
\SetRow{guard}
    & \text{95\% CI of }\widehat{\text{MSE}}
        & [0.100, 0.134]
                    & [0.057, 0.071]
                                    & [0.103, 0.138]
                                                & [0.082, 0.105]    \\
    \bottomrule
    \end{tblr}
\caption{Table using \texttt{tblr} table.}
\label{tab:n5}
    \end{table}

\end{document}

在此处输入图片描述

相关内容