Section 2.2 The Sampled Data
The aim in statistics is to learn the characteristics of a population on the basis of a sample selected from the population. An essential part of this analysis involves consideration of variation in the data.
Subsection 2.2.1 Variation in Data
Variation is given a central role in statistics. To some extent the assessment of variation and the quantification of its contribution to uncertainties in making inference is the statisticianβs main concern.
Variation is present in any set of data. For example, 16-ounce cans of beverage may contain more or less than 16 ounces of liquid. In one study, eight 16 ounce cans were measured and produced the following amount (in ounces) of beverage:
\begin{equation*}
15.8,16.1,15.2,14.8,15.8,15.9,16.0,15.5
\end{equation*}
Measurements of the amount of beverage in a 16-ounce may vary because the conditions of measurement varied or because the exact amount, 16 ounces of liquid, was not put into the cans. Manufacturers regularly run tests to determine if the amount of beverage in a 16-ounce can falls within the desired range.
Subsection 2.2.2 Variation in Samples
Two random samples from the same population, while resembling the population, will nonetheless be different from each other. Suppose Doreen and Jung both decide to study the average amount of time students sleep each night and use all students at their college as the population. Doreen may decide to sample randomly 50 students from the entire body of collage students. Jung also collects a random sample of 50 students. The randomness in the sampling will result in Doreenβs sample consisting in different students than Jungβs sample and therefore exhibit different variation in sleeping patterns purely arising from sampling variation (as oppossed to variation arising from error in measuring sleep for a given students).
Both samples will however resemble the population. If Doreen and Jung took larger samples (i.e. the number of data values is increased), their samples and their characteristics, for example the average amount of time a student sleeps, would be closer to the actual population value. But still, their samples would still be, most probably, different from each other.
The size of a sample (often called the number of observations) plays a key role in determining the uncertainty regarding what we can learn from our data about the population. The examples you have seen in this book so far have been small for convenience, but are usually too small to learn something with relative certainty about a population. Samples of only a few hundred observations, or even smaller, can however be sufficient. In polling, samples that are from 1200 to 1500 observations are considered large enough and good enough if the survey is random and is well done. The theory of statistical inference, that is the subject matter of the second part of this book, provides justification for these claims as well as techniques to quantify the uncertainty arising from random sampling and make decisions about sample sizes.
Finally, for the reasons outlined above, if an investigator collects data they will often vary somewhat from the data someone else is taking for the same purpose. However, if two investigators or more, are taking data from the same source and get very different results, it is time for them to reevaluate their data-collection methods and data recording accuracy.
Subsection 2.2.3 Frequency
The primary way of summarizing the variability of data is via the frequency distribution. Consider an example. Twenty students were asked how many hours they worked per day. Their responses, in hours, are listed below:
\begin{equation*}
5,\; 6,\; 3,\; 3,\; 2,\; 4,\; 7,\; 5,\; 2,\; 3,\; 5,\; 6,\; 5,\; 4,\; 4,\; 3,\; 5,\; 2,\; 5,\; 3
\end{equation*}
work.hours <- c(5,6,3,3,2,4,7,5,2,3,5,6,5,4,4,3,5,2,5,3)
Next, let us create a table that summarizes the different values of working hours and the frequency in which these values appear in the data:
table(work.hours)
## work.hours ## 2 3 4 5 6 7 ## 3 5 3 6 2 1
Recall that the function β
tableβ takes as input a sequence of data and produces as output the frequencies of the different values.
We may have a clearer understanding of the meaning of the output of the function β
tableβ if we presented outcome as a frequency listing the different data values in ascending order and their frequencies. For that end we may apply the function βdata.frameβ to the output of the βtableβ function and obtain:
data.frame(table(work.hours))
## work.hours Freq ## 1 2 3 ## 2 3 5 ## 3 4 3 ## 4 5 6 ## 5 6 2 ## 6 7 1
A frequency is the number of times a given datum occurs in a data set. According to the table above, there are three students who work 2 hours, five students who work 3 hours, etc. The total of the frequency column, 20, represents the total number of students included in the sample.
The function β
data.frameβ transforms its input into a data frame, which is the standard way of storing statistical data. We will introduce data frames in more detail in SectionΒ 2.3 below.
A relative frequency is the fraction of times a value occurs. To find the relative frequencies, divide each frequency by the total number of students in the sample β 20 in this case. Relative frequencies can be written as fractions, percents, or decimals.
As an illustration let us compute the relative frequencies in our data:
freq <- table(work.hours)
freq
sum(freq)
freq/sum(freq)
## work.hours ## 2 3 4 5 6 7 ## 3 5 3 6 2 1
## [1] 20
## work.hours ## 2 3 4 5 6 7 ## 0.15 0.25 0.15 0.30 0.10 0.05
We stored the frequencies in an object called β
freqβ. The content of the object are the frequencies 3, 5, 3, 6, 2 and 1. The function βsumβ sums the components of its input. The sum of the frequencies is the sample size , the total number of students that responded to the survey, which is 20. Hence, when we apply the function βsumβ to the object βfreqβ we get 20 as an output.
The outcome of dividing an object by a number is a division of each element in the object by the given number. Therefore, when we divide β
freqβ by βsum(freq)β (the number 20) we get a sequence of relative frequencies. The first entry to this sequence is \(3/20 = 0.15\text{,}\) the second entry is \(5/20 = 0.25\text{,}\) and the last entry is \(1/20 = 0.05\text{.}\) The sum of the relative frequencies should always be equal to 1:
sum(freq/sum(freq))
## [1] 1
The cumulative relative frequency is the accumulation of previous relative frequencies. To find the cumulative relative frequencies, add all the previous relative frequencies to the relative frequency of the current value. Alternatively, we may apply the function β
cumsumβ to the sequence of relative frequencies:
cumsum(freq/sum(freq))
## 2 3 4 5 6 7 ## 0.15 0.40 0.55 0.85 0.95 1.00
Observe that the cumulative relative frequency of the smallest value 2 is the frequency of that value (0.15). The cumulative relative frequency of the second value 3 is the sum of the relative frequency of the smaller value (0.15) and the relative frequency of the current value (0.25), which produces a total of \(0.15 + 0.25 = 0.40\text{.}\) Likewise, for the third value 4 we get a cumulative relative frequency of \(0.15 + 0.25 + 0.15 = 0.55\text{.}\) The last entry of the cumulative relative frequency column is one, indicating that one hundred percent of the data has been accumulated.
The computation of the cumulative relative frequency was carried out with the aid of the function β
cumsumβ. This function takes as an input argument a numerical sequence and produces as output a numerical sequence of the same length with the cumulative sums of the components of the input sequence.
Subsection 2.2.4 Critical Evaluation
Inappropriate methods of sampling and data collection may produce samples that do not represent the target population. A naΓ―ve application of statistical analysis to such data may produce misleading conclusions.
Consequently, it is important to evaluate critically the statistical analyses we encounter before accepting the conclusions that are obtained as a result of these analyses. Common problems that occurs in data that one should be aware of include:
- Problems with Samples
-
A sample should be representative of the population. A sample that is not representative of the population is biased. Biased samples may produce results that are inaccurate and not valid.
- Data Quality
-
Avoidable errors may be introduced to the data via inaccurate handling of forms, mistakes in the input of data, etc. Data should be cleaned from such errors as much as possible.
- Self-Selected Samples
-
Responses only by people who choose to respond, such as call-in surveys, that are often biased.
- Sample Size Issues
-
Samples that are too small may be unreliable. Larger samples, when possible, are better. In some situations, small samples are unavoidable and can still be used to draw conclusions. Examples: Crash testing cars, medical testing for rare conditions.
- Undue Influence
-
Collecting data or asking questions in a way that influences the response.
- Causality
-
A relationship between two variables does not mean that one causes the other to occur. They may both be related (correlated) because of their relationship to a third variable.
- Self-Funded or Self-Interest Studies
-
A study performed by a person or organization in order to support their claim. Is the study impartial? Read the study carefully to evaluate the work. Do not automatically assume that the study is good but do not automatically assume the study is bad either. Evaluate it on its merits and the work done.
- Misleading Use of Data
-
Improperly displayed graphs and incomplete data.
- Confounding
-
Confounding in this context means confusing. When the effects of multiple factors on a response cannot be separated. Confounding makes it difficult or impossible to draw valid conclusions about the effect of each factor.
