Kapitel 9 Was willst du machen?

9.1 Daten manipulieren

Ich möchte meine Datenobjekte manipulieren.

9.1.1 Zeilen und Spalten tauschen

Ich möchte bei meinem Datensatz Zeilen und Spalten vertauschen.

Dies kann mit der Funktion apply() gemacht werden. Angenommen das Datenframe datensatz sieht wie folgt aus …

# lade Testdatensatz datensatz
datensatz <-read.table(url("http://www.produnis.de/R/DieDaten.csv"), sep=";", header=TRUE) 
# zeige "datensaz" an 
datensatz
##     Name   Geschlecht Lieblingsfarbe Einkommen
## 1   Hans    maennlich          gruen      1233
## 2   Caro     weiblich           blau       800
## 3   Lars intersexuell           gelb      2400
## 4   Ines     weiblich        schwarz      4000
## 5 Samira     weiblich           gelb       899
## 6  Peter    maennlich          gruen      1100
## 7  Sarah     weiblich           blau      1900

…so tauschen wir Zeilen und Spalten mittels

# vertausche Spalten und Zeilen 
apply(datensatz, MARGIN=1, FUN=function(x) {x})
##                [,1]        [,2]       [,3]           [,4]       [,5]      
## Name           "Hans"      "Caro"     "Lars"         "Ines"     "Samira"  
## Geschlecht     "maennlich" "weiblich" "intersexuell" "weiblich" "weiblich"
## Lieblingsfarbe "gruen"     "blau"     "gelb"         "schwarz"  "gelb"    
## Einkommen      "1233"      " 800"     "2400"         "4000"     " 899"    
##                [,6]        [,7]      
## Name           "Peter"     "Sarah"   
## Geschlecht     "maennlich" "weiblich"
## Lieblingsfarbe "gruen"     "blau"    
## Einkommen      "1100"      "1900"

Da die Funktion apply() eine Typkonversion in die Klasse matrix vornimmt, (und somit alle Datentypen auf den kleinsten gemeinsamen Nenner character zurückfallen, siehe die Anführungszeichen im Output) muss bei Bedarf zurück in die Klasse data.frame konvertiert werden.

# vertausche Spalten und Zeilen 
as.data.frame(apply(datensatz, MARGIN=1, FUN=function(x) {x}))
##                       V1       V2           V3       V4       V5        V6
## Name                Hans     Caro         Lars     Ines   Samira     Peter
## Geschlecht     maennlich weiblich intersexuell weiblich weiblich maennlich
## Lieblingsfarbe     gruen     blau         gelb  schwarz     gelb     gruen
## Einkommen           1233      800         2400     4000      899      1100
##                      V7
## Name              Sarah
## Geschlecht     weiblich
## Lieblingsfarbe     blau
## Einkommen          1900

9.1.2 COVID19 Fallzahlen analysieren

Ich möchte die COVID19-Fallahlen analysieren.

Hierfür gibt es eine schöne Anleitung von der Universität Toronto: https://mdl.library.utoronto.ca/technology/tutorials/covid-19-data-r

Zunächst holen wir uns die aktuellen Daten.

# aktiviere das Tidyverse
library(tidyverse)

# Importiere Johns Hopkins Github data
confirmedraw <- read.csv( "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv")
deathsraw <- read.csv( "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv")
recoveredraw <- read.csv( "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_recovered_global.csv")

Dann bringen wir sie ins richtige Format.

confirmed <- confirmedraw %>% 
  gather(key="date", value="confirmed", -c(Country.Region, Province.State, Lat, Long)) %>%    group_by(Country.Region, date) %>% 
  summarize(confirmed=sum(confirmed))
deaths <- deathsraw %>% 
  gather(key="date", value="deaths", -c(Country.Region, Province.State, Lat, Long)) %>% 
  group_by(Country.Region, date) %>% 
  summarize(deaths=sum(deaths))
recovered <- recoveredraw %>% 
  gather(key="date", value="recovered", -c(Country.Region, Province.State, Lat, Long)) %>% 
  group_by(Country.Region, date) %>% 
  summarize(recovered=sum(recovered))
summary(confirmed)
##    confirmed        
##  Min.   :4.401e+10  
##  1st Qu.:4.401e+10  
##  Median :4.401e+10  
##  Mean   :4.401e+10  
##  3rd Qu.:4.401e+10  
##  Max.   :4.401e+10

Jetzt kombinieren wir alles in ein Datenframe und korrigieren die Datumsangaben.

# Final data: combine all three
country <- full_join(confirmed, deaths) %>% 
  full_join(recovered)
# Date variable
# repariere Datumsangaben von character nach date
country$date <- country$date %>% 
  sub("X", "", .) %>% 
  as.Date("%m.%d.%y")

# Neue variable: Anzahl der Tage
country <- country %>% 
  group_by(Country.Region) %>% 
  mutate(cumconfirmed=cumsum(confirmed), days = date - first(date) + 1)

Jetzt aggregieren wir auf Weltperspektive und Deutschland.

world <- country %>% 
  group_by(date) %>% 
  summarize(confirmed=sum(confirmed), cumconfirmed=sum(cumconfirmed), deaths=sum(deaths), recovered=sum(recovered)) %>% 
  mutate(days = date - first(date) + 1)
# Extract specific country: Germany
germany <- country %>% dplyr::filter(Country.Region=="Germany")

So vorbereitet können wir Statistiken ausgeben …

# SUMMARY STATISTICS
summary(country)
by(country$confirmed, country$Country.Region, summary)
by(country$cumconfirmed, country$Country.Region, summary)
by(country$deaths, country$Country.Region, summary)
by(country$recovered, country$Country.Region, summary)
summary(world)
summary(germany)

… und Grafiken plotten.

# World confirmed
ggplot(world, aes(x=date, y=confirmed)) + geom_bar(stat="identity", width=0.1) +
  theme_classic() +
  labs(title = "Covid-19 Global Confirmed Cases", x= "Date", y= "Daily confirmed cases") +
  theme(plot.title = element_text(hjust = 0.5))

# Germany confirmed
ggplot(germany, aes(x=date, y=confirmed)) + geom_bar(stat="identity", width=0.1) +
  labs(title = "Covid-19 Confirmed Cases in Germany", x= "Date", y= "Daily confirmed cases") +
  theme(plot.title = element_text(hjust = 0.5))

# Line graph of cases over time
# World confirmed
ggplot(world, aes(x=days, y=confirmed)) + geom_line() +
  labs(title = "Covid-19 Global Confirmed Cases", x= "Days", y= "Daily confirmed cases") +
  theme(plot.title = element_text(hjust = 0.5))

# Ignore warning
# World confirmed with counts in log10 scale
ggplot(world, aes(x=days, y=confirmed)) + geom_line() +
  labs(title = "Covid-19 Global Confirmed Cases", x= "Days", y= "Daily confirmed cases  (log scale)") +
  theme(plot.title = element_text(hjust = 0.5)) +
  scale_y_continuous(trans="log10")

# Confirmed by country for select countries with counts in log10 scale
countryselection <- country %>% filter(Country.Region==c("US", "Italy", "China", "France", "United Kingdom", "Germany"))
ggplot(countryselection, aes(x=days, y=confirmed, colour=Country.Region)) + geom_line(size=1) +
  labs(title = "Covid-19 Confirmed Cases by Country", x= "Days", y= "Daily confirmed cases (log scale)") +
  theme(plot.title = element_text(hjust = 0.5)) +
  scale_y_continuous(trans="log10")

# Matrix of line graphs of confirmed, deaths and recovered for select countries in log10 scale
countryselection %>% gather("Type", "Cases", -c(date, days, Country.Region)) %>%
  ggplot(aes(x=days, y=Cases, colour=Country.Region)) + geom_line(size=1) +
  labs(title = "Covid-19 Cases by Country", x= "Days", y= "Daily cases (log scale)") +
  theme(plot.title = element_text(hjust = 0.5)) +
  scale_y_continuous(trans="log10") +
  facet_grid(rows=vars(Type))

9.2 Diagramme plotten

Ich möchte Diagramme plotten!

9.2.1 Normalverteilung

Zum Plotten von Normalverteilungen kann man mit der Funktion plot() so vorgehen:

# erstelle Werte von -4 bis 4 in 0.005er-Schritten
x <- seq(-4, 4, by=0.005)

# plotte die Standardnormalverteilung
plot(x,dnorm(x))

# etwas hübscher
plot(x,dnorm(x), col="blue", type="l", xlab="x", ylab="f(x)", main="Standardnormalverteilungen")

# mit Mittelwert 2 und sd = 0,5
plot(x,dnorm(x,mean=2,s=0.5), col="darkblue", type="l", xlab="x", ylab="f(x)", main="Normalverteilungen")

# mit Mittelwert 2 und sd = 2
plot(x,dnorm(x,mean=2,s=2), col="darkorchid", type="l", xlab="x", ylab="f(x)", main="Normalverteilungen")

# erzeuge neue Werte von -3 bis 6
x <- seq(-3,6, by=0.005)

# Alles zusammen plotten
plot(x,dnorm(x,mean=2,s=0.5), col="blue", type="l", xlab="x", ylab="f(x)",main="Normalverteilungen")
lines(x,dnorm(x,mean=0,s=1), col="black")
lines(x,dnorm(x,mean=2,s=2), col="darkorchid")
text(0,.45,"N(0;1)")
text(2.8, 0.6, "N(2;0.5)", col="blue")
text(5, 0.1, "N(2;2)", col="darkorchid")

Mit ggplot kann es so aussehen:

# aktiviere ggplot
library(ggplot2)

# erzeuge Werte von -3 bis 3
x <- seq(-3,3, by=0.005)

# übergebe in ein data.frame 
df <- data.frame(x)

# ggplot erstellen
p <- ggplot(data=df, aes(x)) + 
                     xlim(-4,4) + ylim(0,0.5) + 
                     xlab("x") + ylab("Dichtefunktion") +
                     ggtitle("Normalverteilungen")
p + stat_function(fun=dnorm, args=(c(mean=0,sd=1)), colour="black")+ 
    annotate(geom="text", x=0, y=0.42, label="N(0;1)", color="black")  

# erzeuge Werte von -3 bis 6
x <- seq(-3,6, by=0.005)

# übergebe in ein data.frame 
df <- data.frame(x)

# ggplot erstellen
p <- ggplot(data=df, aes(x)) + 
                     xlim(-3,6) + ylim(0, 0.8) + 
                     xlab("x") + ylab("Dichtefunktion") +
                     ggtitle("Normalverteilungen")
p + stat_function(fun=dnorm, args=(c(mean=0,sd=1)), colour="black")+ 
  annotate(geom="text", x=0, y=0.42, label="N(0;1)", color="black")+ 
  stat_function(fun=dnorm, args=(c(mean=2,sd=0.5)), colour="blue") +
  annotate(geom="text", x=3, y=0.6, label="N(2;0.5)", color="blue")+ 
  stat_function(fun=dnorm, args=(c(mean=2,sd=2)), colour="darkorchid") +
  annotate(geom="text", x=5, y=0.1, label="N(2;2)", color="darkorchid")   

# erzeuge X-Werte
df    <- data.frame(x=seq(-3,3, by=0.005))
# berechne Y-Werte
df$y  <- dnorm(df$x)
# Setze Cuts
df$sd <- cut(df$x, breaks = c(-Inf, 1 *(-2:2), Inf))

# plotte als area
ggplot(df, aes(x, y, fill=sd)) + geom_area()

Erzeugen wir den Bereich von 1 Standardabweichung.

df <- data.frame(x=seq(-3,3, by=0.005))
df$y  <- dnorm(df$x)
df$sd <- cut(df$x, breaks = c(-1,1))
df <- rbind(df, data.frame(x=c(-1, 1), y=c(0,0),sd=c(-1,1)))
df$sd <- forcats::fct_explicit_na(df$sd, na_level="x") 

ggplot(df, aes(x, y, fill=sd)) + 
  ggtitle("Standardnormalverteilung", subtitle = "Bereich von 1 Standardabweichung") +
  geom_area() + theme(legend.position = "none") +
  geom_vline(xintercept=0, linetype="dotted")+
  geom_vline(xintercept=-1, linetype="dashed", col="blue", size=1)+
  geom_vline(xintercept=1, linetype="dashed", col="blue", size=1)+
  scale_fill_manual(name=c("x","(-1,1]"), values=c("skyblue", "snow3"))

Nun erzeugen wir den Bereich von 2 Standardabweichungen.

df    <- data.frame(x=seq(-3,3, by=0.005))
df$y  <- dnorm(df$x)
df$sd <- cut(df$x, breaks = c(-2,2))
df    <- rbind(df, data.frame(x=c(-2, 2), y=c(0,0),sd=c(-2,2)))
df$sd <- forcats::fct_explicit_na(df$sd, na_level="x") 

ggplot(df, aes(x, y, fill=sd)) + 
  ggtitle("Standardnormalverteilung", subtitle = "Bereich von 2 Standardabweichung") +
  geom_area() + theme(legend.position = "none") +
  geom_vline(xintercept=0, linetype="dotted")+  
  geom_vline(xintercept=-2, linetype="dashed", col="purple3", size=1)+
  geom_vline(xintercept=2, linetype="dashed", col="purple3", size=1)+
  scale_fill_manual(name=c("x","(-2,2]"), values=c("purple3", "snow3"))

Erzeugen wir die Fläche, in der 95% der Werte liegen, also von 1,96 Standardabweichungen.

df    <- data.frame(x=seq(-3,3, by=0.005))
df$y  <- dnorm(df$x)
df$sd <- cut(df$x, breaks = c(-1.96, 1.96))
df    <- rbind(df, data.frame(x=c(-1.96, 1.96), y=c(0,0),sd=c(-1.96,1.96)))
df$sd <- forcats::fct_explicit_na(df$sd, na_level="x") 

ggplot(df, aes(x, y, fill=sd)) + 
  ggtitle("Standardnormalverteilung", subtitle = "95% der Werte bei 1,96 sd") +
  geom_area() + theme(legend.position = "none") +
  geom_vline(xintercept=0, linetype="dotted")+
  geom_vline(xintercept=-2, linetype="dotted", col="purple3", size=0.5)+
  geom_vline(xintercept=2, linetype="dotted", col="purple3", size=0.5)+
  geom_vline(xintercept=-1.96, col="chartreuse4", size=0.5)+
  geom_vline(xintercept=1.96, col="chartreuse4", size=0.5)+
  scale_fill_manual(name=c("x","(-1.96,1.96]"), values=c("seagreen3", "snow3"))

Dieser Code kann für die Erzeugung der Grafiken von Tabelle 9.2 und 9.3 verwendet werden.

df    <- data.frame(x=seq(-3,3, by=0.005))
df$y  <- dnorm(df$x)
df$sd <- cut(df$x, breaks = c(-3, 1.4))
df    <- rbind(df, data.frame(x=c(-3, 1.4), y=c(0,0),sd=c(-3,1.4)))
df$sd <- forcats::fct_explicit_na(df$sd, na_level="x") 

ggplot(df, aes(x, y, fill=sd)) + 
  geom_area() + theme(legend.position = "none") +
  geom_vline(xintercept=0, linetype="dotted")+
  geom_vline(xintercept=1.4, col="blue", size=0.5)+
  ylab("") + scale_fill_manual(values=c("skyblue", "snow3"))

df    <- data.frame(x=seq(-3,3, by=0.005))
df$y  <- dnorm(df$x)
df$sd <- cut(df$x, breaks = c(-3, 1.4))
df    <- rbind(df, data.frame(x=c(-3, 1.4), y=c(0,0),sd=c(-3,1.4)))
df$sd <- forcats::fct_explicit_na(df$sd, na_level="x") 

ggplot(df, aes(x, y, fill=sd)) + 
  geom_area() + theme(legend.position = "none") +
  geom_vline(xintercept=0, linetype="dotted")+
  geom_vline(xintercept=1.4, col="blue", size=0.5)+
  ylab("") + scale_fill_manual(values=c("snow3", "skyblue"))

9.2.2 t-Verteilung

Die t-Verteilung kann mit ggplot geplottet werden.

# Erzeuge x-werte
df <- data.frame(x=seq(-3,3, by=0.005))

# Grundlegene Plotangaben
p <- ggplot(data=df, aes(x)) +
  # begrenze die Achsen
  xlim(-3,3) + ylim(0, 0.4) +
  # Achsen-Titel
  xlab("x") + ylab("Dichtefunktion") +
  # Plot-Titel
  ggtitle("t-Verteilungen", subtitle = "nach Freiheitsgraden")

  # t-Verteilung plotten
p + 
  stat_function(fun=dt, args=list(df=1), col="black") +
  # Textfeld hinzufügen
  annotate(geom="text", x=0, y=0.25, label="df=1", color="black")

Dem Plott können weitere Freiheitsgrade hinzugefügt werden.

# t-Verteilungen plotten
p + 
  stat_function(fun=dt, args=list(df=1), col="black") +
  annotate(geom="text", x=0, y=0.25, label="df=1", color="black")+
  stat_function(fun=dt, args=list(df=2), col="blue") +
  annotate(geom="text", x=0, y=0.37, label="df=2", color="blue")

Wenn die t-Werte bereits berechnet wurden, kann eine alternative Vorgehensweise so aussehen:

# berechne t-Werte für Freiheitsgrade 1 bis 5
x=seq(-3,3, by=0.005)
df <- data.frame(
    x,
    df1 = dt(x,df=1), 
    df2 = dt(x,df=2),
    df3 = dt(x,df=3),
    df4 = dt(x,df=4),
    df5 = dt(x,df=5)
)

# wandle ins Format "long table" um
df <- pivot_longer(df, cols=c(df1, df2, df3, df4, df5))

# grundlegende Ploteinstellungen
p <- ggplot(data=df, aes(x,value)) +
  xlim(-3,3) + ylim(0, 0.4) +
  xlab("x") + ylab("Dichtefunktion") +
  ggtitle("t-Verteilungen", subtitle = "nach Freiheitsgraden")

# plotte t-Verteilungen
p + geom_line(aes(col=name))+
  labs(col="Freiheitsgrade")

9.2.3 \(\chi^2\)-Verteilung

Die \(\chi^2\)-Verteilung kann mit ggplot geplottet werden.

# Erzeuge x-werte
x=seq(0,25, by=0.005)
df <- data.frame(  x,
  df01 = dchisq(x, df=1), 
  df05 = dchisq(x, df=5),
  df10 = dchisq(x, df=10),
  df15 = dchisq(x, df=15)
)

# erzeuge long-table
df <- pivot_longer(df, cols=c(df01, df05, df10, df15))

p <- ggplot(data=df, aes(x, value, fill=name)) +
  xlim(0,25) + ylim(0, 0.2) +
  xlab("x") + ylab("Dichtefunktion") +
  ggtitle("Chi^2-Verteilungen", subtitle = "nach Freiheitsgraden")
p + geom_line(aes(col=name,linetype=name))+
labs(col="Freiheitsgrade",linetype="")

Die Fläche unterhalb der Kurve kann mit geom_area() erzeugt werden. Für df=1 lautet der Aufruf:

# erzeuge Dummy-Werte
x=seq(0,25, by=0.005)
# überführe in Datenframe
df <- data.frame(  x, df01 = dchisq(x, df=1))
ggplot(data=df, aes(x, df01)) +
  xlim(0,25)  + coord_cartesian(ylim=c(0, 0.2)) +
  xlab("Chi^2-Wert") + ylab("Dichtefunktion") +
  ggtitle("Chi^2-Verteilung", subtitle = "mit 1 Freiheitsgrad") +   
  geom_line(col="#F8766D") +geom_area(fill="skyblue")

Ähnlich wie bei der Normalverteilung können wir die Fläche für bestimmte \(\chi^2\)-Werte einfärben. Bei einem Freiheitsgrad und \(\alpha=0,05\) ergibt sich ein kritischer \(\chi^2\)-Wert von 3,84. Der Flächenanteil unterhalb dieses Wertes lässt sich wie folgt darstellen:

# Dummy-Werte erzeugen
df <- data.frame(x=seq(0.005,25, by=0.005))
# Chi^2-Werte für df=1 erstellen
df$y  <- dchisq(df$x, df=1)
# Grenze bei 3.84 einziehen
df$sd <- cut(df$x, breaks = c(0.00, 3.84))
ggplot(df, aes(x, y, fill=sd)) + 
  geom_area() + theme(legend.position = "none") + 
  geom_line(aes(col="#F8766D")) +
  xlim(0,25) + coord_cartesian(ylim=c(0, 0.2)) +
  xlab("Chi^2-Wert") + ylab("Dichtefunktion") +
  ggtitle("Chi^2-Verteilung", subtitle = "mit 1 Freiheitsgrad")+
  geom_vline(xintercept=3.84, col="blue", size=0.5, linetype="dashed")+
  ylab("") + scale_fill_manual(values=c("skyblue", "snow3")) +
  annotate(geom="text", x=2, y=0.028, size=8,label="95%", color="blue")

9.2.4 Poisson-Verteilung

Die Poisson-Verteilung kann mit ggplot geplottet werden.

# Erzeuge x-Werte
x=seq(0,25)
df <- data.frame(  x,
                   l1 = dpois(x, 1), 
                   l2 = dpois(x, 2),
                   l4 = dpois(x, 4),
                   l9 = dpois(x, 9)
)

# erzeuge eine long-table
df <- pivot_longer(df, cols=c(l1, l2, l4, l9))

# plot vorbereiten
p <- ggplot(data=df, aes(x, value, fill=name)) +
  xlim(0,17) + ylim(0, 0.4) +
  xlab("x") + ylab("Dichtefunktion") +
  ggtitle("Poisson-Verteilungen", subtitle = "nach Lambda")
p + geom_line(aes(col=name,linetype=name))+
  labs(col="Lambda",linetype="")
## Warning: Removed 32 row(s) containing missing values (geom_path).

Da wir die Plot-Grundlagen in p gespeichert haben, können wir ergänzen:

p + geom_bar(aes(col=name,linetype=name), stat="identity", position="dodge")+
   geom_line(aes(col=name,linetype=name))+
  labs(col="Lambda",linetype="")
## Warning: Removed 36 rows containing missing values (geom_bar).
## Warning: Removed 32 row(s) containing missing values (geom_path).

Möchte man einen Polygonzug, müssen als Ausgangspunkt die Koordinaten (0,0) festegelegt werden.

x=seq(0,25)#, by=0.005)
df <- data.frame(  x=c(0,x),
                   l1 = c(0, dpois(x, 1)), 
                   l2 = c(0, dpois(x, 2)),
                   l4 = c(0, dpois(x, 4)),
                   l9 = c(0, dpois(x, 9))
)
df <- pivot_longer(df, cols=c(l1, l2, l4, l9))

p <- ggplot(data=df, aes(x, value, fill=name)) +
  xlim(0,17) + ylim(0, 0.4) +
  xlab("x") + ylab("Dichtefunktion") +
  ggtitle("Poisson-Verteilungen", subtitle = "nach Lambda")
p + geom_polygon(aes(col=name,linetype=name))+
  geom_line(aes(col=name),linetype="dashed")+
  labs(col="Lambda", fill="Lambda", linetype="Lambda")
## Warning: Removed 32 row(s) containing missing values (geom_path).

9.3 Pakete verwalten

Ich möchte Zusatzpakete verwalten.

9.3.1 Pakete beim Start automatisch laden

Ich möchte, dass Pakete direkt beim Start von R geladen werden.

Legen Sie hierzu in Ihrem Arbeitsverzichnis die Datei .Rprofile an. In diese Datei können Sie alle Befehle schreiben, die beim Start ausgeführt werden sollen. Das geht auch direkt in R:

file.edit(".Rprofile")

# Inhalt von .Rprofile
print("Willkommen zurück!")
print("Ich lade Paket tidyverse")
library(tidyverse)

9.4 RMarkdown

Ich möchte RMarkdown individualisieren.

9.4.1 Ausgabeformat per .css-Datei ändern

Ich möchte die Ausgabe der html-Datei ändern.

Hierfür kann eine css-Datei angelegt werden. Im Kopf des RMarkdown-Dokumentes wird die Datei MeinStyle.css wie folgt eingebunden:

---
title: "Test"
output: 
  html_document:
       css:  MeinStyle.css
---

In der css-Datei können dann wie gewohnt Style-Angaben gemacht werden, z.B. das Aussehen der Codebox. Diese sind über die Parameter class.source (R-Befehle) und class.output (R-Ausgabe) referenzierbar. In der css-Datei definieren wir unsere eigene Klasse “meine” und hinterlegen gewünschte Parameter.

 .meine {
    background-color: rgb(100, 0, 0);
}

Auf diese Klasse können wir in den Chunks verweisen mit

```{r class.output="meine"}
# hier steht der R-Code
```
```{r class.source="meine"}
# hier steht der R-Code
```

Möchte man alle Chunks automatisch auf class.output="meine" setzen, kann dies im YAML-Kopfbereich wie folgt angegeben werden:

knitr::opts_chunk$set(echo = TRUE, class.output="meine")

Es gibt auch vordefinierte Klassen für die Chunks, probieren Sie bg-primary, bg-success, bg-info, bg-warning, und bg-danger aus.

9.5 Referenztabellen erstellen

Ich möchte Referenztabellen erstellen und benötige die Werte.

9.5.1 Fallzahlen nach Effektstärke und Power

Abbildung 9.1: Fallzahlen nach Effektstärke und Power

Der Quellcode für die Werte in Tabelle 9.1 ist etwas komplizierter, da wir zunächst eine Funktion programmieren müssen, um die Tabelle ausgeben zu können.

# lade Paket zur Poweranalyse
library(pwr)
# erzeuge Hilfsfunktion, die nur die errechnete Fallzahl ausgibt
#----------------------------------
powertabelle <- function(alpha, d, power) { round(pwr::pwr.t.test(d = d, sig.level = alpha, power = power, type = "two.sample", alternative = "two.sided")$n)}
# Ende der Funktion


# ein Datenframe aus allen gewünschten Kombinationen
# von power, alpha und d
scen <- expand.grid( alpha = c(0.05, 0.01), 
                    d = seq(from = 0.1, to = 0.8, by = 0.05),
                    power = c(seq(0.6, 0.9, 0.1), 0.95, 0.99)
                )

# füge Datenframe "scen" eine neue Spalte "n" hinzu     
# per apply() wird auf jede Datenreihe die Funktion "powertabelle" angewendet.
# line() hilft dabei, die richtigen Werte aus dem
# Datenframe "scen" an die Funktion "powertabelle" zu übergeben
scen$n <- apply(scen, 1, function(line) powertabelle(line["alpha"], line["d"], line["power"]))

# zeige die ersten 20 Datenreihen an
head(scen, 20)
##    alpha    d power    n
## 1   0.05 0.10   0.6  981
## 2   0.01 0.10   0.6 1603
## 3   0.05 0.15   0.6  436
## 4   0.01 0.15   0.6  713
## 5   0.05 0.20   0.6  246
## 6   0.01 0.20   0.6  402
## 7   0.05 0.25   0.6  158
## 8   0.01 0.25   0.6  258
## 9   0.05 0.30   0.6  110
## 10  0.01 0.30   0.6  180
## 11  0.05 0.35   0.6   81
## 12  0.01 0.35   0.6  132
## 13  0.05 0.40   0.6   62
## 14  0.01 0.40   0.6  102
## 15  0.05 0.45   0.6   49
## 16  0.01 0.45   0.6   81
## 17  0.05 0.50   0.6   40
## 18  0.01 0.50   0.6   66
## 19  0.05 0.55   0.6   33
## 20  0.01 0.55   0.6   55

Jetzt können Teilmengen von scen erstellt werden, um die Werte entsprechend der gewünschten Tabellen (\(\alpha = 0.05\) und \(\alpha = 0.01\)) zu erzeugen.

# erstelle ein subset für "alpha=0.05"
subset05 <- subset(scen, alpha == .05)

# benenne die Spalten um
# und bringe per "reshape" die Tabelle ins "wide"-Format
tabelle05 <- reshape(subset05, v.names = "n", timevar = "d",  idvar = "power", direction = "wide")

# gib tabelle aus
print(tabelle05)
##     alpha power n.0.1 n.0.15 n.0.2 n.0.25 n.0.3 n.0.35 n.0.4 n.0.45 n.0.5
## 1    0.05  0.60   981    436   246    158   110     81    62     49    40
## 31   0.05  0.70  1235    550   310    198   138    102    78     62    50
## 61   0.05  0.80  1571    699   393    252   175    129    99     78    64
## 91   0.05  0.90  2102    935   526    337   234    173   132    105    85
## 121  0.05  0.95  2600   1156   651    417   290    213   163    129   105
## 151  0.05  0.99  3675   1634   920    589   409    301   231    182   148
##     n.0.55 n.0.6 n.0.65 n.0.7 n.0.75 n.0.8
## 1       33    28     24    21     18    16
## 31      42    35     30    26     23    20
## 61      53    45     38    33     29    26
## 91      70    59     51    44     38    34
## 121     87    73     62    54     47    42
## 151    122   103     88    76     66    58
# erstelle ein subset für "alpha=0.01"
subset01 <- subset(scen, alpha == .01)

# benenne die Spalten um
# und bringe per "reshape" die Tabelle ins "wide"-Format
tabelle01 <- reshape(subset01, v.names = "n", timevar = "d",  idvar = "power", direction = "wide")

# gib tabelle aus
print(tabelle01)
##     alpha power n.0.1 n.0.15 n.0.2 n.0.25 n.0.3 n.0.35 n.0.4 n.0.45 n.0.5
## 2    0.01  0.60  1603    713   402    258   180    132   102     81    66
## 32   0.01  0.70  1924    856   482    309   215    159   122     97    79
## 62   0.01  0.80  2337   1040   586    375   261    192   148    117    95
## 92   0.01  0.90  2978   1324   746    478   332    245   188    149   121
## 122  0.01  0.95  3564   1585   892    572   398    293   224    178   144
## 152  0.01  0.99  4808   2138  1203    771   536    394   302    239   194
##     n.0.55 n.0.6 n.0.65 n.0.7 n.0.75 n.0.8
## 2       55    46     40    34     30    27
## 32      65    55     47    41     36    32
## 62      79    67     57    49     43    38
## 92     100    84     72    62     55    48
## 122    119   101     86    74     65    57
## 152    161   135    115   100     87    77

Wenn Sie den Abschnitt über Tidy Data in Kapitel 6 gelesen haben, ist Ihnen evtl. aufgefallen, dass wir hier eine long table in eine wide table umgeformt haben. Das erwähne ich deshalb, da wir sonst immer genau das Gegenteil machen, nämlich wide table ins Format long table zu überführen.

Übrigens, die PDF-Version dieses Buch ist mit LaTeX erstellt worden, und ich hatte keine Lust, die Werte für die Tabellen von Hand in LaTeX zu übertragen.

Mit der Funktion xtable() aus dem Zusatzpaket xtable kann die Ausgabe der Tabelle in LaTeX-Quellcode erfolgen:

# lade Paket "xtable"
library(xtable)

# gib die Tabelle als LaTeX-Code aus 
xtable(tabelle01)
## % latex table generated in R 4.1.1 by xtable 1.8-4 package
## % Tue Aug 31 09:48:34 2021
## \begin{table}[ht]
## \centering
## \begin{tabular}{rrrrrrrrrrrrrrrrrr}
##   \hline
##  & alpha & power & n.0.1 & n.0.15 & n.0.2 & n.0.25 & n.0.3 & n.0.35 & n.0.4 & n.0.45 & n.0.5 & n.0.55 & n.0.6 & n.0.65 & n.0.7 & n.0.75 & n.0.8 \\ 
##   \hline
## 2 & 0.01 & 0.60 & 1603.00 & 713.00 & 402.00 & 258.00 & 180.00 & 132.00 & 102.00 & 81.00 & 66.00 & 55.00 & 46.00 & 40.00 & 34.00 & 30.00 & 27.00 \\ 
##   32 & 0.01 & 0.70 & 1924.00 & 856.00 & 482.00 & 309.00 & 215.00 & 159.00 & 122.00 & 97.00 & 79.00 & 65.00 & 55.00 & 47.00 & 41.00 & 36.00 & 32.00 \\ 
##   62 & 0.01 & 0.80 & 2337.00 & 1040.00 & 586.00 & 375.00 & 261.00 & 192.00 & 148.00 & 117.00 & 95.00 & 79.00 & 67.00 & 57.00 & 49.00 & 43.00 & 38.00 \\ 
##   92 & 0.01 & 0.90 & 2978.00 & 1324.00 & 746.00 & 478.00 & 332.00 & 245.00 & 188.00 & 149.00 & 121.00 & 100.00 & 84.00 & 72.00 & 62.00 & 55.00 & 48.00 \\ 
##   122 & 0.01 & 0.95 & 3564.00 & 1585.00 & 892.00 & 572.00 & 398.00 & 293.00 & 224.00 & 178.00 & 144.00 & 119.00 & 101.00 & 86.00 & 74.00 & 65.00 & 57.00 \\ 
##   152 & 0.01 & 0.99 & 4808.00 & 2138.00 & 1203.00 & 771.00 & 536.00 & 394.00 & 302.00 & 239.00 & 194.00 & 161.00 & 135.00 & 115.00 & 100.00 & 87.00 & 77.00 \\ 
##    \hline
## \end{tabular}
## \end{table}


9.5.2 Verteilungsfunktion und Quantile der Standardnormalverteilung

Ich möchte die Werte dieser Tabelle:

Verteilungsfunktion und Quantile der Standardnormalverteilung
\(\phi\) z .00 .01 .02 .03 .04 .05 .06 .07 .08 .09
0.0 .5000 .5040 .5080 .5120 .5160 .5199 .5239 .5279 .5319 .5359
0.1 .5398 .5438 .5478 .5517 .5557 .5596 .5636 .5675 .5714 .5753
0.2 .5793 .5832 .5871 .5910 .5948 .5987 .6026 .6064 .6103 .6141
0.3 .6179 .6217 .6255 .6293 .6331 .6368 .6406 .6443 .6480 .6517
0.4 .6554 .6591 .6628 .6664 .6700 .6736 .6772 .6808 .6844 .6879
0.5 .6915 .6950 .6985 .7019 .7054 .7088 .7123 .7157 .7190 .7224
0.6 .7257 .7291 .7324 .7357 .7389 .7422 .7454 .7486 .7517 .7549
0.7 .7580 .7611 .7642 .7673 .7704 .7734 .7764 .7794 .7823 .7852
0.8 .7881 .7910 .7939 .7967 .7995 .8023 .8051 .8078 .8106 .8133
0.9 .8159 .8186 .8212 .8238 .8264 .8289 .8315 .8340 .8365 .8389
1.0 .8413 .8438 .8461 .8485 .8508 .8531 .8554 .8577 .8599 .8621
1.1 .8643 .8665 .8686 .8708 .8729 .8749 .8770 .8790 .8810 .8830
1.2 .8849 .8869 .8888 .8907 .8925 .8944 .8962 .8980 .8997 .9015
1.3 .9032 .9049 .9066 .9082 .9099 .9115 .9131 .9147 .9162 .9177
1.4 .9192 .9207 .9222 .9236 .9251 .9265 .9279 .9292 .9306 .9319
1.5 .9332 .9345 .9357 .9370 .9382 .9394 .9406 .9418 .9429 .9441
1.6 .9452 .9463 .9474 .9484 .9495 .9505 .9515 .9525 .9535 .9545
1.7 .9554 .9564 .9573 .9582 .9591 .9599 .9608 .9616 .9625 .9633
1.8 .9641 .9649 .9656 .9664 .9671 .9678 .9686 .9693 .9699 .9706
1.9 .9713 .9719 .9726 .9732 .9738 .9744 .9750 .9756 .9761 .9767
2.0 .9772 .9778 .9783 .9788 .9793 .9798 .9803 .9808 .9812 .9817
2.1 .9821 .9826 .9830 .9834 .9838 .9842 .9846 .9850 .9854 .9857
2.2 .9861 .9864 .9868 .9871 .9875 .9878 .9881 .9884 .9887 .9890
2.3 .9893 .9896 .9898 .9901 .9904 .9906 .9909 .9911 .9913 .9916
2.4 .9918 .9920 .9922 .9925 .9927 .9929 .9931 .9932 .9934 .9936
2.5 .9938 .9940 .9941 .9943 .9945 .9946 .9948 .9949 .9951 .9952
2.6 .9953 .9955 .9956 .9957 .9959 .9960 .9961 .9962 .9963 .9964
2.7 .9965 .9966 .9967 .9968 .9969 .9970 .9971 .9972 .9973 .9974
2.8 .9974 .9975 .9976 .9977 .9977 .9978 .9979 .9979 .9980 .9981
2.9 .9981 .9982 .9982 .9983 .9984 .9984 .9985 .9985 .9986 .9986
3.0 .9987 .9987 .9987 .9988 .9988 .9989 .9989 .9989 .9990 .9990
p = .5000 .7500 .8000 .9000 .9500 .9750 .9900 .9950 .9975 .9990
\(z_p\) = 0.0000 0.6745 0.8416 1.2816 1.6449 1.9600 2.3263 2.5758 2.8070 3.0902

Bei der z-Transformation benötigt man die Werte dieser Tabelle beispielsweise für Fragen wie “Wie hoch ist der prozentuale Anteil für Werte, die mindestens X sind

Verteilungsfunktion und Quantile der Standardnormalverteilung

Abbildung 9.2: Verteilungsfunktion und Quantile der Standardnormalverteilung

Die Werte werden erzeugt mit:

# erstelle Werte von 0.00 bis 3.09
z <- seq(from=0, to=3.09, by = 0.01)

# P-Werte berechnen
pnorm(z)
##   [1] 0.5000000 0.5039894 0.5079783 0.5119665 0.5159534 0.5199388 0.5239222
##   [8] 0.5279032 0.5318814 0.5358564 0.5398278 0.5437953 0.5477584 0.5517168
##  [15] 0.5556700 0.5596177 0.5635595 0.5674949 0.5714237 0.5753454 0.5792597
##  [22] 0.5831662 0.5870644 0.5909541 0.5948349 0.5987063 0.6025681 0.6064199
##  [29] 0.6102612 0.6140919 0.6179114 0.6217195 0.6255158 0.6293000 0.6330717
##  [36] 0.6368307 0.6405764 0.6443088 0.6480273 0.6517317 0.6554217 0.6590970
##  [43] 0.6627573 0.6664022 0.6700314 0.6736448 0.6772419 0.6808225 0.6843863
##  [50] 0.6879331 0.6914625 0.6949743 0.6984682 0.7019440 0.7054015 0.7088403
##  [57] 0.7122603 0.7156612 0.7190427 0.7224047 0.7257469 0.7290691 0.7323711
##  [64] 0.7356527 0.7389137 0.7421539 0.7453731 0.7485711 0.7517478 0.7549029
##  [71] 0.7580363 0.7611479 0.7642375 0.7673049 0.7703500 0.7733726 0.7763727
##  [78] 0.7793501 0.7823046 0.7852361 0.7881446 0.7910299 0.7938919 0.7967306
##  [85] 0.7995458 0.8023375 0.8051055 0.8078498 0.8105703 0.8132671 0.8159399
##  [92] 0.8185887 0.8212136 0.8238145 0.8263912 0.8289439 0.8314724 0.8339768
##  [99] 0.8364569 0.8389129 0.8413447 0.8437524 0.8461358 0.8484950 0.8508300
## [106] 0.8531409 0.8554277 0.8576903 0.8599289 0.8621434 0.8643339 0.8665005
## [113] 0.8686431 0.8707619 0.8728568 0.8749281 0.8769756 0.8789995 0.8809999
## [120] 0.8829768 0.8849303 0.8868606 0.8887676 0.8906514 0.8925123 0.8943502
## [127] 0.8961653 0.8979577 0.8997274 0.9014747 0.9031995 0.9049021 0.9065825
## [134] 0.9082409 0.9098773 0.9114920 0.9130850 0.9146565 0.9162067 0.9177356
## [141] 0.9192433 0.9207302 0.9221962 0.9236415 0.9250663 0.9264707 0.9278550
## [148] 0.9292191 0.9305634 0.9318879 0.9331928 0.9344783 0.9357445 0.9369916
## [155] 0.9382198 0.9394292 0.9406201 0.9417924 0.9429466 0.9440826 0.9452007
## [162] 0.9463011 0.9473839 0.9484493 0.9494974 0.9505285 0.9515428 0.9525403
## [169] 0.9535213 0.9544860 0.9554345 0.9563671 0.9572838 0.9581849 0.9590705
## [176] 0.9599408 0.9607961 0.9616364 0.9624620 0.9632730 0.9640697 0.9648521
## [183] 0.9656205 0.9663750 0.9671159 0.9678432 0.9685572 0.9692581 0.9699460
## [190] 0.9706210 0.9712834 0.9719334 0.9725711 0.9731966 0.9738102 0.9744119
## [197] 0.9750021 0.9755808 0.9761482 0.9767045 0.9772499 0.9777844 0.9783083
## [204] 0.9788217 0.9793248 0.9798178 0.9803007 0.9807738 0.9812372 0.9816911
## [211] 0.9821356 0.9825708 0.9829970 0.9834142 0.9838226 0.9842224 0.9846137
## [218] 0.9849966 0.9853713 0.9857379 0.9860966 0.9864474 0.9867906 0.9871263
## [225] 0.9874545 0.9877755 0.9880894 0.9883962 0.9886962 0.9889893 0.9892759
## [232] 0.9895559 0.9898296 0.9900969 0.9903581 0.9906133 0.9908625 0.9911060
## [239] 0.9913437 0.9915758 0.9918025 0.9920237 0.9922397 0.9924506 0.9926564
## [246] 0.9928572 0.9930531 0.9932443 0.9934309 0.9936128 0.9937903 0.9939634
## [253] 0.9941323 0.9942969 0.9944574 0.9946139 0.9947664 0.9949151 0.9950600
## [260] 0.9952012 0.9953388 0.9954729 0.9956035 0.9957308 0.9958547 0.9959754
## [267] 0.9960930 0.9962074 0.9963189 0.9964274 0.9965330 0.9966358 0.9967359
## [274] 0.9968333 0.9969280 0.9970202 0.9971099 0.9971972 0.9972821 0.9973646
## [281] 0.9974449 0.9975229 0.9975988 0.9976726 0.9977443 0.9978140 0.9978818
## [288] 0.9979476 0.9980116 0.9980738 0.9981342 0.9981929 0.9982498 0.9983052
## [295] 0.9983589 0.9984111 0.9984618 0.9985110 0.9985588 0.9986051 0.9986501
## [302] 0.9986938 0.9987361 0.9987772 0.9988171 0.9988558 0.9988933 0.9989297
## [309] 0.9989650 0.9989992
# In Matrix mit 10 Spalten übertragen
matrix(pnorm(z),ncol=10, byrow=TRUE)
##            [,1]      [,2]      [,3]      [,4]      [,5]      [,6]      [,7]
##  [1,] 0.5000000 0.5039894 0.5079783 0.5119665 0.5159534 0.5199388 0.5239222
##  [2,] 0.5398278 0.5437953 0.5477584 0.5517168 0.5556700 0.5596177 0.5635595
##  [3,] 0.5792597 0.5831662 0.5870644 0.5909541 0.5948349 0.5987063 0.6025681
##  [4,] 0.6179114 0.6217195 0.6255158 0.6293000 0.6330717 0.6368307 0.6405764
##  [5,] 0.6554217 0.6590970 0.6627573 0.6664022 0.6700314 0.6736448 0.6772419
##  [6,] 0.6914625 0.6949743 0.6984682 0.7019440 0.7054015 0.7088403 0.7122603
##  [7,] 0.7257469 0.7290691 0.7323711 0.7356527 0.7389137 0.7421539 0.7453731
##  [8,] 0.7580363 0.7611479 0.7642375 0.7673049 0.7703500 0.7733726 0.7763727
##  [9,] 0.7881446 0.7910299 0.7938919 0.7967306 0.7995458 0.8023375 0.8051055
## [10,] 0.8159399 0.8185887 0.8212136 0.8238145 0.8263912 0.8289439 0.8314724
## [11,] 0.8413447 0.8437524 0.8461358 0.8484950 0.8508300 0.8531409 0.8554277
## [12,] 0.8643339 0.8665005 0.8686431 0.8707619 0.8728568 0.8749281 0.8769756
## [13,] 0.8849303 0.8868606 0.8887676 0.8906514 0.8925123 0.8943502 0.8961653
## [14,] 0.9031995 0.9049021 0.9065825 0.9082409 0.9098773 0.9114920 0.9130850
## [15,] 0.9192433 0.9207302 0.9221962 0.9236415 0.9250663 0.9264707 0.9278550
## [16,] 0.9331928 0.9344783 0.9357445 0.9369916 0.9382198 0.9394292 0.9406201
## [17,] 0.9452007 0.9463011 0.9473839 0.9484493 0.9494974 0.9505285 0.9515428
## [18,] 0.9554345 0.9563671 0.9572838 0.9581849 0.9590705 0.9599408 0.9607961
## [19,] 0.9640697 0.9648521 0.9656205 0.9663750 0.9671159 0.9678432 0.9685572
## [20,] 0.9712834 0.9719334 0.9725711 0.9731966 0.9738102 0.9744119 0.9750021
## [21,] 0.9772499 0.9777844 0.9783083 0.9788217 0.9793248 0.9798178 0.9803007
## [22,] 0.9821356 0.9825708 0.9829970 0.9834142 0.9838226 0.9842224 0.9846137
## [23,] 0.9860966 0.9864474 0.9867906 0.9871263 0.9874545 0.9877755 0.9880894
## [24,] 0.9892759 0.9895559 0.9898296 0.9900969 0.9903581 0.9906133 0.9908625
## [25,] 0.9918025 0.9920237 0.9922397 0.9924506 0.9926564 0.9928572 0.9930531
## [26,] 0.9937903 0.9939634 0.9941323 0.9942969 0.9944574 0.9946139 0.9947664
## [27,] 0.9953388 0.9954729 0.9956035 0.9957308 0.9958547 0.9959754 0.9960930
## [28,] 0.9965330 0.9966358 0.9967359 0.9968333 0.9969280 0.9970202 0.9971099
## [29,] 0.9974449 0.9975229 0.9975988 0.9976726 0.9977443 0.9978140 0.9978818
## [30,] 0.9981342 0.9981929 0.9982498 0.9983052 0.9983589 0.9984111 0.9984618
## [31,] 0.9986501 0.9986938 0.9987361 0.9987772 0.9988171 0.9988558 0.9988933
##            [,8]      [,9]     [,10]
##  [1,] 0.5279032 0.5318814 0.5358564
##  [2,] 0.5674949 0.5714237 0.5753454
##  [3,] 0.6064199 0.6102612 0.6140919
##  [4,] 0.6443088 0.6480273 0.6517317
##  [5,] 0.6808225 0.6843863 0.6879331
##  [6,] 0.7156612 0.7190427 0.7224047
##  [7,] 0.7485711 0.7517478 0.7549029
##  [8,] 0.7793501 0.7823046 0.7852361
##  [9,] 0.8078498 0.8105703 0.8132671
## [10,] 0.8339768 0.8364569 0.8389129
## [11,] 0.8576903 0.8599289 0.8621434
## [12,] 0.8789995 0.8809999 0.8829768
## [13,] 0.8979577 0.8997274 0.9014747
## [14,] 0.9146565 0.9162067 0.9177356
## [15,] 0.9292191 0.9305634 0.9318879
## [16,] 0.9417924 0.9429466 0.9440826
## [17,] 0.9525403 0.9535213 0.9544860
## [18,] 0.9616364 0.9624620 0.9632730
## [19,] 0.9692581 0.9699460 0.9706210
## [20,] 0.9755808 0.9761482 0.9767045
## [21,] 0.9807738 0.9812372 0.9816911
## [22,] 0.9849966 0.9853713 0.9857379
## [23,] 0.9883962 0.9886962 0.9889893
## [24,] 0.9911060 0.9913437 0.9915758
## [25,] 0.9932443 0.9934309 0.9936128
## [26,] 0.9949151 0.9950600 0.9952012
## [27,] 0.9962074 0.9963189 0.9964274
## [28,] 0.9971972 0.9972821 0.9973646
## [29,] 0.9979476 0.9980116 0.9980738
## [30,] 0.9985110 0.9985588 0.9986051
## [31,] 0.9989297 0.9989650 0.9989992
# auf 4 Stellen runden
matrix(round(pnorm(z),4),ncol=10, byrow=TRUE)
##         [,1]   [,2]   [,3]   [,4]   [,5]   [,6]   [,7]   [,8]   [,9]  [,10]
##  [1,] 0.5000 0.5040 0.5080 0.5120 0.5160 0.5199 0.5239 0.5279 0.5319 0.5359
##  [2,] 0.5398 0.5438 0.5478 0.5517 0.5557 0.5596 0.5636 0.5675 0.5714 0.5753
##  [3,] 0.5793 0.5832 0.5871 0.5910 0.5948 0.5987 0.6026 0.6064 0.6103 0.6141
##  [4,] 0.6179 0.6217 0.6255 0.6293 0.6331 0.6368 0.6406 0.6443 0.6480 0.6517
##  [5,] 0.6554 0.6591 0.6628 0.6664 0.6700 0.6736 0.6772 0.6808 0.6844 0.6879
##  [6,] 0.6915 0.6950 0.6985 0.7019 0.7054 0.7088 0.7123 0.7157 0.7190 0.7224
##  [7,] 0.7257 0.7291 0.7324 0.7357 0.7389 0.7422 0.7454 0.7486 0.7517 0.7549
##  [8,] 0.7580 0.7611 0.7642 0.7673 0.7704 0.7734 0.7764 0.7794 0.7823 0.7852
##  [9,] 0.7881 0.7910 0.7939 0.7967 0.7995 0.8023 0.8051 0.8078 0.8106 0.8133
## [10,] 0.8159 0.8186 0.8212 0.8238 0.8264 0.8289 0.8315 0.8340 0.8365 0.8389
## [11,] 0.8413 0.8438 0.8461 0.8485 0.8508 0.8531 0.8554 0.8577 0.8599 0.8621
## [12,] 0.8643 0.8665 0.8686 0.8708 0.8729 0.8749 0.8770 0.8790 0.8810 0.8830
## [13,] 0.8849 0.8869 0.8888 0.8907 0.8925 0.8944 0.8962 0.8980 0.8997 0.9015
## [14,] 0.9032 0.9049 0.9066 0.9082 0.9099 0.9115 0.9131 0.9147 0.9162 0.9177
## [15,] 0.9192 0.9207 0.9222 0.9236 0.9251 0.9265 0.9279 0.9292 0.9306 0.9319
## [16,] 0.9332 0.9345 0.9357 0.9370 0.9382 0.9394 0.9406 0.9418 0.9429 0.9441
## [17,] 0.9452 0.9463 0.9474 0.9484 0.9495 0.9505 0.9515 0.9525 0.9535 0.9545
## [18,] 0.9554 0.9564 0.9573 0.9582 0.9591 0.9599 0.9608 0.9616 0.9625 0.9633
## [19,] 0.9641 0.9649 0.9656 0.9664 0.9671 0.9678 0.9686 0.9693 0.9699 0.9706
## [20,] 0.9713 0.9719 0.9726 0.9732 0.9738 0.9744 0.9750 0.9756 0.9761 0.9767
## [21,] 0.9772 0.9778 0.9783 0.9788 0.9793 0.9798 0.9803 0.9808 0.9812 0.9817
## [22,] 0.9821 0.9826 0.9830 0.9834 0.9838 0.9842 0.9846 0.9850 0.9854 0.9857
## [23,] 0.9861 0.9864 0.9868 0.9871 0.9875 0.9878 0.9881 0.9884 0.9887 0.9890
## [24,] 0.9893 0.9896 0.9898 0.9901 0.9904 0.9906 0.9909 0.9911 0.9913 0.9916
## [25,] 0.9918 0.9920 0.9922 0.9925 0.9927 0.9929 0.9931 0.9932 0.9934 0.9936
## [26,] 0.9938 0.9940 0.9941 0.9943 0.9945 0.9946 0.9948 0.9949 0.9951 0.9952
## [27,] 0.9953 0.9955 0.9956 0.9957 0.9959 0.9960 0.9961 0.9962 0.9963 0.9964
## [28,] 0.9965 0.9966 0.9967 0.9968 0.9969 0.9970 0.9971 0.9972 0.9973 0.9974
## [29,] 0.9974 0.9975 0.9976 0.9977 0.9977 0.9978 0.9979 0.9979 0.9980 0.9981
## [30,] 0.9981 0.9982 0.9982 0.9983 0.9984 0.9984 0.9985 0.9985 0.9986 0.9986
## [31,] 0.9987 0.9987 0.9987 0.9988 0.9988 0.9989 0.9989 0.9989 0.9990 0.9990
# In Dataframe übertragen
tabelle1 <- data.frame(matrix(round(pnorm(z),4),ncol=10, byrow=TRUE))
# benenne die Spalten
colnames(tabelle1) <- c(seq(0.00, 0.09, 0.01))
# benenne die Zeilen
row.names(tabelle1) <- c(seq(0, 3, 0.1))
# gib fertige Tabelle aus
tabelle1
##          0   0.01   0.02   0.03   0.04   0.05   0.06   0.07   0.08   0.09
## 0   0.5000 0.5040 0.5080 0.5120 0.5160 0.5199 0.5239 0.5279 0.5319 0.5359
## 0.1 0.5398 0.5438 0.5478 0.5517 0.5557 0.5596 0.5636 0.5675 0.5714 0.5753
## 0.2 0.5793 0.5832 0.5871 0.5910 0.5948 0.5987 0.6026 0.6064 0.6103 0.6141
## 0.3 0.6179 0.6217 0.6255 0.6293 0.6331 0.6368 0.6406 0.6443 0.6480 0.6517
## 0.4 0.6554 0.6591 0.6628 0.6664 0.6700 0.6736 0.6772 0.6808 0.6844 0.6879
## 0.5 0.6915 0.6950 0.6985 0.7019 0.7054 0.7088 0.7123 0.7157 0.7190 0.7224
## 0.6 0.7257 0.7291 0.7324 0.7357 0.7389 0.7422 0.7454 0.7486 0.7517 0.7549
## 0.7 0.7580 0.7611 0.7642 0.7673 0.7704 0.7734 0.7764 0.7794 0.7823 0.7852
## 0.8 0.7881 0.7910 0.7939 0.7967 0.7995 0.8023 0.8051 0.8078 0.8106 0.8133
## 0.9 0.8159 0.8186 0.8212 0.8238 0.8264 0.8289 0.8315 0.8340 0.8365 0.8389
## 1   0.8413 0.8438 0.8461 0.8485 0.8508 0.8531 0.8554 0.8577 0.8599 0.8621
## 1.1 0.8643 0.8665 0.8686 0.8708 0.8729 0.8749 0.8770 0.8790 0.8810 0.8830
## 1.2 0.8849 0.8869 0.8888 0.8907 0.8925 0.8944 0.8962 0.8980 0.8997 0.9015
## 1.3 0.9032 0.9049 0.9066 0.9082 0.9099 0.9115 0.9131 0.9147 0.9162 0.9177
## 1.4 0.9192 0.9207 0.9222 0.9236 0.9251 0.9265 0.9279 0.9292 0.9306 0.9319
## 1.5 0.9332 0.9345 0.9357 0.9370 0.9382 0.9394 0.9406 0.9418 0.9429 0.9441
## 1.6 0.9452 0.9463 0.9474 0.9484 0.9495 0.9505 0.9515 0.9525 0.9535 0.9545
## 1.7 0.9554 0.9564 0.9573 0.9582 0.9591 0.9599 0.9608 0.9616 0.9625 0.9633
## 1.8 0.9641 0.9649 0.9656 0.9664 0.9671 0.9678 0.9686 0.9693 0.9699 0.9706
## 1.9 0.9713 0.9719 0.9726 0.9732 0.9738 0.9744 0.9750 0.9756 0.9761 0.9767
## 2   0.9772 0.9778 0.9783 0.9788 0.9793 0.9798 0.9803 0.9808 0.9812 0.9817
## 2.1 0.9821 0.9826 0.9830 0.9834 0.9838 0.9842 0.9846 0.9850 0.9854 0.9857
## 2.2 0.9861 0.9864 0.9868 0.9871 0.9875 0.9878 0.9881 0.9884 0.9887 0.9890
## 2.3 0.9893 0.9896 0.9898 0.9901 0.9904 0.9906 0.9909 0.9911 0.9913 0.9916
## 2.4 0.9918 0.9920 0.9922 0.9925 0.9927 0.9929 0.9931 0.9932 0.9934 0.9936
## 2.5 0.9938 0.9940 0.9941 0.9943 0.9945 0.9946 0.9948 0.9949 0.9951 0.9952
## 2.6 0.9953 0.9955 0.9956 0.9957 0.9959 0.9960 0.9961 0.9962 0.9963 0.9964
## 2.7 0.9965 0.9966 0.9967 0.9968 0.9969 0.9970 0.9971 0.9972 0.9973 0.9974
## 2.8 0.9974 0.9975 0.9976 0.9977 0.9977 0.9978 0.9979 0.9979 0.9980 0.9981
## 2.9 0.9981 0.9982 0.9982 0.9983 0.9984 0.9984 0.9985 0.9985 0.9986 0.9986
## 3   0.9987 0.9987 0.9987 0.9988 0.9988 0.9989 0.9989 0.9989 0.9990 0.9990


Im Gegensatz zu Tabelle 9.2 zeigt Tabelle 9.3 die Überschreitungswahrscheinlichkeiten \(P\) für Abszissenwerte \(z\) der Standardnormalverteilung (\(\mu=0\) und \(\sigma=1\)).

Die p-Werte entsprechen der Fläche unter der Standardnormalverteilung zwischen \(z\) und \(+\infty\) und damit einer einseitigen Fragestellung. Sie müssen bei zweiseitigen Fragestellungen verdoppelt werden!

Überschreitungswahrscheinlichkeiten P für Abszissenwerte z der Standardnormalverteilung {#test}
\(\phi\) z .00 .01 .02 .03 .04 .05 .06 .07 .08 .09
0.0 .5000 .4960 .4920 .4880 .4840 .4801 .4761 .4721 .4681 .4641
0.1 .4602 .4562 .4522 .4483 .4443 .4404 .4364 .4325 .4286 .4247
0.2 .4207 .4168 .4129 .4090 .4052 .4013 .3974 .3936 .3897 .3859
0.3 .3821 .3783 .3745 .3707 .3669 .3632 .3594 .3557 .3520 .3483
0.4 .3446 .3409 .3372 .3336 .3300 .3264 .3228 .3192 .3156 .3121
0.5 .3085 .3050 .3015 .2981 .2946 .2912 .2887 .2843 .2810 .2776
0.6 .2743 .2709 .2676 .2643 .2611 .2578 .2546 .2514 .2483 .2451
0.7 .2420 .2389 .2358 .2327 .2296 .2266 .2236 .2206 .2177 .2148
0.8 .2119 .2090 .2061 .2033 .2005 .1977 .1949 .1922 .1894 .1867
0.9 .1841 .1814 .1788 .1762 .1736 .1711 .1685 .1660 .1635 .1611
1.0 .1587 .1562 .1539 .1515 .1492 .1469 .1464 .1423 .1401 .1379
1.1 .1357 .1335 .1314 .1291 .1271 .1251 .1230 .1210 .1190 .1170
1.2 .1151 .1131 .1112 .1093 .1075 .1056 .1038 .1020 .1003 .0985
1.3 .0968 .0951 .0934 .0918 .0901 .0885 .0869 .0853 .0838 .0823
1.4 .0808 .0793 .0778 .0764 .0749 .0735 .0721 .0708 .0694 .0681
1.5 .0668 .0655 .0643 .0630 .0618 .0606 .0594 .0582 .0571 .0559
1.6 .0548 .0537 .0526 .0516 .0505 .0495 .0485 .0475 .0465 .0455
1.7 .0446 .0436 .0427 .0418 .0409 .0401 .0392 .0384 .0375 .0367
1.8 .0359 .0351 .0344 .0336 .0329 .0322 .0314 .0307 .0301 .0294
1.9 .0287 .0281 .0274 .0268 .0262 .0256 .0250 .0244 .0239 .0233
2.0 .0228 .0222 .0217 .0212 .0207 .0202 .0197 .0192 .0188 .0183
2.1 .0179 .0174 .0170 .0166 .0162 .0158 .0154 .0150 .0146 .0143
2.2 .0139 .0136 .0132 .0129 .0125 .0122 .0119 .0116 .0113 .0110
2.3 .0107 .0104 .0102 .0099 .0096 .0094 .0091 .0089 .0087 .0084
2.4 .0082 .0080 .0078 .0075 .0073 .0071 .0069 .0068 .0066 .0064
2.5 .0062 .0060 .0059 .0057 .0055 .0054 .0052 .0051 .0049 .0048
2.6 .0047 .0045 .0044 .0043 .0041 .0040 .0039 .0038 .0037 .0036
2.7 .0035 .0034 .0033 .0032 .0031 .0030 .0029 .0028 .0027 .0026
2.8 .0026 .0025 .0024 .0023 .0023 .0022 .0021 .0021 .0020 .0019
2.9 .0019 .0018 .0018 .0017 .0016 .0016 .0015 .0015 .0014 .0014
3.0 .0013 .0013 .0013 .0012 .0012 .0011 .0011 .0011 .0010 .0010
p = .5000 .7500 .8000 .9000 .9500 .9750 .9900 .9950 .9975 .9990
\(z_p\) = 0.0000 0.6745 0.8416 1.2816 1.6449 1.9600 2.3263 2.5758 2.8070 3.0902

Bei der z-Transformation benötigt man die Werte dieser Tabelle beispielsweise für Fragen wie “Wie hoch ist der prozentuale Anteil für Werte, die mindestens X sind

Überschreitungswahrscheinlichkeiten P für Abszissenwerte z

Abbildung 9.3: Überschreitungswahrscheinlichkeiten P für Abszissenwerte z

Die Werte werden erzeugt mit:

# erstelle Werte von 0.00 bis 3.09
z <- seq(from=0, to=3.09, by = 0.01)

# P-Werte berechnen
1 - pnorm(z)
##   [1] 0.500000000 0.496010644 0.492021686 0.488033527 0.484046563 0.480061194
##   [7] 0.476077817 0.472096830 0.468118628 0.464143607 0.460172163 0.456204687
##  [13] 0.452241574 0.448283213 0.444329995 0.440382308 0.436440537 0.432505068
##  [19] 0.428576284 0.424654565 0.420740291 0.416833837 0.412935577 0.409045885
##  [25] 0.405165128 0.401293674 0.397431887 0.393580127 0.389738752 0.385908119
##  [31] 0.382088578 0.378280478 0.374484165 0.370699981 0.366928264 0.363169349
##  [37] 0.359423567 0.355691245 0.351972708 0.348268273 0.344578258 0.340902974
##  [43] 0.337242727 0.333597821 0.329968554 0.326355220 0.322758110 0.319177509
##  [49] 0.315613697 0.312066949 0.308537539 0.305025731 0.301531788 0.298055965
##  [55] 0.294598516 0.291159687 0.287739719 0.284338849 0.280957309 0.277595325
##  [61] 0.274253118 0.270930904 0.267628893 0.264347292 0.261086300 0.257846111
##  [67] 0.254626915 0.251428895 0.248252230 0.245097094 0.241963652 0.238852068
##  [73] 0.235762498 0.232695092 0.229649997 0.226627352 0.223627292 0.220649946
##  [79] 0.217695438 0.214763884 0.211855399 0.208970088 0.206108054 0.203269392
##  [85] 0.200454193 0.197662543 0.194894521 0.192150202 0.189429655 0.186732943
##  [91] 0.184060125 0.181411255 0.178786380 0.176185542 0.173608780 0.171056126
##  [97] 0.168527607 0.166023246 0.163543059 0.161087060 0.158655254 0.156247645
## [103] 0.153864230 0.151505003 0.149169950 0.146859056 0.144572300 0.142309654
## [109] 0.140071090 0.137856572 0.135666061 0.133499513 0.131356881 0.129238112
## [115] 0.127143151 0.125071936 0.123024403 0.121000484 0.119000107 0.117023196
## [121] 0.115069670 0.113139446 0.111232437 0.109348552 0.107487697 0.105649774
## [127] 0.103834681 0.102042315 0.100272568 0.098525329 0.096800485 0.095097918
## [133] 0.093417509 0.091759136 0.090122672 0.088507991 0.086914962 0.085343451
## [139] 0.083793322 0.082264439 0.080756659 0.079269841 0.077803841 0.076358510
## [145] 0.074933700 0.073529260 0.072145037 0.070780877 0.069436623 0.068112118
## [151] 0.066807201 0.065521712 0.064255488 0.063008364 0.061780177 0.060570758
## [157] 0.059379941 0.058207556 0.057053433 0.055917403 0.054799292 0.053698928
## [163] 0.052616138 0.051550748 0.050502583 0.049471468 0.048457226 0.047459682
## [169] 0.046478658 0.045513977 0.044565463 0.043632937 0.042716221 0.041815138
## [175] 0.040929509 0.040059157 0.039203903 0.038363570 0.037537980 0.036726956
## [181] 0.035930319 0.035147894 0.034379502 0.033624969 0.032884119 0.032156775
## [187] 0.031442763 0.030741909 0.030054039 0.029378980 0.028716560 0.028066607
## [193] 0.027428950 0.026803419 0.026189845 0.025588060 0.024997895 0.024419185
## [199] 0.023851764 0.023295468 0.022750132 0.022215594 0.021691694 0.021178270
## [205] 0.020675163 0.020182215 0.019699270 0.019226172 0.018762766 0.018308900
## [211] 0.017864421 0.017429178 0.017003023 0.016585807 0.016177383 0.015777607
## [217] 0.015386335 0.015003423 0.014628731 0.014262118 0.013903448 0.013552581
## [223] 0.013209384 0.012873721 0.012545461 0.012224473 0.011910625 0.011603792
## [229] 0.011303844 0.011010658 0.010724110 0.010444077 0.010170439 0.009903076
## [235] 0.009641870 0.009386706 0.009137468 0.008894043 0.008656319 0.008424186
## [241] 0.008197536 0.007976260 0.007760254 0.007549411 0.007343631 0.007142811
## [247] 0.006946851 0.006755653 0.006569119 0.006387155 0.006209665 0.006036558
## [253] 0.005867742 0.005703126 0.005542623 0.005386146 0.005233608 0.005084926
## [259] 0.004940016 0.004798797 0.004661188 0.004527111 0.004396488 0.004269243
## [265] 0.004145301 0.004024589 0.003907033 0.003792562 0.003681108 0.003572601
## [271] 0.003466974 0.003364160 0.003264096 0.003166716 0.003071959 0.002979763
## [277] 0.002890068 0.002802815 0.002717945 0.002635402 0.002555130 0.002477075
## [283] 0.002401182 0.002327400 0.002255677 0.002185961 0.002118205 0.002052359
## [289] 0.001988376 0.001926209 0.001865813 0.001807144 0.001750157 0.001694810
## [295] 0.001641061 0.001588870 0.001538195 0.001488999 0.001441242 0.001394887
## [301] 0.001349898 0.001306238 0.001263873 0.001222769 0.001182891 0.001144207
## [307] 0.001106685 0.001070294 0.001035003 0.001000782
# In Matrix mit 10 Spalten übertragen
matrix(1-pnorm(z),ncol=10, byrow=TRUE)
##              [,1]        [,2]        [,3]        [,4]        [,5]        [,6]
##  [1,] 0.500000000 0.496010644 0.492021686 0.488033527 0.484046563 0.480061194
##  [2,] 0.460172163 0.456204687 0.452241574 0.448283213 0.444329995 0.440382308
##  [3,] 0.420740291 0.416833837 0.412935577 0.409045885 0.405165128 0.401293674
##  [4,] 0.382088578 0.378280478 0.374484165 0.370699981 0.366928264 0.363169349
##  [5,] 0.344578258 0.340902974 0.337242727 0.333597821 0.329968554 0.326355220
##  [6,] 0.308537539 0.305025731 0.301531788 0.298055965 0.294598516 0.291159687
##  [7,] 0.274253118 0.270930904 0.267628893 0.264347292 0.261086300 0.257846111
##  [8,] 0.241963652 0.238852068 0.235762498 0.232695092 0.229649997 0.226627352
##  [9,] 0.211855399 0.208970088 0.206108054 0.203269392 0.200454193 0.197662543
## [10,] 0.184060125 0.181411255 0.178786380 0.176185542 0.173608780 0.171056126
## [11,] 0.158655254 0.156247645 0.153864230 0.151505003 0.149169950 0.146859056
## [12,] 0.135666061 0.133499513 0.131356881 0.129238112 0.127143151 0.125071936
## [13,] 0.115069670 0.113139446 0.111232437 0.109348552 0.107487697 0.105649774
## [14,] 0.096800485 0.095097918 0.093417509 0.091759136 0.090122672 0.088507991
## [15,] 0.080756659 0.079269841 0.077803841 0.076358510 0.074933700 0.073529260
## [16,] 0.066807201 0.065521712 0.064255488 0.063008364 0.061780177 0.060570758
## [17,] 0.054799292 0.053698928 0.052616138 0.051550748 0.050502583 0.049471468
## [18,] 0.044565463 0.043632937 0.042716221 0.041815138 0.040929509 0.040059157
## [19,] 0.035930319 0.035147894 0.034379502 0.033624969 0.032884119 0.032156775
## [20,] 0.028716560 0.028066607 0.027428950 0.026803419 0.026189845 0.025588060
## [21,] 0.022750132 0.022215594 0.021691694 0.021178270 0.020675163 0.020182215
## [22,] 0.017864421 0.017429178 0.017003023 0.016585807 0.016177383 0.015777607
## [23,] 0.013903448 0.013552581 0.013209384 0.012873721 0.012545461 0.012224473
## [24,] 0.010724110 0.010444077 0.010170439 0.009903076 0.009641870 0.009386706
## [25,] 0.008197536 0.007976260 0.007760254 0.007549411 0.007343631 0.007142811
## [26,] 0.006209665 0.006036558 0.005867742 0.005703126 0.005542623 0.005386146
## [27,] 0.004661188 0.004527111 0.004396488 0.004269243 0.004145301 0.004024589
## [28,] 0.003466974 0.003364160 0.003264096 0.003166716 0.003071959 0.002979763
## [29,] 0.002555130 0.002477075 0.002401182 0.002327400 0.002255677 0.002185961
## [30,] 0.001865813 0.001807144 0.001750157 0.001694810 0.001641061 0.001588870
## [31,] 0.001349898 0.001306238 0.001263873 0.001222769 0.001182891 0.001144207
##              [,7]        [,8]        [,9]       [,10]
##  [1,] 0.476077817 0.472096830 0.468118628 0.464143607
##  [2,] 0.436440537 0.432505068 0.428576284 0.424654565
##  [3,] 0.397431887 0.393580127 0.389738752 0.385908119
##  [4,] 0.359423567 0.355691245 0.351972708 0.348268273
##  [5,] 0.322758110 0.319177509 0.315613697 0.312066949
##  [6,] 0.287739719 0.284338849 0.280957309 0.277595325
##  [7,] 0.254626915 0.251428895 0.248252230 0.245097094
##  [8,] 0.223627292 0.220649946 0.217695438 0.214763884
##  [9,] 0.194894521 0.192150202 0.189429655 0.186732943
## [10,] 0.168527607 0.166023246 0.163543059 0.161087060
## [11,] 0.144572300 0.142309654 0.140071090 0.137856572
## [12,] 0.123024403 0.121000484 0.119000107 0.117023196
## [13,] 0.103834681 0.102042315 0.100272568 0.098525329
## [14,] 0.086914962 0.085343451 0.083793322 0.082264439
## [15,] 0.072145037 0.070780877 0.069436623 0.068112118
## [16,] 0.059379941 0.058207556 0.057053433 0.055917403
## [17,] 0.048457226 0.047459682 0.046478658 0.045513977
## [18,] 0.039203903 0.038363570 0.037537980 0.036726956
## [19,] 0.031442763 0.030741909 0.030054039 0.029378980
## [20,] 0.024997895 0.024419185 0.023851764 0.023295468
## [21,] 0.019699270 0.019226172 0.018762766 0.018308900
## [22,] 0.015386335 0.015003423 0.014628731 0.014262118
## [23,] 0.011910625 0.011603792 0.011303844 0.011010658
## [24,] 0.009137468 0.008894043 0.008656319 0.008424186
## [25,] 0.006946851 0.006755653 0.006569119 0.006387155
## [26,] 0.005233608 0.005084926 0.004940016 0.004798797
## [27,] 0.003907033 0.003792562 0.003681108 0.003572601
## [28,] 0.002890068 0.002802815 0.002717945 0.002635402
## [29,] 0.002118205 0.002052359 0.001988376 0.001926209
## [30,] 0.001538195 0.001488999 0.001441242 0.001394887
## [31,] 0.001106685 0.001070294 0.001035003 0.001000782
# auf 4 Stellen runden
matrix(round(1-pnorm(z),4),ncol=10, byrow=TRUE)
##         [,1]   [,2]   [,3]   [,4]   [,5]   [,6]   [,7]   [,8]   [,9]  [,10]
##  [1,] 0.5000 0.4960 0.4920 0.4880 0.4840 0.4801 0.4761 0.4721 0.4681 0.4641
##  [2,] 0.4602 0.4562 0.4522 0.4483 0.4443 0.4404 0.4364 0.4325 0.4286 0.4247
##  [3,] 0.4207 0.4168 0.4129 0.4090 0.4052 0.4013 0.3974 0.3936 0.3897 0.3859
##  [4,] 0.3821 0.3783 0.3745 0.3707 0.3669 0.3632 0.3594 0.3557 0.3520 0.3483
##  [5,] 0.3446 0.3409 0.3372 0.3336 0.3300 0.3264 0.3228 0.3192 0.3156 0.3121
##  [6,] 0.3085 0.3050 0.3015 0.2981 0.2946 0.2912 0.2877 0.2843 0.2810 0.2776
##  [7,] 0.2743 0.2709 0.2676 0.2643 0.2611 0.2578 0.2546 0.2514 0.2483 0.2451
##  [8,] 0.2420 0.2389 0.2358 0.2327 0.2296 0.2266 0.2236 0.2206 0.2177 0.2148
##  [9,] 0.2119 0.2090 0.2061 0.2033 0.2005 0.1977 0.1949 0.1922 0.1894 0.1867
## [10,] 0.1841 0.1814 0.1788 0.1762 0.1736 0.1711 0.1685 0.1660 0.1635 0.1611
## [11,] 0.1587 0.1562 0.1539 0.1515 0.1492 0.1469 0.1446 0.1423 0.1401 0.1379
## [12,] 0.1357 0.1335 0.1314 0.1292 0.1271 0.1251 0.1230 0.1210 0.1190 0.1170
## [13,] 0.1151 0.1131 0.1112 0.1093 0.1075 0.1056 0.1038 0.1020 0.1003 0.0985
## [14,] 0.0968 0.0951 0.0934 0.0918 0.0901 0.0885 0.0869 0.0853 0.0838 0.0823
## [15,] 0.0808 0.0793 0.0778 0.0764 0.0749 0.0735 0.0721 0.0708 0.0694 0.0681
## [16,] 0.0668 0.0655 0.0643 0.0630 0.0618 0.0606 0.0594 0.0582 0.0571 0.0559
## [17,] 0.0548 0.0537 0.0526 0.0516 0.0505 0.0495 0.0485 0.0475 0.0465 0.0455
## [18,] 0.0446 0.0436 0.0427 0.0418 0.0409 0.0401 0.0392 0.0384 0.0375 0.0367
## [19,] 0.0359 0.0351 0.0344 0.0336 0.0329 0.0322 0.0314 0.0307 0.0301 0.0294
## [20,] 0.0287 0.0281 0.0274 0.0268 0.0262 0.0256 0.0250 0.0244 0.0239 0.0233
## [21,] 0.0228 0.0222 0.0217 0.0212 0.0207 0.0202 0.0197 0.0192 0.0188 0.0183
## [22,] 0.0179 0.0174 0.0170 0.0166 0.0162 0.0158 0.0154 0.0150 0.0146 0.0143
## [23,] 0.0139 0.0136 0.0132 0.0129 0.0125 0.0122 0.0119 0.0116 0.0113 0.0110
## [24,] 0.0107 0.0104 0.0102 0.0099 0.0096 0.0094 0.0091 0.0089 0.0087 0.0084
## [25,] 0.0082 0.0080 0.0078 0.0075 0.0073 0.0071 0.0069 0.0068 0.0066 0.0064
## [26,] 0.0062 0.0060 0.0059 0.0057 0.0055 0.0054 0.0052 0.0051 0.0049 0.0048
## [27,] 0.0047 0.0045 0.0044 0.0043 0.0041 0.0040 0.0039 0.0038 0.0037 0.0036
## [28,] 0.0035 0.0034 0.0033 0.0032 0.0031 0.0030 0.0029 0.0028 0.0027 0.0026
## [29,] 0.0026 0.0025 0.0024 0.0023 0.0023 0.0022 0.0021 0.0021 0.0020 0.0019
## [30,] 0.0019 0.0018 0.0018 0.0017 0.0016 0.0016 0.0015 0.0015 0.0014 0.0014
## [31,] 0.0013 0.0013 0.0013 0.0012 0.0012 0.0011 0.0011 0.0011 0.0010 0.0010
# In Dataframe übertragen
tabelle2 <- data.frame(matrix(round(1-pnorm(z),4),ncol=10, byrow=TRUE))
# benenne die Spalten
colnames(tabelle2) <- c(seq(0.00, 0.09, 0.01))
# benenne die Zeilen
row.names(tabelle2) <- c(seq(0, 3, 0.1))
# gib fertige Tabelle aus
tabelle2
##          0   0.01   0.02   0.03   0.04   0.05   0.06   0.07   0.08   0.09
## 0   0.5000 0.4960 0.4920 0.4880 0.4840 0.4801 0.4761 0.4721 0.4681 0.4641
## 0.1 0.4602 0.4562 0.4522 0.4483 0.4443 0.4404 0.4364 0.4325 0.4286 0.4247
## 0.2 0.4207 0.4168 0.4129 0.4090 0.4052 0.4013 0.3974 0.3936 0.3897 0.3859
## 0.3 0.3821 0.3783 0.3745 0.3707 0.3669 0.3632 0.3594 0.3557 0.3520 0.3483
## 0.4 0.3446 0.3409 0.3372 0.3336 0.3300 0.3264 0.3228 0.3192 0.3156 0.3121
## 0.5 0.3085 0.3050 0.3015 0.2981 0.2946 0.2912 0.2877 0.2843 0.2810 0.2776
## 0.6 0.2743 0.2709 0.2676 0.2643 0.2611 0.2578 0.2546 0.2514 0.2483 0.2451
## 0.7 0.2420 0.2389 0.2358 0.2327 0.2296 0.2266 0.2236 0.2206 0.2177 0.2148
## 0.8 0.2119 0.2090 0.2061 0.2033 0.2005 0.1977 0.1949 0.1922 0.1894 0.1867
## 0.9 0.1841 0.1814 0.1788 0.1762 0.1736 0.1711 0.1685 0.1660 0.1635 0.1611
## 1   0.1587 0.1562 0.1539 0.1515 0.1492 0.1469 0.1446 0.1423 0.1401 0.1379
## 1.1 0.1357 0.1335 0.1314 0.1292 0.1271 0.1251 0.1230 0.1210 0.1190 0.1170
## 1.2 0.1151 0.1131 0.1112 0.1093 0.1075 0.1056 0.1038 0.1020 0.1003 0.0985
## 1.3 0.0968 0.0951 0.0934 0.0918 0.0901 0.0885 0.0869 0.0853 0.0838 0.0823
## 1.4 0.0808 0.0793 0.0778 0.0764 0.0749 0.0735 0.0721 0.0708 0.0694 0.0681
## 1.5 0.0668 0.0655 0.0643 0.0630 0.0618 0.0606 0.0594 0.0582 0.0571 0.0559
## 1.6 0.0548 0.0537 0.0526 0.0516 0.0505 0.0495 0.0485 0.0475 0.0465 0.0455
## 1.7 0.0446 0.0436 0.0427 0.0418 0.0409 0.0401 0.0392 0.0384 0.0375 0.0367
## 1.8 0.0359 0.0351 0.0344 0.0336 0.0329 0.0322 0.0314 0.0307 0.0301 0.0294
## 1.9 0.0287 0.0281 0.0274 0.0268 0.0262 0.0256 0.0250 0.0244 0.0239 0.0233
## 2   0.0228 0.0222 0.0217 0.0212 0.0207 0.0202 0.0197 0.0192 0.0188 0.0183
## 2.1 0.0179 0.0174 0.0170 0.0166 0.0162 0.0158 0.0154 0.0150 0.0146 0.0143
## 2.2 0.0139 0.0136 0.0132 0.0129 0.0125 0.0122 0.0119 0.0116 0.0113 0.0110
## 2.3 0.0107 0.0104 0.0102 0.0099 0.0096 0.0094 0.0091 0.0089 0.0087 0.0084
## 2.4 0.0082 0.0080 0.0078 0.0075 0.0073 0.0071 0.0069 0.0068 0.0066 0.0064
## 2.5 0.0062 0.0060 0.0059 0.0057 0.0055 0.0054 0.0052 0.0051 0.0049 0.0048
## 2.6 0.0047 0.0045 0.0044 0.0043 0.0041 0.0040 0.0039 0.0038 0.0037 0.0036
## 2.7 0.0035 0.0034 0.0033 0.0032 0.0031 0.0030 0.0029 0.0028 0.0027 0.0026
## 2.8 0.0026 0.0025 0.0024 0.0023 0.0023 0.0022 0.0021 0.0021 0.0020 0.0019
## 2.9 0.0019 0.0018 0.0018 0.0017 0.0016 0.0016 0.0015 0.0015 0.0014 0.0014
## 3   0.0013 0.0013 0.0013 0.0012 0.0012 0.0011 0.0011 0.0011 0.0010 0.0010


9.5.3 Kritische Werte \(\mathbf{t^*}\) der \(\mathbf{t}\)-Verteilung

Kritische Werte \(t^*\) der \(t\)-Verteilung
\(\alpha/2\) 0.10 0.05 0.025 0.01 0.005 0.0005
\(\alpha\) 0.20 0.10 0.050 0.020 0.010 0.0010
———- ——– ——- ——– ——– ——— ——–
df
1 3.078 6.314 12.706 31.821 63.657 318.309
2 1.886 2.920 4.303 6.965 9.925 22.327
3 1.638 2.353 3.182 4.541 5.841 10.215
4 1.533 2.132 2.776 3.747 4.604 7.173
5 1.476 2.015 2.571 3.365 4.032 5.893
6 1.440 1.943 2.447 3.143 3.707 5.208
7 1.415 1.895 2.365 2.998 3.499 4.785
8 1.397 1.860 2.306 2.896 3.355 4.501
9 1.383 1.833 2.262 2.821 3.250 4.297
10 1.372 1.812 2.228 2.764 3.169 4.144
11 1.363 1.796 2.201 2.718 3.106 4.025
12 1.356 1.782 2.179 2.681 3.055 3.930
13 1.350 1.771 2.160 2.650 3.012 3.852
14 1.345 1.761 2.145 2.624 2.977 3.787
15 1.341 1.753 2.131 2.602 2.947 3.733
16 1.337 1.746 2.120 2.583 2.921 3.686
17 1.333 1.740 2.110 2.567 2.898 3.646
18 1.330 1.734 2.101 2.552 2.878 3.611
19 1.328 1.729 2.093 2.539 2.861 3.579
20 1.325 1.725 2.086 2.528 2.845 3.552
21 1.323 1.721 2.080 2.518 2.831 3.527
22 1.321 1.717 2.074 2.508 2.819 3.505
23 1.319 1.714 2.069 2.500 2.807 3.485
24 1.318 1.711 2.064 2.492 2.797 3.467
25 1.316 1.708 2.060 2.485 2.787 3.450
26 1.315 1.706 2.056 2.479 2.779 3.435
27 1.314 1.703 2.052 2.473 2.771 3.421
28 1.313 1.701 2.048 2.467 2.763 3.408
29 1.311 1.699 2.045 2.462 2.756 3.396
30 1.310 1.697 2.042 2.457 2.750 3.385
40 1.303 1.684 2.021 2.423 2.704 3.307
50 1.299 1.676 2.009 2.403 2.678 3.261
60 1.296 1.671 2.000 2.390 2.660 3.232
70 1.294 1.667 1.994 2.381 2.648 3.211
80 1.292 1.664 1.990 2.374 2.639 3.195
90 1.291 1.662 1.987 2.368 2.632 3.183
100 1.290 1.660 1.984 2.364 2.626 3.174
200 1.286 1.653 1.972 2.345 2.601 3.131
300 1.284 1.650 1.968 2.339 2.592 3.118
400 1.284 1.649 1.966 2.336 2.588 3.111
500 1.283 1.648 1.965 2.334 2.586 3.107
\(\infty\) 1.282 1.645 1.960 2.326 2.576 3.090

Die Werte werden erzeugt mit:

# erstelle Werte von 1 bis 100, und 200, 300, 400, 500
df <- c(seq(from=1, to=100, by = 1), 200, 300, 400, 500)

# für alpha= 0.2
qt(0.9,df=df)
##   [1] 3.077684 1.885618 1.637744 1.533206 1.475884 1.439756 1.414924 1.396815
##   [9] 1.383029 1.372184 1.363430 1.356217 1.350171 1.345030 1.340606 1.336757
##  [17] 1.333379 1.330391 1.327728 1.325341 1.323188 1.321237 1.319460 1.317836
##  [25] 1.316345 1.314972 1.313703 1.312527 1.311434 1.310415 1.309464 1.308573
##  [33] 1.307737 1.306952 1.306212 1.305514 1.304854 1.304230 1.303639 1.303077
##  [41] 1.302543 1.302035 1.301552 1.301090 1.300649 1.300228 1.299825 1.299439
##  [49] 1.299069 1.298714 1.298373 1.298045 1.297730 1.297426 1.297134 1.296853
##  [57] 1.296581 1.296319 1.296066 1.295821 1.295585 1.295356 1.295134 1.294920
##  [65] 1.294712 1.294511 1.294315 1.294126 1.293942 1.293763 1.293589 1.293421
##  [73] 1.293256 1.293097 1.292941 1.292790 1.292643 1.292500 1.292360 1.292224
##  [81] 1.292091 1.291961 1.291835 1.291711 1.291591 1.291473 1.291358 1.291246
##  [89] 1.291136 1.291029 1.290924 1.290821 1.290721 1.290623 1.290527 1.290432
##  [97] 1.290340 1.290250 1.290161 1.290075 1.285799 1.284380 1.283672 1.283247
# erstelle Datenframe
tabelle_t <- data.frame(qt(0.9,df=df), qt(0.95,df=df), qt(0.975,df=df), qt(0.99,df=df), qt(0.995,df=df), qt(0.9995,df=df))
# benenne Spalten
colnames(tabelle_t) <- c("0.01","0.05","0.025","0.01","0.005","0.0005")
# benenne Zeilen
row.names(tabelle_t) <- df
# gib Tabelle aus
tabelle_t
##         0.01     0.05     0.025      0.01     0.005     0.0005
## 1   3.077684 6.313752 12.706205 31.820516 63.656741 636.619249
## 2   1.885618 2.919986  4.302653  6.964557  9.924843  31.599055
## 3   1.637744 2.353363  3.182446  4.540703  5.840909  12.923979
## 4   1.533206 2.131847  2.776445  3.746947  4.604095   8.610302
## 5   1.475884 2.015048  2.570582  3.364930  4.032143   6.868827
## 6   1.439756 1.943180  2.446912  3.142668  3.707428   5.958816
## 7   1.414924 1.894579  2.364624  2.997952  3.499483   5.407883
## 8   1.396815 1.859548  2.306004  2.896459  3.355387   5.041305
## 9   1.383029 1.833113  2.262157  2.821438  3.249836   4.780913
## 10  1.372184 1.812461  2.228139  2.763769  3.169273   4.586894
## 11  1.363430 1.795885  2.200985  2.718079  3.105807   4.436979
## 12  1.356217 1.782288  2.178813  2.680998  3.054540   4.317791
## 13  1.350171 1.770933  2.160369  2.650309  3.012276   4.220832
## 14  1.345030 1.761310  2.144787  2.624494  2.976843   4.140454
## 15  1.340606 1.753050  2.131450  2.602480  2.946713   4.072765
## 16  1.336757 1.745884  2.119905  2.583487  2.920782   4.014996
## 17  1.333379 1.739607  2.109816  2.566934  2.898231   3.965126
## 18  1.330391 1.734064  2.100922  2.552380  2.878440   3.921646
## 19  1.327728 1.729133  2.093024  2.539483  2.860935   3.883406
## 20  1.325341 1.724718  2.085963  2.527977  2.845340   3.849516
## 21  1.323188 1.720743  2.079614  2.517648  2.831360   3.819277
## 22  1.321237 1.717144  2.073873  2.508325  2.818756   3.792131
## 23  1.319460 1.713872  2.068658  2.499867  2.807336   3.767627
## 24  1.317836 1.710882  2.063899  2.492159  2.796940   3.745399
## 25  1.316345 1.708141  2.059539  2.485107  2.787436   3.725144
## 26  1.314972 1.705618  2.055529  2.478630  2.778715   3.706612
## 27  1.313703 1.703288  2.051831  2.472660  2.770683   3.689592
## 28  1.312527 1.701131  2.048407  2.467140  2.763262   3.673906
## 29  1.311434 1.699127  2.045230  2.462021  2.756386   3.659405
## 30  1.310415 1.697261  2.042272  2.457262  2.749996   3.645959
## 31  1.309464 1.695519  2.039513  2.452824  2.744042   3.633456
## 32  1.308573 1.693889  2.036933  2.448678  2.738481   3.621802
## 33  1.307737 1.692360  2.034515  2.444794  2.733277   3.610913
## 34  1.306952 1.690924  2.032245  2.441150  2.728394   3.600716
## 35  1.306212 1.689572  2.030108  2.437723  2.723806   3.591147
## 36  1.305514 1.688298  2.028094  2.434494  2.719485   3.582150
## 37  1.304854 1.687094  2.026192  2.431447  2.715409   3.573675
## 38  1.304230 1.685954  2.024394  2.428568  2.711558   3.565678
## 39  1.303639 1.684875  2.022691  2.425841  2.707913   3.558120
## 40  1.303077 1.683851  2.021075  2.423257  2.704459   3.550966
## 41  1.302543 1.682878  2.019541  2.420803  2.701181   3.544184
## 42  1.302035 1.681952  2.018082  2.418470  2.698066   3.537745
## 43  1.301552 1.681071  2.016692  2.416250  2.695102   3.531626
## 44  1.301090 1.680230  2.015368  2.414134  2.692278   3.525801
## 45  1.300649 1.679427  2.014103  2.412116  2.689585   3.520251
## 46  1.300228 1.678660  2.012896  2.410188  2.687013   3.514957
## 47  1.299825 1.677927  2.011741  2.408345  2.684556   3.509901
## 48  1.299439 1.677224  2.010635  2.406581  2.682204   3.505068
## 49  1.299069 1.676551  2.009575  2.404892  2.679952   3.500443
## 50  1.298714 1.675905  2.008559  2.403272  2.677793   3.496013
## 51  1.298373 1.675285  2.007584  2.401718  2.675722   3.491766
## 52  1.298045 1.674689  2.006647  2.400225  2.673734   3.487691
## 53  1.297730 1.674116  2.005746  2.398790  2.671823   3.483777
## 54  1.297426 1.673565  2.004879  2.397410  2.669985   3.480016
## 55  1.297134 1.673034  2.004045  2.396081  2.668216   3.476398
## 56  1.296853 1.672522  2.003241  2.394801  2.666512   3.472916
## 57  1.296581 1.672029  2.002465  2.393568  2.664870   3.469562
## 58  1.296319 1.671553  2.001717  2.392377  2.663287   3.466329
## 59  1.296066 1.671093  2.000995  2.391229  2.661759   3.463210
## 60  1.295821 1.670649  2.000298  2.390119  2.660283   3.460200
## 61  1.295585 1.670219  1.999624  2.389047  2.658857   3.457294
## 62  1.295356 1.669804  1.998972  2.388011  2.657479   3.454485
## 63  1.295134 1.669402  1.998341  2.387008  2.656145   3.451769
## 64  1.294920 1.669013  1.997730  2.386037  2.654854   3.449142
## 65  1.294712 1.668636  1.997138  2.385097  2.653604   3.446598
## 66  1.294511 1.668271  1.996564  2.384186  2.652394   3.444135
## 67  1.294315 1.667916  1.996008  2.383302  2.651220   3.441749
## 68  1.294126 1.667572  1.995469  2.382446  2.650081   3.439435
## 69  1.293942 1.667239  1.994945  2.381615  2.648977   3.437192
## 70  1.293763 1.666914  1.994437  2.380807  2.647905   3.435015
## 71  1.293589 1.666600  1.993943  2.380024  2.646863   3.432901
## 72  1.293421 1.666294  1.993464  2.379262  2.645852   3.430848
## 73  1.293256 1.665996  1.992997  2.378522  2.644869   3.428854
## 74  1.293097 1.665707  1.992543  2.377802  2.643913   3.426916
## 75  1.292941 1.665425  1.992102  2.377102  2.642983   3.425031
## 76  1.292790 1.665151  1.991673  2.376420  2.642078   3.423197
## 77  1.292643 1.664885  1.991254  2.375757  2.641198   3.421413
## 78  1.292500 1.664625  1.990847  2.375111  2.640340   3.419676
## 79  1.292360 1.664371  1.990450  2.374482  2.639505   3.417985
## 80  1.292224 1.664125  1.990063  2.373868  2.638691   3.416337
## 81  1.292091 1.663884  1.989686  2.373270  2.637897   3.414732
## 82  1.291961 1.663649  1.989319  2.372687  2.637123   3.413167
## 83  1.291835 1.663420  1.988960  2.372119  2.636369   3.411641
## 84  1.291711 1.663197  1.988610  2.371564  2.635632   3.410152
## 85  1.291591 1.662978  1.988268  2.371022  2.634914   3.408699
## 86  1.291473 1.662765  1.987934  2.370493  2.634212   3.407282
## 87  1.291358 1.662557  1.987608  2.369977  2.633527   3.405897
## 88  1.291246 1.662354  1.987290  2.369472  2.632858   3.404546
## 89  1.291136 1.662155  1.986979  2.368979  2.632204   3.403225
## 90  1.291029 1.661961  1.986675  2.368497  2.631565   3.401935
## 91  1.290924 1.661771  1.986377  2.368026  2.630940   3.400674
## 92  1.290821 1.661585  1.986086  2.367566  2.630330   3.399442
## 93  1.290721 1.661404  1.985802  2.367115  2.629732   3.398236
## 94  1.290623 1.661226  1.985523  2.366674  2.629148   3.397057
## 95  1.290527 1.661052  1.985251  2.366243  2.628576   3.395904
## 96  1.290432 1.660881  1.984984  2.365821  2.628016   3.394775
## 97  1.290340 1.660715  1.984723  2.365407  2.627468   3.393670
## 98  1.290250 1.660551  1.984467  2.365002  2.626931   3.392588
## 99  1.290161 1.660391  1.984217  2.364606  2.626405   3.391529
## 100 1.290075 1.660234  1.983972  2.364217  2.625891   3.390491
## 200 1.285799 1.652508  1.971896  2.345137  2.600634   3.339835
## 300 1.284380 1.649949  1.967903  2.338842  2.592316   3.323252
## 400 1.283672 1.648672  1.965912  2.335706  2.588176   3.315015
## 500 1.283247 1.647907  1.964720  2.333829  2.585698   3.310091

9.5.4 Kritische Werte der \(\mathbf{\chi^2}\)-Verteilung

Kritische Werte der \(\chi^2\)-Verteilung
\(\alpha\) 0.10 0.05 0.025 0.01 0.005 0.0005
df
1 2.71 3.84 5.02 6.63 7.88 12.12
2 4.61 5.99 7.38 9.21 10.60 15.20
3 6.25 7.81 9.35 11.34 12.84 17.73
4 7.78 9.49 11.14 13.28 14.86 20.00
5 9.24 11.07 12.83 15.09 16.75 22.11
6 10.64 12.59 14.45 16.81 18.55 24.10
7 12.02 14.07 16.01 18.48 20.28 26.02
8 13.36 15.51 17.53 20.09 21.95 27.87
9 14.68 16.92 19.02 21.67 23.59 29.67
10 15.99 18.31 20.48 23.21 25.19 31.42
11 17.28 19.68 21.92 24.72 26.76 33.14
12 18.55 21.03 23.34 26.22 28.30 34.82
13 19.81 22.36 24.74 27.69 29.82 36.48
14 21.06 23.68 26.12 29.14 31.32 38.11
15 22.31 25.00 27.49 30.58 32.80 39.72
16 23.54 26.30 28.85 32.00 34.27 41.31
17 24.77 27.59 30.19 33.41 35.72 42.88
18 25.99 28.87 31.53 34.81 37.16 44.43
19 27.20 30.14 32.85 36.19 38.58 45.97
20 28.41 31.41 34.17 37.57 40.00 47.50
21 29.62 32.67 35.48 38.93 41.40 49.01
22 30.81 33.92 36.78 40.29 42.80 50.51
23 32.01 35.17 38.08 41.64 44.18 52.00
24 33.20 36.42 39.36 42.98 45.56 53.48
25 34.38 37.65 40.65 44.31 46.93 54.95
26 35.56 38.89 41.92 45.64 48.29 56.41
27 36.74 40.11 43.19 46.96 49.64 57.86
28 37.92 41.34 44.46 48.28 50.99 59.30
29 39.09 42.56 45.72 49.59 52.34 60.73
30 40.26 43.77 46.98 50.89 53.67 62.16
31 41.42 44.99 48.23 52.19 55.00 63.58
32 42.58 46.19 49.48 53.49 56.33 65.00
33 43.75 47.40 50.73 54.78 57.65 66.40
34 44.90 48.60 51.97 56.06 58.96 67.80
35 46.06 49.80 53.20 57.34 60.27 69.20
36 47.21 51.00 54.44 58.62 61.58 70.59
37 48.36 52.19 55.67 59.89 62.88 71.97
38 49.51 53.38 56.90 61.16 64.18 73.35
39 50.66 54.57 58.12 62.43 65.48 74.73
40 51.81 55.76 59.34 63.69 66.77 76.09

Die Werte werden erzeugt mit:

# werte von 1 bis 40
df <- c(seq(from=1, to=40, by = 1))
# chi^2-Werte für unterschiedliche alpha berechnen
tabelle_chi <- data.frame(qchisq(0.9,df=df), qchisq(0.95,df=df), qchisq(0.975,df=df), qchisq(0.99,df=df), qchisq(0.995,df=df), qchisq(0.9995,df=df))
# benenne Spalten nach alpha-Werten
colnames(tabelle_chi) <- c("0.01","0.05","0.025","0.01","0.005","0.0005")
# benenne Zeilen nach df-Werten
row.names(tabelle_chi) <- df
# gib Tabelle aus
tabelle_chi
##         0.01      0.05     0.025      0.01     0.005   0.0005
## 1   2.705543  3.841459  5.023886  6.634897  7.879439 12.11567
## 2   4.605170  5.991465  7.377759  9.210340 10.596635 15.20180
## 3   6.251389  7.814728  9.348404 11.344867 12.838156 17.73000
## 4   7.779440  9.487729 11.143287 13.276704 14.860259 19.99735
## 5   9.236357 11.070498 12.832502 15.086272 16.749602 22.10533
## 6  10.644641 12.591587 14.449375 16.811894 18.547584 24.10280
## 7  12.017037 14.067140 16.012764 18.475307 20.277740 26.01777
## 8  13.361566 15.507313 17.534546 20.090235 21.954955 27.86805
## 9  14.683657 16.918978 19.022768 21.665994 23.589351 29.66581
## 10 15.987179 18.307038 20.483177 23.209251 25.188180 31.41981
## 11 17.275009 19.675138 21.920049 24.724970 26.756849 33.13662
## 12 18.549348 21.026070 23.336664 26.216967 28.299519 34.82127
## 13 19.811929 22.362032 24.735605 27.688250 29.819471 36.47779
## 14 21.064144 23.684791 26.118948 29.141238 31.319350 38.10940
## 15 22.307130 24.995790 27.488393 30.577914 32.801321 39.71876
## 16 23.541829 26.296228 28.845351 31.999927 34.267187 41.30807
## 17 24.769035 27.587112 30.191009 33.408664 35.718466 42.87921
## 18 25.989423 28.869299 31.526378 34.805306 37.156451 44.43377
## 19 27.203571 30.143527 32.852327 36.190869 38.582257 45.97312
## 20 28.411981 31.410433 34.169607 37.566235 39.996846 47.49845
## 21 29.615089 32.670573 35.478876 38.932173 41.401065 49.01081
## 22 30.813282 33.924438 36.780712 40.289360 42.795655 50.51112
## 23 32.006900 35.172462 38.075627 41.638398 44.181275 52.00019
## 24 33.196244 36.415029 39.364077 42.979820 45.558512 53.47875
## 25 34.381587 37.652484 40.646469 44.314105 46.927890 54.94746
## 26 35.563171 38.885139 41.923170 45.641683 48.289882 56.40689
## 27 36.741217 40.113272 43.194511 46.962942 49.644915 57.85759
## 28 37.915923 41.337138 44.460792 48.278236 50.993376 59.30003
## 29 39.087470 42.556968 45.722286 49.587884 52.335618 60.73465
## 30 40.256024 43.772972 46.979242 50.892181 53.671962 62.16185
## 31 41.421736 44.985343 48.231890 52.191395 55.002704 63.58201
## 32 42.584745 46.194260 49.480438 53.485772 56.328115 64.99546
## 33 43.745180 47.399884 50.725080 54.775540 57.648445 66.40251
## 34 44.903158 48.602367 51.965995 56.060909 58.963926 67.80346
## 35 46.058788 49.801850 53.203349 57.342073 60.274771 69.19856
## 36 47.212174 50.998460 54.437294 58.619215 61.581179 70.58807
## 37 48.363408 52.192320 55.667973 59.892500 62.883335 71.97222
## 38 49.512580 53.383541 56.895521 61.162087 64.181412 73.35123
## 39 50.659770 54.572228 58.120060 62.428121 65.475571 74.72529
## 40 51.805057 55.758479 59.341707 63.690740 66.765962 76.09460