Compare commits
10
Commits
51cd711da8
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1b11d1dce | ||
|
|
fc8d0245bc | ||
|
|
6584495be7 | ||
|
|
8cfb62c7bd | ||
|
|
2738e6d032 | ||
|
|
a5474df9b3 | ||
|
|
1871414592 | ||
|
|
3ae01d771f | ||
|
|
6e3788817e | ||
|
|
74f5c9c54e |
No files matched your search
@@ -46,3 +46,4 @@ docs/
|
|||||||
po/*~
|
po/*~
|
||||||
|
|
||||||
*.onetoc2
|
*.onetoc2
|
||||||
|
Open Notebook.onetoc2
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
# quantitative-methods-hs22
|
# quantitative-methods-hs22
|
||||||
|
|
||||||
|
Find the live html version here: https://statistik.m-g.tech
|
||||||
+96
-83
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<meta name="author" content="Marc Gauch" />
|
<meta name="author" content="Marc Gauch" />
|
||||||
|
|
||||||
<meta name="date" content="2022-11-18" />
|
<meta name="date" content="2022-12-02" />
|
||||||
|
|
||||||
<title>Quantitative Methods HS22</title>
|
<title>Quantitative Methods HS22</title>
|
||||||
|
|
||||||
@@ -1487,7 +1487,7 @@ border-radius: 0px;
|
|||||||
|
|
||||||
<h1 class="title toc-ignore">Quantitative Methods HS22</h1>
|
<h1 class="title toc-ignore">Quantitative Methods HS22</h1>
|
||||||
<h4 class="author">Marc Gauch</h4>
|
<h4 class="author">Marc Gauch</h4>
|
||||||
<h4 class="date">2022-11-18</h4>
|
<h4 class="date">2022-12-02</h4>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -1498,9 +1498,9 @@ border-radius: 0px;
|
|||||||
install.packages("tidyverse")
|
install.packages("tidyverse")
|
||||||
library(tidyverse)
|
library(tidyverse)
|
||||||
}
|
}
|
||||||
if (!require(moments)) {
|
if (!require(e1071)) {
|
||||||
install.packages("moments")
|
install.packages("e1071")
|
||||||
library(moments)
|
library(e1071)
|
||||||
}</code></pre>
|
}</code></pre>
|
||||||
</div>
|
</div>
|
||||||
<div id="own-functions" class="section level1" number="2">
|
<div id="own-functions" class="section level1" number="2">
|
||||||
@@ -1508,26 +1508,30 @@ if (!require(moments)) {
|
|||||||
<div id="frequency-table-ordered-from-wish.com" class="section level2" number="2.1">
|
<div id="frequency-table-ordered-from-wish.com" class="section level2" number="2.1">
|
||||||
<h2><span class="header-section-number">2.1</span> Frequency Table
|
<h2><span class="header-section-number">2.1</span> Frequency Table
|
||||||
ordered from wish.com</h2>
|
ordered from wish.com</h2>
|
||||||
<pre class="r"><code>freq <- function(data) {
|
<pre class="r"><code>freq <- function(data, rounded_digits = 2) {
|
||||||
|
# counts
|
||||||
|
total_count <- length(data)
|
||||||
na_count <- length(data[is.na(data)])
|
na_count <- length(data[is.na(data)])
|
||||||
valid_count <- length(data) - na_count
|
valid_count <- total_count - na_count
|
||||||
|
|
||||||
frequency <- table(data)
|
frequency <- table(data)
|
||||||
p <- prop.table(frequency)
|
p <- prop.table(frequency)
|
||||||
percent <- round(p * 100, digits = 2)
|
valid_percent <- round(p * 100, digits = rounded_digits)
|
||||||
frequency_sum <- cumsum(frequency)
|
na_percent <- round(na_count / length(data) * 100, digits = rounded_digits)
|
||||||
hkum <- cumsum(p)
|
|
||||||
percent_sum <- round(hkum * 100, digits = 2)
|
|
||||||
freq_table <- cbind(frequency, percent, frequency_sum, percent_sum)
|
|
||||||
valid_percent <- round(valid_count / length(data) * 100, digits = 2)
|
|
||||||
na_percent <- round(na_count / length(data) * 100, digits = 2)
|
|
||||||
|
|
||||||
|
percent_raw <- frequency/total_count*100
|
||||||
|
percent <- round(percent_raw, digits = rounded_digits)
|
||||||
|
cumulative_percent <- round(cumsum(p) * 100, digits = rounded_digits)
|
||||||
|
freq_table <- cbind(frequency, percent, percent_raw, valid_percent, cumulative_percent)
|
||||||
|
|
||||||
print(freq_table)
|
valid_percent_sum <- round(sum(as.data.frame(freq_table)$percent_raw), digits = rounded_digits)
|
||||||
|
Valid_Total <- c(valid_count, valid_percent_sum, 100, NaN)
|
||||||
|
|
||||||
count <- c(valid_count, na_count, valid_count + na_count)
|
freq_table <- subset(freq_table, select = -c(percent_raw))
|
||||||
percent <- c(valid_percent, na_percent, valid_percent + na_percent)
|
|
||||||
df <- data.frame(count, percent, row.names = c("valid", "NA", "Total"))
|
NAs <- c(na_count, na_percent, NaN, NaN)
|
||||||
print(df)
|
Total <- c(total_count, 100, NaN, NaN)
|
||||||
|
print(rbind(freq_table, Valid_Total, NAs, Total))
|
||||||
}</code></pre>
|
}</code></pre>
|
||||||
<p><em>Source: <a href="https://tellmi.psy.lmu.de/tutorials/deskriptive-statistiken-und-grafiken.html#haeufigkeiten-diskret" class="uri">https://tellmi.psy.lmu.de/tutorials/deskriptive-statistiken-und-grafiken.html#haeufigkeiten-diskret</a>
|
<p><em>Source: <a href="https://tellmi.psy.lmu.de/tutorials/deskriptive-statistiken-und-grafiken.html#haeufigkeiten-diskret" class="uri">https://tellmi.psy.lmu.de/tutorials/deskriptive-statistiken-und-grafiken.html#haeufigkeiten-diskret</a>
|
||||||
and adapted</em></p>
|
and adapted</em></p>
|
||||||
@@ -1540,6 +1544,12 @@ and adapted</em></p>
|
|||||||
uniqv[which(x == max(x))]
|
uniqv[which(x == max(x))]
|
||||||
}</code></pre>
|
}</code></pre>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="remove-na" class="section level2" number="2.3">
|
||||||
|
<h2><span class="header-section-number">2.3</span> Remove NA</h2>
|
||||||
|
<pre class="r"><code>removeNA <- function(d){
|
||||||
|
return(d[!is.na(d)])
|
||||||
|
}</code></pre>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="load-data" class="section level1" number="3">
|
<div id="load-data" class="section level1" number="3">
|
||||||
<h1><span class="header-section-number">3</span> Load Data</h1>
|
<h1><span class="header-section-number">3</span> Load Data</h1>
|
||||||
@@ -2388,71 +2398,68 @@ gibt.</p>
|
|||||||
<div id="selbststudium-2.1" class="section level1" number="6">
|
<div id="selbststudium-2.1" class="section level1" number="6">
|
||||||
<h1><span class="header-section-number">6</span> Selbststudium 2.1</h1>
|
<h1><span class="header-section-number">6</span> Selbststudium 2.1</h1>
|
||||||
<p>We have the year 2021 ## Preparation</p>
|
<p>We have the year 2021 ## Preparation</p>
|
||||||
<pre class="r"><code>birthyears <- litdata$D7
|
<pre class="r"><code># remove NAs
|
||||||
# remove NAs
|
birthyears <- removeNA(litdata$D7)
|
||||||
birthyears <- birthyears[!is.na(birthyears)]
|
|
||||||
age <- 2021 - birthyears</code></pre>
|
age <- 2021 - birthyears</code></pre>
|
||||||
<div id="frequency" class="section level2" number="6.1">
|
<div id="frequency" class="section level2" number="6.1">
|
||||||
<h2><span class="header-section-number">6.1</span> Frequency</h2>
|
<h2><span class="header-section-number">6.1</span> Frequency</h2>
|
||||||
<pre class="r"><code>freq(age)</code></pre>
|
<pre class="r"><code>freq(age)</code></pre>
|
||||||
<pre><code>## frequency percent frequency_sum percent_sum
|
<pre><code>## frequency percent valid_percent cumulative_percent
|
||||||
## 19 1 0.94 1 0.94
|
## 19 1 0.94 0.94 0.94
|
||||||
## 20 2 1.89 3 2.83
|
## 20 2 1.89 1.89 2.83
|
||||||
## 21 7 6.60 10 9.43
|
## 21 7 6.60 6.60 9.43
|
||||||
## 22 7 6.60 17 16.04
|
## 22 7 6.60 6.60 16.04
|
||||||
## 23 15 14.15 32 30.19
|
## 23 15 14.15 14.15 30.19
|
||||||
## 24 14 13.21 46 43.40
|
## 24 14 13.21 13.21 43.40
|
||||||
## 25 3 2.83 49 46.23
|
## 25 3 2.83 2.83 46.23
|
||||||
## 26 10 9.43 59 55.66
|
## 26 10 9.43 9.43 55.66
|
||||||
## 27 2 1.89 61 57.55
|
## 27 2 1.89 1.89 57.55
|
||||||
## 28 8 7.55 69 65.09
|
## 28 8 7.55 7.55 65.09
|
||||||
## 29 6 5.66 75 70.75
|
## 29 6 5.66 5.66 70.75
|
||||||
## 30 5 4.72 80 75.47
|
## 30 5 4.72 4.72 75.47
|
||||||
## 31 4 3.77 84 79.25
|
## 31 4 3.77 3.77 79.25
|
||||||
## 32 2 1.89 86 81.13
|
## 32 2 1.89 1.89 81.13
|
||||||
## 33 3 2.83 89 83.96
|
## 33 3 2.83 2.83 83.96
|
||||||
## 34 5 4.72 94 88.68
|
## 34 5 4.72 4.72 88.68
|
||||||
## 36 4 3.77 98 92.45
|
## 36 4 3.77 3.77 92.45
|
||||||
## 37 1 0.94 99 93.40
|
## 37 1 0.94 0.94 93.40
|
||||||
## 41 1 0.94 100 94.34
|
## 41 1 0.94 0.94 94.34
|
||||||
## 47 3 2.83 103 97.17
|
## 47 3 2.83 2.83 97.17
|
||||||
## 48 1 0.94 104 98.11
|
## 48 1 0.94 0.94 98.11
|
||||||
## 49 1 0.94 105 99.06
|
## 49 1 0.94 0.94 99.06
|
||||||
## 50 1 0.94 106 100.00
|
## 50 1 0.94 0.94 100.00
|
||||||
## count percent
|
## Valid_Total 106 100.00 100.00 NaN
|
||||||
## valid 106 100
|
## NAs 0 0.00 NaN NaN
|
||||||
## NA 0 0
|
## Total 106 100.00 NaN NaN</code></pre>
|
||||||
## Total 106 100</code></pre>
|
|
||||||
<pre class="r"><code># with NA
|
<pre class="r"><code># with NA
|
||||||
freq(2021 - litdata$D7)</code></pre>
|
freq(2021 - litdata$D7)</code></pre>
|
||||||
<pre><code>## frequency percent frequency_sum percent_sum
|
<pre><code>## frequency percent valid_percent cumulative_percent
|
||||||
## 19 1 0.94 1 0.94
|
## 19 1 0.32 0.94 0.94
|
||||||
## 20 2 1.89 3 2.83
|
## 20 2 0.64 1.89 2.83
|
||||||
## 21 7 6.60 10 9.43
|
## 21 7 2.24 6.60 9.43
|
||||||
## 22 7 6.60 17 16.04
|
## 22 7 2.24 6.60 16.04
|
||||||
## 23 15 14.15 32 30.19
|
## 23 15 4.79 14.15 30.19
|
||||||
## 24 14 13.21 46 43.40
|
## 24 14 4.47 13.21 43.40
|
||||||
## 25 3 2.83 49 46.23
|
## 25 3 0.96 2.83 46.23
|
||||||
## 26 10 9.43 59 55.66
|
## 26 10 3.19 9.43 55.66
|
||||||
## 27 2 1.89 61 57.55
|
## 27 2 0.64 1.89 57.55
|
||||||
## 28 8 7.55 69 65.09
|
## 28 8 2.56 7.55 65.09
|
||||||
## 29 6 5.66 75 70.75
|
## 29 6 1.92 5.66 70.75
|
||||||
## 30 5 4.72 80 75.47
|
## 30 5 1.60 4.72 75.47
|
||||||
## 31 4 3.77 84 79.25
|
## 31 4 1.28 3.77 79.25
|
||||||
## 32 2 1.89 86 81.13
|
## 32 2 0.64 1.89 81.13
|
||||||
## 33 3 2.83 89 83.96
|
## 33 3 0.96 2.83 83.96
|
||||||
## 34 5 4.72 94 88.68
|
## 34 5 1.60 4.72 88.68
|
||||||
## 36 4 3.77 98 92.45
|
## 36 4 1.28 3.77 92.45
|
||||||
## 37 1 0.94 99 93.40
|
## 37 1 0.32 0.94 93.40
|
||||||
## 41 1 0.94 100 94.34
|
## 41 1 0.32 0.94 94.34
|
||||||
## 47 3 2.83 103 97.17
|
## 47 3 0.96 2.83 97.17
|
||||||
## 48 1 0.94 104 98.11
|
## 48 1 0.32 0.94 98.11
|
||||||
## 49 1 0.94 105 99.06
|
## 49 1 0.32 0.94 99.06
|
||||||
## 50 1 0.94 106 100.00
|
## 50 1 0.32 0.94 100.00
|
||||||
## count percent
|
## Valid_Total 106 33.87 100.00 NaN
|
||||||
## valid 106 33.87
|
## NAs 207 66.13 NaN NaN
|
||||||
## NA 207 66.13
|
## Total 313 100.00 NaN NaN</code></pre>
|
||||||
## Total 313 100.00</code></pre>
|
|
||||||
</div>
|
</div>
|
||||||
<div id="selbststudium-2" class="section level2" number="6.2">
|
<div id="selbststudium-2" class="section level2" number="6.2">
|
||||||
<h2><span class="header-section-number">6.2</span> Selbststudium 2</h2>
|
<h2><span class="header-section-number">6.2</span> Selbststudium 2</h2>
|
||||||
@@ -2502,9 +2509,8 @@ Standardabweichung</h3>
|
|||||||
</div>
|
</div>
|
||||||
<div id="schiefe" class="section level3" number="6.2.8">
|
<div id="schiefe" class="section level3" number="6.2.8">
|
||||||
<h3><span class="header-section-number">6.2.8</span> Schiefe</h3>
|
<h3><span class="header-section-number">6.2.8</span> Schiefe</h3>
|
||||||
<pre class="r"><code>library(moments)
|
<pre class="r"><code>skewness(age)</code></pre>
|
||||||
skewness(age)</code></pre>
|
<pre><code>## [1] 1.550033</code></pre>
|
||||||
<pre><code>## [1] 1.572229</code></pre>
|
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p>Die Kennzahl Schiefe ist wird Null bei einer perfekt symmetrischen
|
<p>Die Kennzahl Schiefe ist wird Null bei einer perfekt symmetrischen
|
||||||
Verteilung, größer als Null bei einer rechtsschiefen und kleiner als
|
Verteilung, größer als Null bei einer rechtsschiefen und kleiner als
|
||||||
@@ -2513,8 +2519,9 @@ Null bei einer linksschiefen Verteilung. <a href="https://www.beratung-statistik
|
|||||||
</div>
|
</div>
|
||||||
<div id="kurtosis" class="section level3" number="6.2.9">
|
<div id="kurtosis" class="section level3" number="6.2.9">
|
||||||
<h3><span class="header-section-number">6.2.9</span> Kurtosis</h3>
|
<h3><span class="header-section-number">6.2.9</span> Kurtosis</h3>
|
||||||
<pre class="r"><code>kurtosis(age)</code></pre>
|
<pre class="r"><code>kurtosis(age, type = 2)</code></pre>
|
||||||
<pre><code>## [1] 5.383429</code></pre>
|
<pre><code>## [1] 2.55861</code></pre>
|
||||||
|
<p><em>SPSS berechnet die Kurtosis mit einer anderen <a href="https://rdrr.io/rforge/e1071/man/kurtosis.html">Formel</a>.</em></p>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p>Eine weitere bekannte Kennzahl ist die Kurtosis. Um eine Vorstellung
|
<p>Eine weitere bekannte Kennzahl ist die Kurtosis. Um eine Vorstellung
|
||||||
von der Bedeutung der Kurtosis zu erhalten, betrachten Sie nachfolgende
|
von der Bedeutung der Kurtosis zu erhalten, betrachten Sie nachfolgende
|
||||||
@@ -2550,6 +2557,12 @@ qqline(age)</code></pre>
|
|||||||
<div id="historam-for-age" class="section level3 tabset" number="6.2.11">
|
<div id="historam-for-age" class="section level3 tabset" number="6.2.11">
|
||||||
<h3 class="tabset"><span class="header-section-number">6.2.11</span>
|
<h3 class="tabset"><span class="header-section-number">6.2.11</span>
|
||||||
Historam for age</h3>
|
Historam for age</h3>
|
||||||
|
<div id="frequency-1" class="section level4 unnumbered">
|
||||||
|
<h4 class="unnumbered">Frequency</h4>
|
||||||
|
<pre class="r"><code>hist(age, freq = F)
|
||||||
|
lines(density(age), lwd = 2, col = "black")</code></pre>
|
||||||
|
<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABUAAAAPACAMAAADDuCPrAAADAFBMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZGRlZWVmZmZnZ2doaGhpaWlqampra2tsbGxtbW1ubm5vb29wcHBxcXFycnJzc3N0dHR1dXV2dnZ3d3d4eHh5eXl6enp7e3t8fHx9fX1+fn5/f3+AgICBgYGCgoKDg4OEhISFhYWGhoaHh4eIiIiJiYmKioqLi4uMjIyNjY2Ojo6Pj4+QkJCRkZGSkpKTk5OUlJSVlZWWlpaXl5eYmJiZmZmampqbm5ucnJydnZ2enp6fn5+goKChoaGioqKjo6OkpKSlpaWmpqanp6eoqKipqamqq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HNmXQvK/XjK6qXxl7MfkbAgrc+AJ6IHxAIvqS7U82+Y7gT2w4u8kR17jTmN3oiMlmAX098joZbDA6oYBGW7x5QM0XGGVdtbxyYRPLfyS9scETEFDgxvkl0srKYRGptEaf+m5IQLXHwwbkvKnAmN3RK4onteoeJaCFnYuvU914H/2mJhrQKIs3D6j5AqOsq6blhha08iqZzQwegoACN95v4bd3K2lI6rVFO/tcHRJQbWFW8TXqvlI8v4KcVGPamXtLn9IjaPf5wdt1/GqJ/m+FA8IBNV98lB3pTRcYZV2p9e2K5px2/XbeLQtehYACN/7dmAJjep5SNb1c7XPu/rL4yoWzOzfIqNL2LeOn4wsGtqmdUb3FzbPCPiXcMrhFhcrtnj2i3RgtoFrhG72almvQO7dQ+9M41cYe8YCaLj7qoZwmC4yyrvrVF9zZsnpmy8tHYhf6JICAgit1ZFGa6vRa8PHSuoK1EFBwizemUcFPDQ/qQ9AvcXaFYvDSuoJCCCi4hX4Gjnr6V/barexypX/i3MI5XlpXUAgBBbe4X/+A8YyPDu5bpg/4XjwysQt5aV1BIQQU3GL/KSRM+8NOr1F0XlpXUAgBBdf4sWNok674I/4tnOOldQV1EFBwj+OvF52VOK3HQqdXJg4vrSsog4CCqxz6fOGLk9787K/413Sel9YV1EBAAQAkIaAAAJIQUAAASQgoAIAkBBQAQBICCgAgCQEFAJCEgAIASEJAAQAkIaAAAJIQUAAASQgoAIAkBBQAQBICCgAgCQEFAJCEgAIASEJAAQAkIaAAAJIQUAAASQgoAIAkBBQAQBICCgAgCQEFAJCEgAIASEJAAQAkIaAAAJIQUAAASQgoAIAkBBQAQBICCgAgCQEFAJCEgAIASEJAAQAkIaAAAJIQUAAASQgoAIAkBBQAQBICCgAgCQEFAJCEgAIASEJAAQAkIaAAAJIQUAAASQgoAIAkBBQAQBICCgAgCQEFLine truncated
|
||||||
|
</div>
|
||||||
<div id="auto-breaks" class="section level4 unnumbered">
|
<div id="auto-breaks" class="section level4 unnumbered">
|
||||||
<h4 class="unnumbered">Auto Breaks</h4>
|
<h4 class="unnumbered">Auto Breaks</h4>
|
||||||
<pre class="r"><code>hist(age)</code></pre>
|
<pre class="r"><code>hist(age)</code></pre>
|
||||||
|
|||||||
+41
-21
@@ -24,9 +24,9 @@ if (!require(tidyverse)) {
|
|||||||
install.packages("tidyverse")
|
install.packages("tidyverse")
|
||||||
library(tidyverse)
|
library(tidyverse)
|
||||||
}
|
}
|
||||||
if (!require(moments)) {
|
if (!require(e1071)) {
|
||||||
install.packages("moments")
|
install.packages("e1071")
|
||||||
library(moments)
|
library(e1071)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -34,26 +34,30 @@ if (!require(moments)) {
|
|||||||
|
|
||||||
## Frequency Table ordered from wish.com
|
## Frequency Table ordered from wish.com
|
||||||
```{r}
|
```{r}
|
||||||
freq <- function(data) {
|
freq <- function(data, rounded_digits = 2) {
|
||||||
|
# counts
|
||||||
|
total_count <- length(data)
|
||||||
na_count <- length(data[is.na(data)])
|
na_count <- length(data[is.na(data)])
|
||||||
valid_count <- length(data) - na_count
|
valid_count <- total_count - na_count
|
||||||
|
|
||||||
frequency <- table(data)
|
frequency <- table(data)
|
||||||
p <- prop.table(frequency)
|
p <- prop.table(frequency)
|
||||||
percent <- round(p * 100, digits = 2)
|
valid_percent <- round(p * 100, digits = rounded_digits)
|
||||||
frequency_sum <- cumsum(frequency)
|
na_percent <- round(na_count / length(data) * 100, digits = rounded_digits)
|
||||||
hkum <- cumsum(p)
|
|
||||||
percent_sum <- round(hkum * 100, digits = 2)
|
|
||||||
freq_table <- cbind(frequency, percent, frequency_sum, percent_sum)
|
|
||||||
valid_percent <- round(valid_count / length(data) * 100, digits = 2)
|
|
||||||
na_percent <- round(na_count / length(data) * 100, digits = 2)
|
|
||||||
|
|
||||||
|
percent_raw <- frequency/total_count*100
|
||||||
|
percent <- round(percent_raw, digits = rounded_digits)
|
||||||
|
cumulative_percent <- round(cumsum(p) * 100, digits = rounded_digits)
|
||||||
|
freq_table <- cbind(frequency, percent, percent_raw, valid_percent, cumulative_percent)
|
||||||
|
|
||||||
print(freq_table)
|
valid_percent_sum <- round(sum(as.data.frame(freq_table)$percent_raw), digits = rounded_digits)
|
||||||
|
Valid_Total <- c(valid_count, valid_percent_sum, 100, NaN)
|
||||||
|
|
||||||
count <- c(valid_count, na_count, valid_count + na_count)
|
freq_table <- subset(freq_table, select = -c(percent_raw))
|
||||||
percent <- c(valid_percent, na_percent, valid_percent + na_percent)
|
|
||||||
df <- data.frame(count, percent, row.names = c("valid", "NA", "Total"))
|
NAs <- c(na_count, na_percent, NaN, NaN)
|
||||||
print(df)
|
Total <- c(total_count, 100, NaN, NaN)
|
||||||
|
print(rbind(freq_table, Valid_Total, NAs, Total))
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
*Source: https://tellmi.psy.lmu.de/tutorials/deskriptive-statistiken-und-grafiken.html#haeufigkeiten-diskret and adapted*
|
*Source: https://tellmi.psy.lmu.de/tutorials/deskriptive-statistiken-und-grafiken.html#haeufigkeiten-diskret and adapted*
|
||||||
@@ -67,6 +71,15 @@ getmode <- function(v) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Remove NA
|
||||||
|
```{r}
|
||||||
|
removeNA <- function(d){
|
||||||
|
return(d[!is.na(d)])
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Load Data
|
# Load Data
|
||||||
## Load from CSV
|
## Load from CSV
|
||||||
``` {r loadData}
|
``` {r loadData}
|
||||||
@@ -348,9 +361,8 @@ displayFunction1(litdata, "D8")
|
|||||||
We have the year 2021
|
We have the year 2021
|
||||||
## Preparation
|
## Preparation
|
||||||
```{r}
|
```{r}
|
||||||
birthyears <- litdata$D7
|
|
||||||
# remove NAs
|
# remove NAs
|
||||||
birthyears <- birthyears[!is.na(birthyears)]
|
birthyears <- removeNA(litdata$D7)
|
||||||
age <- 2021 - birthyears
|
age <- 2021 - birthyears
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -404,7 +416,6 @@ sd(age)
|
|||||||
|
|
||||||
### Schiefe
|
### Schiefe
|
||||||
```{r}
|
```{r}
|
||||||
library(moments)
|
|
||||||
skewness(age)
|
skewness(age)
|
||||||
```
|
```
|
||||||
> Die Kennzahl Schiefe ist wird Null bei einer perfekt symmetrischen Verteilung, größer als Null bei einer rechtsschiefen und kleiner als Null bei einer linksschiefen Verteilung.
|
> Die Kennzahl Schiefe ist wird Null bei einer perfekt symmetrischen Verteilung, größer als Null bei einer rechtsschiefen und kleiner als Null bei einer linksschiefen Verteilung.
|
||||||
@@ -412,8 +423,11 @@ https://www.beratung-statistik.de/statistik-beratung-infos/r-tutorial/deskriptiv
|
|||||||
|
|
||||||
### Kurtosis
|
### Kurtosis
|
||||||
```{r}
|
```{r}
|
||||||
kurtosis(age)
|
kurtosis(age, type = 2)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
*SPSS berechnet die Kurtosis mit einer anderen [Formel](https://rdrr.io/rforge/e1071/man/kurtosis.html).*
|
||||||
|
|
||||||
> Eine weitere bekannte Kennzahl ist die Kurtosis. Um eine Vorstellung von der Bedeutung der Kurtosis zu erhalten, betrachten Sie nachfolgende Graphik.
|
> Eine weitere bekannte Kennzahl ist die Kurtosis. Um eine Vorstellung von der Bedeutung der Kurtosis zu erhalten, betrachten Sie nachfolgende Graphik.
|
||||||
In dieser Graphik sind eine Normalverteilung, sowie eine steilgipflige (aka leptokurtisch) und eine flachgipflige (aka platykurtisch) dargestellt.
|
In dieser Graphik sind eine Normalverteilung, sowie eine steilgipflige (aka leptokurtisch) und eine flachgipflige (aka platykurtisch) dargestellt.
|
||||||
Die steilgipflige Verteilung ist in der Mitte spitzer als die Normalverteilung und an den Rändern breiter. Bei der flachgipligen Verteilung ist es anders herum. Die Kurtosis ist nun eine Kennzahl, mit der untersucht wird, ob eine Verteilung im Vergleich zur Normalverteilung flachgipflig oder steilgipflig ist:
|
Die steilgipflige Verteilung ist in der Mitte spitzer als die Normalverteilung und an den Rändern breiter. Bei der flachgipligen Verteilung ist es anders herum. Die Kurtosis ist nun eine Kennzahl, mit der untersucht wird, ob eine Verteilung im Vergleich zur Normalverteilung flachgipflig oder steilgipflig ist:
|
||||||
@@ -433,6 +447,12 @@ qqline(age)
|
|||||||
|
|
||||||
### Historam for age {.tabset}
|
### Historam for age {.tabset}
|
||||||
|
|
||||||
|
#### Frequency {-}
|
||||||
|
```{r}
|
||||||
|
hist(age, freq = F)
|
||||||
|
lines(density(age), lwd = 2, col = "black")
|
||||||
|
```
|
||||||
|
|
||||||
#### Auto Breaks {-}
|
#### Auto Breaks {-}
|
||||||
```{r}
|
```{r}
|
||||||
hist(age)
|
hist(age)
|
||||||
|
|||||||
Reference in new issue
Block a user