1

Hi I have used a recent suggestion by @leandriis to fix the headers table, but when I tried to use his suggestion to draw another table, I'm getting several issues, here my suggestion, my output and the desired table to produce.

My suggestion :

    \documentclass{article}
    \usepackage{geometry}
    \usepackage{rotating}
    \usepackage{booktabs, makecell}
    \usepackage[referable]{threeparttablex}
    \usepackage{siunitx}
   \usepackage[skip=1ex]{caption}
   \usepackage{xcolor}
   \newcommand\tc[1]{\textcolor{blue}{#1}}
   \NewExpandableDocumentCommand\mcc{O{1}m}
   {\multicolumn{#1}{>{\bfseries}c}{#2}}
   \usepackage{multirow}
   \renewcommand{\theadfont}{\normalsize} 

 \begin{document}
 \begin{table}[h!]
 \centering
 \begin{threeparttable}
  \caption{Forecasting and encompassing test results for the bagging model and combining methods, 
   1995:04–2005:03 out-of-sample period}
   \label{tab1}
   \begin{tabular}{@{} >{\itshape}l
               *{8}{S[table-format=1.2]}
                }
  \toprule
  \multirow{2.1}{*}{Combining method} 
  & \mcc[4]{$\thead{H_{0}$: BA encompasses CB}} 
  & \mcc[4]{$\thead{H_{0}$: CB encompasses BA}}   \\ 
  \cmidrule(r){2-5} \cmidrule(l){6-9}
  & \mcc{\hat{\lambda}_{CB}} & \mcc{MHLN_{h}} & \mcc{P-value} 
  & \mcc{\hat{\lambda}_{CB}} & \mcc{MHLN_{h}} & \mcc{P-value}\\
  \midrule
  BA model&9.13& & & & & \\
  Mean            & 0.35& 2.42\tc{**} & 0.01& 0.65& 3.54\tc{**} & 0.00\\ 
        Median          & 0.32& 2.38\tc{**} & 0.01& 0.68& 3.77\tc{**} & 0.00\\ 
        Trimmed mean    & 0.34& 2.39\tc{**} & 0.01& 0.66& 3.67\tc{**} & 0.00\\
        DMSE,$\Psi=1.00$& 0.35& 2.42\tc{**} & 1.00& 1.10& 3.54\tc{**} & 0.00\\
        DMSE,$\Psi=0.90$& 0.35& 2.41\tc{**} & 1.00& 1.10& 3.55\tc{**} & 0.00\\
        C(2, PB)        & 0.34& 2.34\tc{**} & 0.01& 0.66& 3.59\tc{**} & 0.00\\
        C(2, PB)        & 0.36& 2.33\tc{**} & 0.01& 0.64& 3.43\tc{**} & 0.00\\
        PC              & 0.59& 2.79\tc{**} & 0.00& 0.41& 2.14\tc{**} & 1.00\\             
  \bottomrule
\end{tabular}
 \end{threeparttable}
 \end{table}
 \end{document}

my output:

enter image description here

Desired Table :

enter image description here

3
  • 1
    for the \multirow{2.1}{*}{Combining method} use 3 instead of 2.1 and see the result -- which is the other problem please enumerate
    – js bibra
    Mar 23, 2021 at 9:16
  • Using \mcc[3] instead of \mcc[4] should help.
    – leandriis
    Mar 23, 2021 at 10:15
  • @leandriis it fix the headers but how to include the column of MSFE ratio and its value ? please
    – haithem
    Mar 23, 2021 at 10:22

1 Answer 1

1

In the following MWE, I first of all made sure, the code is compilable. Your original code was not compilable and resulted in a bunch of error messages due to various syntax errors. As soon as you get an error message, do not look as the resulting pdf file, but fiy the error mesages first. If you can't ask a specific question about this error message, but don't ignore them.

I added some small comments regarding all the changes I made to your code hoping that this will help you understand the reason for all these changes.

enter image description here

\documentclass{article}
\usepackage{geometry}
\usepackage{rotating}
\usepackage{booktabs, makecell}
\usepackage[referable]{threeparttablex}
\usepackage{siunitx}
\usepackage[skip=1ex]{caption}
\usepackage{xcolor}
\newcommand\tc[1]{\textcolor{blue}{#1}}
\NewExpandableDocumentCommand\mcc{O{1}m}
{\multicolumn{#1}{>{\bfseries}c}{#2}}
\usepackage{multirow}
\renewcommand{\theadfont}{\normalsize} 

 \begin{document}
 \begin{table}[h!]
 \centering
 \sisetup{table-format=1.2, table-column-width=1cm} % added. Setting are applied to all S type columns in this particular table, made all S type columns slightly wider to avoid uneven column widths due to too long shared header
 \begin{threeparttable}
  \caption{Forecasting and encompassing test results for the bagging model and combining methods, 
   1995:04–2005:03 out-of-sample period}
   \label{tab1}
   \begin{tabular}{@{} >{\itshape}l
                       S  % suitable column type for the "MSFE" column
               *{2}{S S[table-space-text-post=\tc{**}] S} % added table-space-text-post option for all "MHLN" columns, since they not only contain numbers, but also asterisks. Added in order to avoid overfull boxes, to regular S type columns for the \labmda_CB and P value columns
                }
  \toprule
  % \multirow removed, moved text to next row
  & & \mcc[3]{$H_{0}$: BA encompasses CB}  % added another & here,  \thead reomved here sinye you don't need manual linebreaks here
  & \mcc[3]{$H_{0}$: CB encompasses BA}   \\  % \thead reomved here sinye you don't need manual linebreaks here
  \cmidrule(r){3-5} \cmidrule(l){6-8} % corrected \cmidrule commands.
 Combining method & {MSFE} & \mcc{$\hat{\lambda}_{CB}$} & \mcc{$MHLN_{h}$} & \mcc{P-value}   % added "Combining method"  and " MSFE & " here,  math mode ($...$) added since neither \lambda not _ for subscripts can be used in text mode. Do not ignore error messages!
  & \mcc{$\hat{\lambda}_{CB}$} & \mcc{$MHLN_{h}$} & \mcc{P-value}\\ % math mode ($...$) added since neither \lambda not _ for subscripts can be used in text mode. Do not ignore error messages!
  \midrule 
  \multicolumn{8}{c}{A. $h=1$}\\ % added \multicolumn[1}{c}  for horizontally centered text here
 BA model        & 0.90 & 9.13 & & & & & \\ % added MSFE column here
 Mean            &      & 0.35 & 2.42\tc{**} & 0.01& 0.65& 3.54\tc{**} & 0.00\\ 
 Median          &      & 0.32 & 2.38\tc{**} & 0.01& 0.68& 3.77\tc{**} & 0.00\\ 
 Trimmed mean    &      & 0.34 & 2.39\tc{**} & 0.01& 0.66& 3.67\tc{**} & 0.00\\
 DMSE,$\Psi=1.00$&      & 0.35 & 2.42\tc{**} & 1.00& 1.10& 3.54\tc{**} & 0.00\\
 DMSE,$\Psi=0.90$&      & 0.35 & 2.41\tc{**} & 1.00& 1.10& 3.55\tc{**} & 0.00\\
 C(2, PB)        &      & 0.34 & 2.34\tc{**} & 0.01& 0.66& 3.59\tc{**} & 0.00\\
 C(2, PB)        &      & 0.36 & 2.33\tc{**} & 0.01& 0.64& 3.43\tc{**} & 0.00\\
 PC              &      & 0.59 & 2.79\tc{**} & 0.00& 0.41& 2.14\tc{**} & 1.00\\             
  \bottomrule
\end{tabular}
 \end{threeparttable}
 \end{table}
 \end{document}
2
  • You are always so helpful. I sincerely appreciate the assistance. Thank you so much
    – haithem
    Mar 23, 2021 at 20:37
  • @haithem, you should also up-vote this answer (not only accept it) if it is really so value to you as you say in your comment :-)
    – Zarko
    Mar 23, 2021 at 23:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .