0

Rmarkdown citation @bibtexkey fails when used in the tablenotes environment. Is there a way to fix this?

Bibtex source for the two citations in the upcoming MWE of the table

@Article{Lundberg2017,
  author      = {Scott Lundberg and Su-In Lee},
  title       = {A Unified Approach to Interpreting Model Predictions},
  abstract    = {Understanding why a model makes a certain prediction can be as crucial as the prediction's accuracy in many applications. However, the highest accuracy for large modern datasets is often achieved by complex models that even experts struggle to interpret, such as ensemble or deep learning models, creating a tension between accuracy and interpretability. In response, various methods have recently been proposed to help users interpret the predictions of complex models, but it is often unclear how these methods are related and when one method is preferable over another. To address this problem, we present a unified framework for interpreting predictions, SHAP (SHapley Additive exPlanations). SHAP assigns each feature an importance value for a particular prediction. Its novel components include: (1) the identification of a new class of additive feature importance measures, and (2) theoretical results showing there is a unique solution in this class with a set of desirable properties. The new class unifies six existing methods, notable because several recent methods in the class lack the proposed desirable properties. Based on insights from this unification, we present new methods that show improved computational performance and/or better consistency with human intuition than previous approaches.},
  date        = {2017-05-22},
  eprint      = {1705.07874v2},
  eprintclass = {cs.AI},
  eprinttype  = {arXiv},
  file        = {:http\://arxiv.org/pdf/1705.07874v2:PDF},
  keywords    = {cs.AI, cs.LG, stat.ML},
}

@Article{Amoukou2021,
  author       = {Salim I. Amoukou and Nicolas J-B. Brunel and Tangi Salaün},
  title        = {Accurate Shapley Values for explaining tree-based models},
  abstract     = {Although Shapley Values (SV) are widely used in explainable AI, they can be poorly understood and estimated, implying that their analysis may lead to spurious inferences and explanations. As a starting point, we remind an invariance principle for SV and derive the correct approach for computing the SV of categorical variables that are particularly sensitive to the encoding used. In the case of tree-based models, we introduce two estimators of Shapley Values that exploit the tree structure efficiently and are more accurate than state-of-the-art methods. Simulations and comparisons are performed with state-of-the-art algorithms and show the practical gain of our approach. Finally, we discuss the ability of SV to provide reliable local explanations. We also provide a Python package that computes our estimators at https://github.com/salimamoukou/acv00.},
  date         = {2021-06-07},
  eprint       = {2106.03820v2},
  eprintclass  = {stat.ML},
  eprinttype   = {arXiv},
  file         = {:http\://arxiv.org/pdf/2106.03820v2:PDF},
  journaltitle = {AISTATS 2022},
  keywords     = {stat.ML, cs.LG},
}

MWE of the table with citations of concern in the tablenotes :

\newcommand{\hlfancy}[2]{\sethlcolor{#1}\hl{#2}}

\begin{table}[!htbp]
\centering
\scriptsize
\captionsetup{labelsep=newline, justification=centering}
  \begin{threeparttable}
       \caption{\textit{SHAP Value calculation with bias }} 
    \begin{tabular}{*{5}{l}}
        \toprule
        & & \multicolumn{1}{c}{\makecell{\textbf{ Tree 1 }}}& & \\
        \midrule
        \multicolumn{1}{c}{\makecell{Feature \\ subset $(S)$}}&  \multicolumn{1}{c}{\makecell{$f_x(S)$}} & \multicolumn{1}{c}{\makecell{$f_{x}(S \cup\{X_1\})$}} & \multicolumn{1}{c}{\makecell{$f_{x}(S \cup\{X_1\}$\\$ - f_x(S))$ }} & \multicolumn{1}{c}{\makecell{ $|S| !(M-|S|-1) !$}}  \\
        \midrule
        \textit{$\emptyset$}   &
        \multicolumn{1}{c}{\makecell{$100$}} &
        \multicolumn{1}{c}{\makecell{$\dfrac{100}{500} * 100 + \dfrac{400}{500} * 200 $\\$= 180$}} & 
        \multicolumn{1}{c}{\makecell{$80$}}  &
        \multicolumn{1}{c}{\makecell{$0.5$}} 
\\
        \midrule
        \textit{\{$X_2$\}}   &
        \multicolumn{1}{c}{\makecell{\hlfancy{yellow}{$\dfrac{500}{1000}$}$ * 100+ $\hlfancy{yellow}{$\dfrac{500}{1000}$}$ * 200 $\\$= 150$}} &
        \multicolumn{1}{c}{\makecell{$200$}} & 
        \multicolumn{1}{c}{\makecell{$50$}}  &
        \multicolumn{1}{c}{\makecell{$0.5$}} 
\\
\midrule 
\midrule
&&&  \multicolumn{1}{c}{\makecell{SHAP value of $X_1$}} &  \multicolumn{1}{c}{\makecell{$90$}} \\
        \cmidrule{4-5}
       \multicolumn{1}{c}{\makecell{Feature \\ subset $(S)$}}&  \multicolumn{1}{c}{\makecell{$f_x(S)$}} & \multicolumn{1}{c}{\makecell{$f_{x}(S \cup\{X_2\})$}} & \multicolumn{1}{c}{\makecell{$f_{x}(S \cup\{X_2\} $\\$ - f_x(S))$ }} & \multicolumn{1}{c}{\makecell{ $|S| !(M-|S|-1) !$}}  \\
        \midrule
        \textit{$\emptyset$}   &
        \multicolumn{1}{c}{\makecell{$100$}} &
        \multicolumn{1}{c}{\makecell{\hlfancy{yellow}{$\dfrac{500}{1000}$}$ * 100 + $\hlfancy{yellow}{$\dfrac{500}{1000}$}$ * 200 $\\$= 150$}} & 
        \multicolumn{1}{c}{\makecell{$50$}}  &
        \multicolumn{1}{c}{\makecell{$0.5$}} 
\\
        \midrule
        \textit{\{$X_1$\}}   &
        \multicolumn{1}{c}{\makecell{$\dfrac{100}{500} * 100 + \dfrac{400}{500} * 200 $\\$= 180$}} &
        \multicolumn{1}{c}{\makecell{$200$}} & 
        \multicolumn{1}{c}{\makecell{$20$}}  &
        \multicolumn{1}{c}{\makecell{$0.5$}} 
\\
\midrule  
\midrule
&&&  \multicolumn{1}{c}{\makecell{SHAP value of $X_2$}} &  \multicolumn{1}{c}{\makecell{$35$}} \\
  \cmidrule{4-5}
        & & \multicolumn{1}{c}{\makecell{\textbf{ Tree 2 }}}& & \\
        \midrule
        \multicolumn{1}{c}{\makecell{Feature \\ subset $(S)$}}&  \multicolumn{1}{c}{\makecell{$f_x(S)$}} & \multicolumn{1}{c}{\makecell{$f_{x}(S \cup\{X_1\})$}} & \multicolumn{1}{c}{\makecell{$f_{x}(S \cup\{X_1\} $\\$ - f_x(S))$}} & \multicolumn{1}{c}{\makecell{ $|S| !(M-|S|-1) !$}}  \\
        \midrule
            \textit{$\emptyset$}   &
        \multicolumn{1}{c}{\makecell{$100$}} &
        \multicolumn{1}{c}{\makecell{\hlfancy{yellow}{$\dfrac{500}{1000}$}$ * 100 + $\hlfancy{yellow}{$\dfrac{500}{1000}$}$ * 200 $\\$= 150$}} & 
        \multicolumn{1}{c}{\makecell{$50$}}  &
        \multicolumn{1}{c}{\makecell{$0.5$}} 
\\
        \midrule
        \textit{\{$X_2$\}}   &
        \multicolumn{1}{c}{\makecell{$\dfrac{100}{500} * 100 + \dfrac{400}{500} * 200 $\\$= 180$}} &
        \multicolumn{1}{c}{\makecell{$200$}} & 
        \multicolumn{1}{c}{\makecell{$20$}}  &
        \multicolumn{1}{c}{\makecell{$0.5$}} 
\\          
\midrule  
\midrule
&&&  \multicolumn{1}{c}{\makecell{SHAP value of $X_1$}} &  \multicolumn{1}{c}{\makecell{$35$}} \\
        \cmidrule{4-5}
       \multicolumn{1}{c}{\makecell{Feature \\ subset $(S)$}}&  \multicolumn{1}{c}{\makecell{$f_x(S)$}} & \multicolumn{1}{c}{\makecell{$f_{x}(S \cup\{X_2\})$}} & \multicolumn{1}{c}{\makecell{$f_{x}(S \cup\{X_2\} $\\$ - f_x(S))$}} &
       \multicolumn{1}{c}{\makecell{ $|S| !(M-|S|-1) !$}}  \\
        \midrule
\textit{$\emptyset$}   &
        \multicolumn{1}{c}{\makecell{$100$}} &
        \multicolumn{1}{c}{\makecell{$\dfrac{100}{500} * 100 + \dfrac{400}{500} * 200 $\\$ = 180$}} & 
        \multicolumn{1}{c}{\makecell{$80$}}  &
        \multicolumn{1}{c}{\makecell{$0.5$}} 
\\
        \midrule
        \textit{\{$X_1$\}}   &
         \multicolumn{1}{c}{\makecell{\hlfancy{yellow}{$\dfrac{500}{1000}$}$ * 100 + $\hlfancy{yellow}{$\dfrac{500}{1000}$}$ * 200 $\\$= 150$}} &
        \multicolumn{1}{c}{\makecell{$200$}} & 
        \multicolumn{1}{c}{\makecell{$50$}}  &
        \multicolumn{1}{c}{\makecell{$0.5$}} 
\\
\midrule
\midrule
&&&  \multicolumn{1}{c}{\makecell{SHAP value of $X_2$}} &
\multicolumn{1}{c}{\makecell{$90$}} \\
\cmidrule{4-5}
\bottomrule
     \end{tabular}
    \begin{tablenotes}[flushleft]
      \small
      \item \textit{Note.} SHAP values were calculated using equation 2 of @Lundberg2017. In case of $|S|=\emptyset$ the author considered $0! = 1$. Highlighted parts of the calculation are weights which cause the bias of the SHAP values, argued by @Amoukou2021. 
    \end{tablenotes}
    \label{tab:SHAP_bias}
  \end{threeparttable}
\end{table}

Table output with wrong citation in table notes

1
  • A possible solution to at least secure the same citation layout is to replace @bibtexkey with \textcite{bibtexkey}.
    – mugdi
    May 2, 2022 at 13:39

1 Answer 1

1

Rmarkdown syntax can include raw LaTeX commands and LaTeX environments but inside LaTeX commands and LaTeX environments cannot include rmarkdown syntax.

You should not use @bibtexkey inside Latex code, but the equivalent LaTeX command (that could change depending on document settings, set keep_tex: yes and use @bibtexkey between pure markdown text to see how is exported exactly in your case).

You must log in to answer this question.

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