---
title: "Test choice tree"
output: rmarkdown::pdf_document
classoption: landscape
header-includes:
- \usepackage{tikz}
- \usepackage{tikz-cd}
- \usepackage{stackengine}
- \tikzcdset{scale cd/.style={every label/.append style={scale=#1}, cells={nodes={scale=#1}}}, every arrow/.append style={line width=0.1}}
- \parindent=0pt
- \pagenumbering{gobble}
pkgdown:
  as_is: true 
  extension: pdf
  title: Test choice tree
vignette: >
  %\VignetteIndexEntry{b_test_choice_tree}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

The graph below describes the test choice algorithm employed in the \texttt{DescrTab2} package.
Some of the branching steps are dependent on the data and some can be manipulated by the user.
The type of data (\texttt{numeric},  \texttt{ordered} factor and unordered \texttt{factor}) is automatically determined,
as is the number of groups and the number of categories in categorical variables. The user may choose to apply nonparametric instead
of parametric tests, asymptotic instead of exact and paired instead of unpaired tests.

The default configuration of arguments is \texttt{test\_options=list(paired=F, nonparametric=F, exact=F)}.
In a scenario with 2 groups, this will give Welch's t-test for numerical variables and a chi-squared test for
categorical variables with 2 categories.

Test choices can be manually overwritten via the appropriately titled parameter \texttt{test\_override}.
If, for example, you want to calculate Boschloo's test only for the gender variable and use a chi-squared test (default) for everything else,
you can request this by supplying the following argument: \newline
\texttt{var\_options=list(gender=list(test\_options = list(test\_override="Boschloo's test")))}.


\vspace{1.5cm}

<!-- https://tikzcd.yichuanshen.de/#N4Igdg9gJgpgziAXAbVABwnAlgFyxMJZARgAYAaUgXXJADcBDAGwFcYkQAdTnGADxwAjAGbBuvAcADqACywBjGQAJecHEqxwlizDDBLhEAE4qZMJYyNYGgpuYC+S8fxyvgl+88kB+e-ZD25OiYuPiEKACc5MQ09MxsHF5CoknAAMIMvADmxgrMfgFBIBjYeARExMTRsYys7IhcPC4iYk2SAHIsALYwVvL5-oHBpWEVFABMNfH1jRLJrXPAAPJGUFhgA4XDoeUoAGzkk7S1C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FT3hVKjeGxt7xm3JM9Y2kk1rkllv3ac1VbLcXnsqdW+9cySRHuSSe99rqv2VNbY28Ys7nWNuxQskke6D03sqaB39yTR2VPndumDLxx1tpfS8RFVB7BAA -->
\hspace{-2.5cm}\begin{tikzcd}[scale cd=0.28, sep=10pt]
                           &                                                                                   &                                         &                                   &                                                   &                                                                                                                     &                                                                                                                 &                                                                                                                &                                               &                                                                                                                                           & \textbf{\text{Which test is chosen for the variable } \texttt{var}\text{?}} \arrow[ld, "\texttt{is.factor(var)==T}" description] \arrow[rd, "\texttt{is.numeric(var)==T}" description] &                                                                                                                                     &                                       &                                             &                                                                                                                                                                 &                                    &                                                             &                                \\
                           &                                                                                   &                                         &                                   &                                                   &                                                                                                                     &                                                                                                                 &                                                                                                                &                                               & \textbf{\text{Categorical}} \arrow[rd, "\texttt{is.ordered(var)==T}" description] \arrow[llld, "\texttt{is.ordered(var)==F}" description] &                                                                                                                                                                                        & \textbf{\text{Numerical}} \arrow[ld, "\texttt{nonparametric==T}" description] \arrow[rrrd, "\texttt{nonparametric==F}" description] &                                       &                                             &                                                                                                                                                                 &                                    &                                                             &                                \\
                           &                                                                                   &                                         &                                   &                                                   &                                                                                                                     & \textbf{\text{Nominal}} \arrow[ld, "\texttt{exact==F}" description] \arrow[rd, "\texttt{exact==T}" description] &                                                                                                                &                                               &                                                                                                                                           & \textbf{\text{Ordinal}} \arrow[ldd, "\texttt{paired==T}" description] \arrow[rdd, "\texttt{paired==F}" description]                                                                    &                                                                                                                                     &                                       &                                             & \textbf{\text{\stackanchor{Continuous}{and normally distributed}}} \arrow[ldd, "\texttt{paired==T}" description] \arrow[rrdd, "\texttt{paired==F}" description] &                                    &                                                             &                                \\
                           &                                                                                   &                                         &                                   &                                                   & \textbf{\text{Asymptotic}} \arrow[d, "\texttt{paired==F}" description] \arrow[ld, "\texttt{paired==T}" description] &                                                                                                                 & \textbf{\text{Exact}} \arrow[ld, "\texttt{paired==T}" description] \arrow[d, "\texttt{paired==F}" description] &                                               &                                                                                                                                           &                                                                                                                                                                                        &                                                                                                                                     &                                       &                                             &                                                                                                                                                                 &                                    &                                                             &                                \\
                           &                                                                                   &                                         &                                   & \textbf{\text{Paired}} \arrow[llld] \arrow[lllld] & \textbf{\text{Independent}} \arrow[lld] \arrow[llld]                                                                & \textbf{\text{Paired}} \arrow[lld]                                                                              & \textbf{\text{Independent}} \arrow[ld] \arrow[d] \arrow[lld]                                                   &                                               & \textbf{\text{Paired}} \arrow[ld] \arrow[d]                                                                                               &                                                                                                                                                                                        & \textbf{\text{Independent}} \arrow[rd] \arrow[ld] \arrow[d]                                                                         &                                       & \textbf{\text{Paired}} \arrow[rd] \arrow[d] &                                                                                                                                                                 &                                    & \textbf{\text{Independent}} \arrow[ld] \arrow[d] \arrow[rd] &                                \\
\text{2x2 table} \arrow[d] & {\text{\stackanchor{K repetitions x L Groups table,}{binary response}}} \arrow[d] & \text{1xL table} \arrow[d]              & \text{KxL table} \arrow[d]        & \text{2x2 table} \arrow[d]                        & \text{1xL table} \arrow[d]                                                                                          & \text{2x2 table} \arrow[d]                                                                                      & \text{\stackanchor{KxL table or}{large n}} \arrow[d]                                                           & \text{2 groups} \arrow[d]                     & \geq \text{3 groups} \arrow[d]                                                                                                            & \text{1 group} \arrow[d]                                                                                                                                                               & \text{2 groups} \arrow[d]                                                                                                           & \geq\text{ 3 groups} \arrow[d]        & \text{2 groups} \arrow[d]                   & \geq \text{3 groups} \arrow[d]                                                                                                                                  & \text{1 group} \arrow[d]           & \text{2 groups} \arrow[d]                                   & \geq \text{3 groups} \arrow[d] \\
\text{McNemar's test}      & \text{Cochrane's Q test}                                                          & \text{Chi-squared goodness-of-fit test} & \text{Pearson's Chi-squared test} & \text{Exact McNemar's test}                       & \text{Exact binomial test}                                                                                          & \text{Boschloo's test}                                                                                          & \text{Fisher's exact test}                                                                                     & \text{Wilcoxon's two-sample signed-rank test} & \text{Friedman's test}                                                                                                                    & \text{Wilcoxon's one-sample signed-rank test}                                                                                                                                          & \text{Mann-Whitney's U test}                                                                                                        & \text{Kruskal-Wallis's one-way ANOVA} & \text{Student's paired t-test}              & {\text{\stackanchor{Mixed model ANOVA,}{subject ID as random effect}}}                                                                                          & \text{Student's one-sample t-test} & \text{Welch's t-test}                                       & \text{F-test (ANOVA)}         
\end{tikzcd}
