```{r echo = FALSE}
#| message: false
#| warning: false
pacman::p_load(tidyverse, readxl, knitr, kableExtra, Hmisc, performance, parameters,
latex2exp, see, patchwork, mfp, multcomp, emmeans, janitor, effectsize,
broom, ggmosaic, tinytable,
conflicted)
conflicts_prefer(dplyr::select)
conflicts_prefer(dplyr::filter)
cb_pal <- c("#000000", "#E69F00", "#56B4E9", "#009E73",
"#F0E442", "#0072B2", "#D55E00", "#CC79A7")
cbbPalette <- cb_pal
```
# Baustelle {#sec-construction}
*Letzte Änderung am `r format(fs::file_info("construction-zone.qmd")$modification_time, '%d. %B %Y um %H:%M:%S')`*
{fig-align="center" width="100%"}
## Ranged t-Test {.unnumbered}
[Beware the Friedman test!](https://seriousstats.wordpress.com/2012/02/14/friedman/)
[Equivalent to Welch's t-test in GLS framework](https://stats.stackexchange.com/questions/142685/equivalent-to-welchs-t-test-in-gls-framework)
[Common statistical tests are linear models](https://lindeloev.github.io/tests-as-linear/)
[Are parametric tests on rank transformed data equivalent to non-parametric test on raw data?](https://stats.stackexchange.com/questions/210529/are-parametric-tests-on-rank-transformed-data-equivalent-to-non-parametric-test?noredirect=1#comment399981_210529)
@conover1981rank mit [Rank Transformations as a Bridge Between Parametric and Nonparametric Statistics](https://www.jstor.org/stable/2683975)
```{r}
set.seed(20250345)
ranked_tbl <- tibble(grp = gl(3, 7, labels = c("cat", "dog", "fox")),
rsp_lognormal = c(round(rlnorm(7, 4, 1), 2),
round(rlnorm(7, 4, 1), 2),
round(rlnorm(7, 4, 1), 2)),
ranked_lognormal = rank(rsp_lognormal),
rsp_normal = c(round(rnorm(7, 4, 1), 2),
round(rnorm(7, 5, 1), 2),
round(rnorm(7, 7, 1), 2)),
ranked_normal = rank(rsp_normal))
```
```{r}
t.test(ranked_normal ~ grp, data = filter(ranked_tbl, grp != "fox")) |>
tidy() |>
select(p.value)
```
```{r}
wilcox.test(rsp_normal ~ grp, data = filter(ranked_tbl, grp != "fox")) |>
tidy() |>
select(p.value)
```
```{r}
signed_rank <- function(x) sign(x) * rank(abs(x))
```
```{r}
rank(c(3.6, 3.4, -5.0, 8.2))
signed_rank(c(3.6, 3.4, -5.0, 8.2))
```
## Concordance Correlation Coefficient (CCC) {.unnumbered}
*Kann auch in technische Gleichheit mit rein*
```{r}
nirs_wide_tbl <- read_excel("data/nirs_qs_data.xlsx") |>
clean_names()
nirs_long_tbl <- nirs_wide_tbl |>
pivot_longer(cols = jd_ts:last_col(),
values_to = "values",
names_to = c("method", "type"),
names_sep = "_") |>
mutate(gulleart = as_factor(gulleart),
method = as_factor(method),
type = as_factor(type))
```
[Technical note: Validation and comparison of 2 commercially available activity loggers](https://www.sciencedirect.com/science/article/pii/S0022030218302418)
[User's guide to correlation coefficients](https://pmc.ncbi.nlm.nih.gov/articles/PMC6107969/)
[Concordance correlation coefficient calculation in R](https://medium.com/@amorimfranchi/concordance-correlation-coefficient-calculation-in-r-98d74ae5f0fc)
## Bessere Schriftart? {.unnumbered}
[Adding Custom Fonts to ggplot in R](https://gradientdescending.com/adding-custom-fonts-to-ggplot-in-r/)
[Aesthetic specifications](https://ggplot2.tidyverse.org/articles/ggplot2-specs.html)
Die Sache mit der Schriftart in `{ggplot}`.
```{r}
library(ggrepel)
```
[Getting started with `{ggrepel}`](https://cran.r-project.org/web/packages/ggrepel/vignettes/ggrepel.html) [{`ggtext`}: Improved text rendering support for ggplot2](https://wilkelab.org/ggtext/)
```{r}
update_geom_defaults("label",
list(family = "IBM Plex Sans Condensed"))
update_geom_defaults(ggtext::GeomRichText,
list(family = "IBM Plex Sans Condensed"))
update_geom_defaults("label_repel",
list(family = "IBM Plex Sans Condensed"))
```
```{r}
ggplot(tibble(x = 1:3, y = 1:3), aes(x,y)) +
theme_minimal(base_family = "IBM Plex Sans Condensed") +
geom_point() +
labs(x = "Hallo", y = "Mehr zesz")
```
## `{gganimate}`
[Datanovia](https://www.datanovia.com/en/blog/gganimate-how-to-create-plots-with-beautiful-animation-in-r/)
[Cheat sheet `{gganimate}`](https://rstudio.github.io/cheatsheets/gganimate.pdf)
## SQL als `{dbplyr}`?
[Das R Paket `{dbplyr}`](https://dbplyr.tidyverse.org/) [Database Queries With R](https://solutions.posit.co/connections/db/getting-started/database-queries/)