```{r echo = FALSE, warning = FALSE}
source("init.R")
source("images/part_0/part_0_science.R")
```
# What is science? {#sec-what-is-science}
*Last modified on `r format(fs::file_info("chapter-01-what-is-science.qmd")$modification_time, '%d. %B %Y at %H:%M:%S')`*
> *"Reality is negotiable." --- Tim Ferriss*
```{r}
#| message: false
#| echo: false
#| warning: false
#| fig-align: center
#| fig-height: 10
#| fig-width: 10
#| fig-cap: "foo"
#| label: fig-test-theory
ggplot() +
#theme_void() +
coord_cartesian(xlim = c(-10, 10), ylim = c(-10, 10)) +
geom_hline(yintercept = c(-5, 0, 5), color = "gray") +
geom_vline(xintercept = c(-5, 0, 5), color = "gray") +
scale_x_continuous(breaks = seq(-10, 10, 1)) +
scale_y_continuous(breaks = seq(-10, 10, 1)) +
## Population
geom_circle(aes(x0 = -5, y0 = 5, r = 4.25), fill = "white") +
annotate("label", x = -5, y = 9.25, label = "Population", size = 7.5, fontface = 2) +
annotate("text", x = 2, y = 9.95, label = "Randomisation", size = 5.5, fontface = 2) +
annotate("text", x = 2, y = 9.5, label = "Structural equality", size = 5, fontface = 3) +
geom_curve(aes(x = -2, y = 8, xend = 6, yend = 8),
arrow = arrow(length = unit(0.01, "npc"), type = "closed"),
curvature = -0.3, color = "black", linewidth = 0.5) +
## Sample
geom_circle(aes(x0 = 7.5, y0 = 7.5, r = 1.5), fill = "white") +
annotate("label", x = 7.5, y = 9, label = "Sample", size = 7.5, fontface = 2) +
geom_curve(aes(x = 6, y = 7, xend = 3, yend = 6),
arrow = arrow(length = unit(0.01, "npc"), type = "closed"),
curvature = 0.4, color = "black", linewidth = 0.5) +
geom_curve(aes(x = 9.1, y = 7.5, xend = 9.1, yend = 2.5),
arrow = arrow(length = unit(0.01, "npc"), type = "closed"),
curvature = -0.3, color = "black", linewidth = 0.5,
linetype = "33") +
## Test
geom_circle(aes(x0 = 7.5, y0 = 2.5, r = 1.5), fill = "white") +
geom_curve(aes(x = 6, y = 2, xend = -1.9, yend = 2),
arrow = arrow(length = unit(0.01, "npc"), type = "closed"),
curvature = -0.3, color = "black", linewidth = 0.5) +
annotate("text", x = 7.5, y = 2.5, label = "Statistical\ntest", size = 6, fontface = 2) +
annotate("label", x = 8.5, y = 1.4, label = expression(T[D]), size = 6) +
annotate("text", x = 2, y = 1.85, label = "Conclusion", size = 5.5, fontface = 2) +
annotate("text", x = 2, y = 1.25, label = expression(Does~H[0]~apply*"?"),
size = 5, fontface = 3) +
## Desc stat
geom_curve(aes(x = 3, y = 4, xend = 6, yend = 3),
arrow = arrow(length = unit(0.01, "npc"), type = "closed"),
curvature = 0.4, color = "black", linewidth = 0.5) +
geom_shape(data = tibble(x = c(1, 5, 5, 1), y = c(4.1, 4.1, 5.9, 5.9)),
aes(x, y), radius = unit(0.5, 'cm'), fill = "white", color = "black") +
annotate("text", x = 3, y = 5, label = "Descriptive\nstatistics", size = 6, fontface = 2) +
## Distribution
geom_segment(aes(x = 7.5, y = -8.5, xend = 7.5, yend = -7.5)) +
geom_line(data = tibble(x_raw = seq(-3.5, 3.5, 0.01), y_raw = dnorm(x_raw)),
aes(x = (x_raw*1.25 + 5), y = (y_raw*18 - 8.5)),
linewidth = 1, color = "gray") +
geom_segment(aes(x = 5, y = -8.5, xend = 5, yend = -1.3), color = "gray") +
geom_segment(aes(x = 0.7, y = -8.5, xend = 9.3, yend = -8.5), color = "gray")
```
```{r}
#| message: false
#| echo: false
#| warning: false
#| fig-align: center
#| fig-height: 7
#| fig-width: 7
#| fig-cap: "foo"
#| label: fig-test-theory-old
set.seed(20240407)
truth_tbl <- tibble(grp = as_factor("truth"),
x = rnorm(200, 20, 7),
y = rnorm(200, 70, 7),
color = as_factor(sample(1:6, 200, replace = TRUE)),
shape = as_factor(sample(1:4, 200, replace = TRUE)))
data_theory_tbl <- tibble(grp = as_factor("data"),
x = rnorm(12, 90, 2),
y = rnorm(12, 80, 2),
color = as_factor(sample(1:3, 12, replace = TRUE)),
shape = as_factor(sample(1:2, 12, replace = TRUE)))
t1_tbl <- tibble(grp = as_factor("t1"),
x = rnorm(12, 70, 3),
y = rnorm(12, 45, 3),
color = as_factor(sample(2:4, 12, replace = TRUE)),
shape = as_factor(sample(2:3, 12, replace = TRUE)))
t2_tbl <- tibble(grp = as_factor("t1"),
x = rnorm(12, 60, 2),
y = rnorm(12, 25, 2),
color = as_factor(sample(4:6, 12, replace = TRUE)),
shape = as_factor(sample(2:3, 12, replace = TRUE)))
t3_tbl <- tibble(grp = as_factor("t1"),
x = rnorm(12, 35, 2),
y = rnorm(12, 10, 2),
color = as_factor(sample(1:4, 12, replace = TRUE)),
shape = as_factor(sample(3:4, 12, replace = TRUE)))
t4_tbl <- tibble(grp = as_factor("t1"),
x = rnorm(12, 5, 3),
y = rnorm(12, 10, 3),
color = as_factor(sample(3:6, 12, replace = TRUE)),
shape = as_factor(sample(1:2, 12, replace = TRUE)))
dist_tbl <- tibble(x_raw = seq(-4, 4, 0.01),
y_raw = dnorm(x_raw))
bind_rows(truth_tbl,
data_theory_tbl,
t1_tbl,
t2_tbl,
t3_tbl,
t4_tbl) |>
ggplot(aes(x, y)) +
theme_void() +
#theme_minimal() +
geom_jitter(aes(fill = color, shape = shape), size = 4, width = 5, height = 5) +
annotate("text", x = 60, y = 105, label = "Randomisierung", size = 5, fontface = 2) +
annotate("text", x = 60, y = 101, label = "(Strukturgleichheit)", size = 5, fontface = 3) +
geom_curve(x = 36, y = 90, xend = 85, yend = 85,
arrow = arrow(length = unit(0.01, "npc"), type = "closed"),
curvature = -0.5, color = "black", linewidth = 0.5) +
geom_curve(x = 91, y = 38, xend = 43, yend = 72,
arrow = arrow(length = unit(0.01, "npc"), type = "closed"),
curvature = 0.6, color = "black", linewidth = 0.5) +
geom_curve(x = 99, y = 83, xend = 110, yend = 68,
arrow = arrow(length = unit(0.01, "npc"), type = "closed"),
curvature = -0.2, color = "black", linewidth = 0.5) +
geom_curve(x = 110, y = 60, xend = 105, yend = 11,
arrow = arrow(length = unit(0.01, "npc"), type = "closed"),
curvature = -0.3, color = "black", linewidth = 0.5) +
annotate("text", x = 20, y = 102, label = "Grundgesamtheit", size = 5, fontface = 2) +
geom_ellipse(aes(x0 = 20, y0 = 70, a = 22, b = 29, angle = 0), color = "black") +
annotate("text", x = 93, y = 98, label = "Stichprobe", size = 5, fontface = 2) +
annotate("text", x = 93, y = 94, label = "Daten (D)", size = 5, fontface = 3) +
geom_ellipse(aes(x0 = 91, y0 = 80, a = 12, b = 7, angle = 20), color = "black") +
annotate("text", x = 110, y = 66, label = "Teststatistik", size = 5, fontface = 2) +
annotate("label", x = 110, y = 60, label = expression(T[D]), size = 7) +
annotate("text", x = 60, y = 77, label = "Rückschluß", size = 5, fontface = 2) +
annotate("text", x = 60, y = 70, label = expression(Gilt~die~H[0]*"?"),
size = 5, fontface = 3) +
geom_ellipse(aes(x0 = 7, y0 = 10, a = 10, b = 10, angle = 0), color = "gray") +
geom_ellipse(aes(x0 = 36, y0 = 10, a = 10, b = 10, angle = 0), color = "gray") +
geom_ellipse(aes(x0 = 60, y0 = 24, a = 10, b = 10, angle = 0), color = "gray") +
geom_ellipse(aes(x0 = 70, y0 = 44, a = 10, b = 10, angle = 0), color = "gray") +
geom_curve(x = 34, y = 42, xend = 59, yend = 44,
arrow = arrow(length = unit(0.01, "npc"), type = "closed"),
curvature = -0.2, color = "gray", linewidth = 0.5) +
geom_curve(x = 35, y = 41, xend = 51, yend = 30,
arrow = arrow(length = unit(0.01, "npc"), type = "closed"),
curvature = -0.2, color = "gray", linewidth = 0.5) +
geom_curve(x = 30, y = 40, xend = 35, yend = 21,
arrow = arrow(length = unit(0.01, "npc"), type = "closed"),
curvature = -0.2, color = "gray", linewidth = 0.5) +
geom_curve(x = 20, y = 40, xend = 8, yend = 21,
arrow = arrow(length = unit(0.01, "npc"), type = "closed"),
curvature = 0.2, color = "gray", linewidth = 0.5) +
annotate("label", x = 25, y = 42, label = expression(H[0]~wahr),
size = 7) +
geom_line(data = dist_tbl, aes(x = (x_raw + 13)*7, y = y_raw*80+5),
linewidth = 1, color = "gray") +
geom_segment(x = 65, y = 5, xend = 115, yend = 5, color = "gray") +
geom_segment(x = 91, y = 5, xend = 91, yend = 37, color = "gray") +
geom_segment(x = 104, y = 5, xend = 104, yend = 10.5) +
annotate("text", x = 91, y = 3, label = "0") +
annotate("text", x = 104, y = 3, label = expression(T[D])) +
annotate("text", x = 80, y = -2, label = "Testverteilung", size = 5,
fontface = 2) +
annotate("text", x = 101, y = -2, label = expression("("*T[1]*","*"..."*","*T[p]*")"), size = 5,
fontface = 2) +
annotate("text", x = 21.5, y = 12, label = "...", size = 12, fontface = 2,
color = "gray") +
annotate("label", x = 81, y = 42, label = expression(T[1]), size = 7) +
annotate("label", x = 70, y = 18, label = expression(T[2]), size = 7) +
annotate("label", x = 46, y = 3, label = expression(T[3]), size = 7) +
annotate("label", x = 16.5, y = 3, label = expression(T[p]), size = 7) +
scale_x_continuous(limits = c(-3, 115)) +
scale_y_continuous(limits = c(-4, 105)) +
scale_shape_manual(values = 21:24) +
theme(legend.position = "none") +
scale_fill_okabeito()
```
```{r}
#| echo: false
#| message: false
#| warning: false
#| label: fig-chap-01-vulcan
#| fig-align: center
#| fig-height: 3.5
#| fig-width: 10.5
#| fig-cap: "foo **(A)** foo **(B)** foo"
p_vulcan_observed + p_vulcan_model +
plot_layout(ncol = 2) +
plot_annotation(tag_levels = 'A', tag_prefix = '(', tag_suffix = ')') &
theme(plot.tag = element_text(size = 16, face = "bold"))
```
```{r}
#| echo: false
#| message: false
#| warning: false
#| label: fig-chap-01-habital
#| fig-align: center
#| fig-height: 3.5
#| fig-width: 10.5
#| fig-cap: "foo **(A)** foo **(B)** foo"
p_habital_observed + p_habital_model +
plot_layout(ncol = 2) +
plot_annotation(tag_levels = 'A', tag_prefix = '(', tag_suffix = ')') &
theme(plot.tag = element_text(size = 16, face = "bold"))
```
```{r}
#| echo: false
#| message: false
#| warning: false
#| label: fig-chap-01-hollow
#| fig-align: center
#| fig-height: 3.5
#| fig-width: 10.5
#| fig-cap: "foo **(A)** foo **(B)** foo"
p_hollow_observed + p_hollow_model +
plot_layout(ncol = 2) +
plot_annotation(tag_levels = 'A', tag_prefix = '(', tag_suffix = ')') &
theme(plot.tag = element_text(size = 16, face = "bold"))
```
## General background
> *"Any sufficiently advanced technology is indistinguishable from magic." --- @clarke1968clarke, Clarke's third law*
Full quote
> *"Reality is negotiable. Outside of science and law, all rules can be bent or broken, and it doesn’t require being unethical." --- Tim Ferriss*
Idea of hypotheses
Science is guessing and falsification
@chalmers2013thing [What is this thing called Science?](https://www.pmf.unizg.hr/_download/repository/1._Dodatna_literatura_%28filozofija_znanosti%29%5B3%5D.pdf)
@feynman1966science [What is science](https://www-oc.chemie.uni-regensburg.de/diaz/media/docs/feynman_what-is-science_68.pdf)
@campbell1952science [What is science?](https://www.whatisscience.info/files/what_is_science_rd1.pdf)
@clark2025models [Models Demystified: A Practical Guide from Linear Regression to Deep Learning](https://m-clark.github.io/book-of-models/)
@cox2017statistical [Statistical Thinking for the 21st Century](https://statsthinking21.github.io/statsthinking21-core-site/index.html)
@deutsch2011beginning [The beginning of infinity: Explanations that transform the world](https://www.academia.edu/download/106176299/rtx120400544p.pdf)
[David Deutsch > Quotes](https://www.goodreads.com/author/quotes/103190.David_Deutsch)
## Theoretical background
## R packages used
## Data
## Alternatives
Further tutorials and R packages on XXX
## Glossary
term
: what does it mean.
## The meaning of "Models of Reality" in this chapter.
- itemize with max. 5-6 words
## Summary
## References {.unnumbered}