8.2 Chapter 2
Solution. 2.2
a. Discrete quantitative
b. Continuous quantitative
c. Discrete quantitative
d. Continuous quantitative
e. Nominal qualitative
f. Ordinal qualitative
g. Nominal qualitative
h. Continuous quantitative
i. Continuous quantitative
j. Ordinal qualitative
k. Continuous quantitative
l. Nominal qualitative
m. Continuous quantitative
Solution. 2.3
## [1] -4 1 3 5 7 9 10
# b
sx[4] # It is the fourth order statistic, or the fourth ordination value. Corresponds to the median.
## [1] 5
Solution. 2.4
h <- read.table('https://filipezabala.com/data/hospital.txt', header = T)
# a.
base::sort(h$children)
## [1] 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
## [57] 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 6
## [1] 1.51 1.52 1.53 1.54 1.55 1.55 1.56 1.56 1.56 1.56 1.57 1.57 1.58 1.58 1.58 1.58 1.58 1.59 1.59 1.59 1.59 1.59
## [23] 1.59 1.59 1.59 1.60 1.60 1.60 1.60 1.60 1.60 1.60 1.60 1.61 1.61 1.61 1.61 1.61 1.61 1.61 1.62 1.62 1.62 1.62
## [45] 1.62 1.62 1.62 1.62 1.62 1.62 1.63 1.63 1.63 1.63 1.63 1.64 1.64 1.64 1.64 1.64 1.64 1.64 1.64 1.64 1.64 1.64
## [67] 1.65 1.65 1.65 1.65 1.65 1.65 1.65 1.65 1.65 1.65 1.66 1.66 1.66 1.66 1.66 1.66 1.66 1.67 1.67 1.67 1.68 1.68
## [89] 1.68 1.68 1.68 1.69 1.69 1.69 1.70 1.70 1.70 1.72 1.73 1.74
## [1] 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
## [57] 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 6
## [1] 1.51 1.52 1.53 1.54 1.55 1.55 1.56 1.56 1.56 1.56 1.57 1.57 1.58 1.58 1.58 1.58 1.58 1.59 1.59 1.59 1.59 1.59
## [23] 1.59 1.59 1.59 1.60 1.60 1.60 1.60 1.60 1.60 1.60 1.60 1.61 1.61 1.61 1.61 1.61 1.61 1.61 1.62 1.62 1.62 1.62
## [45] 1.62 1.62 1.62 1.62 1.62 1.62 1.63 1.63 1.63 1.63 1.63 1.64 1.64 1.64 1.64 1.64 1.64 1.64 1.64 1.64 1.64 1.64
## [67] 1.65 1.65 1.65 1.65 1.65 1.65 1.65 1.65 1.65 1.65 1.66 1.66 1.66 1.66 1.66 1.66 1.66 1.67 1.67 1.67 1.68 1.68
## [89] 1.68 1.68 1.68 1.69 1.69 1.69 1.70 1.70 1.70 1.72 1.73 1.74
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [,15] [,16] [,17] [,18] [,19]
## children 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
## [,20] [,21] [,22] [,23] [,24] [,25] [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
## children 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49] [,50] [,51] [,52] [,53] [,54] [,55]
## children 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
## [,56] [,57] [,58] [,59] [,60] [,61] [,62] [,63] [,64] [,65] [,66] [,67] [,68] [,69] [,70] [,71] [,72] [,73]
## children 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3
## [,74] [,75] [,76] [,77] [,78] [,79] [,80] [,81] [,82] [,83] [,84] [,85] [,86] [,87] [,88] [,89] [,90] [,91]
## children 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4
## [,92] [,93] [,94] [,95] [,96] [,97] [,98] [,99] [,100]
## children 4 4 4 4 4 4 4 5 6
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [,15] [,16] [,17] [,18] [,19]
## height 1.51 1.52 1.53 1.54 1.55 1.55 1.56 1.56 1.56 1.56 1.57 1.57 1.58 1.58 1.58 1.58 1.58 1.59 1.59
## [,20] [,21] [,22] [,23] [,24] [,25] [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
## height 1.59 1.59 1.59 1.59 1.59 1.59 1.6 1.6 1.6 1.6 1.6 1.6 1.6 1.6 1.61 1.61 1.61 1.61
## [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49] [,50] [,51] [,52] [,53] [,54] [,55]
## height 1.61 1.61 1.61 1.62 1.62 1.62 1.62 1.62 1.62 1.62 1.62 1.62 1.62 1.63 1.63 1.63 1.63 1.63
## [,56] [,57] [,58] [,59] [,60] [,61] [,62] [,63] [,64] [,65] [,66] [,67] [,68] [,69] [,70] [,71] [,72] [,73]
## height 1.64 1.64 1.64 1.64 1.64 1.64 1.64 1.64 1.64 1.64 1.64 1.65 1.65 1.65 1.65 1.65 1.65 1.65
## [,74] [,75] [,76] [,77] [,78] [,79] [,80] [,81] [,82] [,83] [,84] [,85] [,86] [,87] [,88] [,89] [,90] [,91]
## height 1.65 1.65 1.65 1.66 1.66 1.66 1.66 1.66 1.66 1.66 1.67 1.67 1.67 1.68 1.68 1.68 1.68 1.68
## [,92] [,93] [,94] [,95] [,96] [,97] [,98] [,99] [,100]
## height 1.69 1.69 1.69 1.7 1.7 1.7 1.72 1.73 1.74
Solution. ??
- Discrete quantitative.
- \(f_3 = 50-(17+10+8+5+1)=9\). 9 parts have 2 defects.
- \(f_{r_{3}} = 9/50 = 0.18\). 18% of parts have 2 defects.
- \(F_4 = 44\). 44 parts have up to 3 defects.
- \(F_{r_{5}} = 49/50 = 0.98\). 98% of parts have up to 4 defects.
Solution. 2.8
Median: half (\(1/2=50\%\)) of the values are below and the other half above 1.625.
Tertile 1: one third (\(1/3=33.3\%\)) of the values are below and two thirds (\(2/3=66.7\%\)) are above 1.61.
Tertile 2: two thirds (\(2/3=66.7\%\)) of the values are below and one third (\(1/3=33.3\%\)) are above 1.65.
Quartile 1: one-quarter (\(1/4=25\%\)) of the values are below and three-quarters (\(3/4=75\%\)) are above 1.598.
Quartile 2: Equivalent to the median.
Quartile 3: three-quarters (\(3/4=75\%\)) of the values are below and one-quarter (\(1/4=25\%\)) are above 1.650.
Decile 1: one tenth (\(1/10=10\%\)) of the values are below and nine tenths (\(9/10=90\%\)) are above 1.569.
…
Solution. 2.9
- By definition, the median is the value that limits to its left 50% of the ordered values, as well as those to the right. The same occurs with the second quartile, which divides two quarters (\(2/4=50\%\)) both to its left and right, therefore being equivalent to the median.
- Yes, just limit 50% of the values to the left and right.
- Some suggestions: \(k=5\) quintile, \(k=6\) sextile, \(k=7\) septile, \(k=8\) octyl, \(k=9\) eneil, \(k=11\) undecil, \(k=12\) dodecyl.
- \(k-1\).
Solution. 2.10
h <- read.csv('https://filipezabala.com/data/hospital.csv')
quantile(h$filhos, probs = seq(0, 1, 1/2)) # Median
## 0% 50% 100%
## NA NA NA
## 0% 33.33333% 66.66667% 100%
## NA NA NA NA
## 0% 25% 50% 75% 100%
## NA NA NA NA NA
## 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
## NA NA NA NA NA NA NA NA NA NA NA