Docsity

Statistics lecture notes and slides, Appunti di Statistica

Toggle sidebar
bg1
1
What is Statistics?
• Statistics is the study of data and how it can be collected, organized, analyzed and interpreted to
obtain insights.
• Descriptive statistics focuses on organizing and summarizing data so that it is better
understood: you collected your data and with this statistics you rearrange the list.
• Inferential statistics leverages data from a small group to arrive at conclusions about the entire
population of which the small group is a part. E.g., instead of collecting all information of all
Italians for instance, I will select wisely a subgroup of Italians and we will use this information
to get insights on the entirety of population. We need to know how to compute probability.
N.B Square brackets are used for intervals in which the two numbers are included,
whereas round brackets mean that the value is not included in the interval .
BASIC CONCEPTS
Variables and Data
At the heart of statistics are variables and data:
• A variable is a characteristic of individuals or objects that I want to study e.g., students ‘grades,
height, and income are all variables of students.
Variables have values they can attain → they can be words or numbers e.g.; student’s mark can
have any value between 0 and 100.
• Data are the observed values of the variables (it is what we collect, analyse and report) e.g.,
we can record data on the grades of all students in our class (for example {67, 74,71,83,93, 55,48
Data Types
Data can be qualitative or quantitative:
• quantitative (values are numbers):
quantitative data are numerical (e.g.,
height, income, age)
Quantitative data can be further
characterized as
o continuous → result of a
measurement process → values
expressed with decimals/real
numbers (e.g. profit/income:
£300.980, 04; average time: 2,5min
which is 2min30s)
o discrete → result of a counting
process → values expressed in integers/natural numbers ((e.g. years in business: 4ys;
number of customers: 5670)
• qualitative (values are words): qualitative data are categorical (e.g., marital status, gender,
laptop brand name).
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13

Anteprima parziale del testo

Scarica Statistics lecture notes and slides e più Appunti in PDF di Statistica solo su Docsity!

What is Statistics?

  • Statistics is the study of data and how it can be collected, organized, analyzed and interpreted to obtain insights.
    • Descriptive statistics focuses on organizing and summarizing data so that it is better understood: you collected your data and with this statistics you rearrange the list.
    • Inferential statistics leverages data from a small group to arrive at conclusions about the entire population of which the small group is a part. E.g., instead of collecting all information of all Italians for instance, I will select wisely a subgroup of Italians and we will use this information to get insights on the entirety of population. We need to know how to compute probability. N.B Square brackets are used for intervals in which the two numbers are included, whereas round brackets mean that the value is not included in the interval. BASIC CONCEPTS Variables and Data At the heart of statistics are variables and data:
    • A variable is a characteristic of individuals or objects that I want to study e.g., students ‘grades, height, and income are all variables of students. Variables have values they can attain → they can be words or numbers e.g.; student’s mark can have any value between 0 and 100.
    • Data are the observed values of the variables (it is what we collect, analyse and report) e.g., we can record data on the grades of all students in our class (for example {67, 74,71,83,93, 55, Data Types Data can be qualitative or quantitative :
    • quantitative (values are numbers): quantitative data are numerical (e.g., height, income, age) Quantitative data can be further characterized as o continuous → result of a measurement process → values expressed with decimals /real numbers (e.g. profit/income: £300.980, 04; average time: 2,5min which is 2min30s) o discrete → result of a counting process → values expressed in integers /natural numbers ((e.g. years in business: 4ys; number of customers: 5670)
    • qualitative (values are words): qualitative data are categorical (e.g., marital status, gender, laptop brand name).

Scales of Measurement In which unit these variables are measured? There are four broad scales of measurements: nominal, ordinal, interval and ratio and they determine the type of analysis that can be conducted on a variable.

  1. Where do you live?
  2. What is your gender?
  3. What is your marital status? These three are qualitative variables measured in a nominal scale → they can only be measured in terms of distinct categories as there is no ordering to nominal data and we cannot apply arithmetic operations on these data. However, we can study counts and proportions of nominal data
  4. State your level of education (high school, some college, bachelor’s degree, master’s degree or higher)
  5. How satisfied are you with your current cell phone provider (not at all satisfied, somewhat satisfied, or extremely satisfied)? These are values measured on an ordinal scale → this allows to rank order the items we measure. e.g.; a bachelor is less than a master degree. Still, we cannot quantify the difference between the different levels of satisfaction for instance.
  6. What is your SAT score? Quantitative value measured on an interval scale e.g., temperature
  7. What is your annual income (in thousands of dollars)?
  8. What is your age? Quantitative value measured on a ratio scale Qualitative values can be measured:
    • on a NOMINAL SCALE: the values cannot be ordered (e.g. gender, name marital status)
    • on a ORDINAL SCALE: the values have an order (e.g. level of education) → thus arithmetic operations beyond counts and proportions are meaningless; the difference between the two is that ordinal scales provide insights on the rank order of items, allowing us to make statements such as ‘A is greater than B’ → if you’re asked to rank your satisfaction from 1 (unsatisfied) to 5 (completely satisfied), that is an ordinal scale; the same holds true for “how often do you send emails?”: once a week, once a month, few times a year, never

A key concept in sampling is randomness and it has to do with the chances of each person/object in the population to be selected for the study → Random sampling means that samples are chosen so that every sample in a population has an equal chance of being chosen → it is important to prevent bias! (if a certain group is over/underrepresented, the sample is considered to be biased, and it could lead to inaccurate conclusions about a population) There are several causes of sampling bias: o The timeframe at which data are collected o Certain subjects may be more likely to be selected (biased selection by either researchers (e.g. choose friends, or haven’t advertised the study that much) or subjects themselves (often the people who take the time to respond to surveys are those who really care about the topic)) Statistical sampling methods: o Simple Random Sample : samples are randomly selected from the population Randomness is defined by the chances of being selected: every subject has an equal chance of being selected E.g. select a simple random sample of 10 people from a population consisting of 100 people. You can assign each person in the population a number (from 1 to 100) and then use a random number generator to select 10 people from this population. A specific type of random sampling is the systematic sample, in which you sample every k th person from the population (in our example, every 10th person) o Stratified Random Sample : take into account different layers within the population E.g. survey the opinions about the difficulty of the DIS program from students. Randomly select a sample of students from each of the program’s years. We ensure that our sample is representative of the population by also keeping the same ratio of sample sizes as the ratio of the population strata (indeed, the respective sample sizes (inner rectangles in the picture) mimic the size of the population) Stratified sampling is beneficial to ensure that enough data from each category is collected to make a meaningful inference, and it also allows us to draw conclusions within each of the groups o Cluster Sample : focuses on representative subsets within a population E.g. we wish to study Maths performance of elementary school students. The city school district with 8 elementary schools is the population (the rectangle) and we randomly select 3 of these schools (clusters) for our sample. Within each of the 3 schools, we select a random sample of students for our study. It is used when it’s difficult or impractical to randomly draw samples across an entire population. It is important that the clusters from which the samples are drawn are representative of the population. Otherwise, the samples, themselves, will not be representative of the population → the clusters must be homogeneous!→ since the clusters are homogeneous, they are interchangeable! (≠ stratified random sample, which is used when the layers are not homogeneous)

The Sample Size depends on 4 criteria: a. Population size : the larger the population, the larger the sample should be b. Population variation (= extent to which members of the population differ from each other; e.g. high variation in the income of Chicago residents; low variation in the income of students in a private school in an upper-class area - thus in Chicago you would have to obtain a much larger sample-to-population size ratio to adequately represent this population): the larger the variation in the population, the larger the sample (and the larger the sample-to-population size ratio) should be c. Resources available : the more resources available to you, the larger the sample can be d. Amount of error that can be tolerated : the more tolerant you are of error, the smaller the sample can be. Sampling error : difference between the sample statistic and the population parameter E.g. if you measure each and every person in the class, you’d obtain the true average height for the class. This true average is called the population parameter. If you take a sample of 20 students, you would obtain an estimate of the true average based on your sample. This is called the sample statistic A survey of 100% of the population would result in a sampling error of zero. However, as you reduce the sample size, you’d generally be working with a less accurate representation and increasing the sampling error It would make most sense for you to obtain the largest sample you are able to obtain. Nevertheless, if you are just after a general estimate of the population parameter and would be happy with a rough figure, you can reduce your sample size (and save your resources!) → it’s difficult to judge the size of a sample based if we don’t have much information about it (e.g. a survey on the opinions of 40 top M.&A. bankers and lawyers). In order to know if a sample is sufficiently large, we’d need to know the total population size, the extent their opinions vary (population variation), whether we can afford to survey more people (available resources), and how accurate we want or need to be in our conclusions (tolerable error) Errors:

  • Sampling errors: refer to the difference between the sample statistic and the population parameter → e.g. a survey shows 51% of students work, when, in fact, only 50.42% work
  • Non-sampling errors: refer to errors in data acquisition: o Inaccuracies and mistakes (e.g. when typing data into a database) o Responses that are not truthful → one may lie about their age or their behaviours o Response/Non-response bias: only people with a certain agenda or interest in the topic respond to the survey o Selection bias: sampling problems Data Collection We can collect data directly ( primary data ) or we can use data collected by others ( secondary data ), namely, market research companies, ISTAT, financial institutions, etc. To obtain data, we need to decide on the most suitable data collection method, primarily surveys, experiments, observations or interviews. o Surveys : questionnaires distributed to members of a sample, asking them to respond to a set of predefined questions They may be paper-based, sent by mail, by phone, handed in person, or delivered online. Paper- based ones are resource-intensive and require data to be typed into a database by a person (ergo, input errors are inevitable!). Instead, web-based surveys are automatically registered, can be distributed to a large, geographically-dispersed sample, are cheaper to make and distribute, allow

Frequency Tables for Qualitative Data → qualitative data are those measured on the nominal and ordinal scales, and the only operation we can perform with such data are counts and proportions Which country dominated the 2016 Summer Olympics? Based on your data, you construct the frequency table, which lists the true medal counts for the top ten countries. Each row provides a value (i.e., a country) alongside this value’s observed frequency (i.e., the number of gold medals won by the country) → a pie chart could also be used Another example: you survey 30 co-workers ( statistical unit ) to obtain the following data on their mobile providers ( variable ) We could also use bar charts and pie charts to represent data: Frequency Tables for Quantitative Data Quantitative data are numerical and can be either discrete (integers - countable) or continuous (generally uncountable, as listing all the values present in a data set would result in much too large a frequency table). For the most part, with quantitative data we cannot simply list all the values in our data set since often that would result in very large frequency tables. For example, if we wish to observe the frequencies of grades on a percentage scale, it does not make sense to have a table with 100 rows for each possible grade: We group values into classes before constructing a frequency table. Classes must be mutually exclusive and exhaustive :

  • Mutually exclusive means that each value falls in only one class.
  • Exhaustive means that all values are represented in the table

There are 3 important points we can make with respect to this example: a) We still have a relatively large number of classes (10) for a relatively small number of observations (50) → we may wish to consider a different way of grouping data into classes (e.g. representing the grades A, B, C, D, F) b) Since we defined our classes in terms of integers, we are not capable of handling half grades like 79.5 (would you place it in class 8 or 9) c) We defined our classes arbitrarily as intervals of 10 and some of these have very low frequencies, so it may be better to first consider the data and research requirements before defining classes → 2 important decisions involved in constructing frequency tables: 1) determining the number of classes to use, and 2) determining the width of these classes Creating Classes Step 1: Number of Classes ➢ There are no strict rules for determining the right number of classes to use, and the decision is generally guided by the number of observations in the data set, the researcher’s knowledge of what is being described by the data, and other research requirements ➢ rule of thumb: any number between five and twenty classes is acceptable ➢ the alternative is Sturges’ formula , which offers a way to calculate the number of classes to use for a data set of size n: E.g. if there are 200 observations in the above data set and no business logic to determine the optimal amount of classes, we can use Sturges’ formula as: 1+3.3*log(200)= 8.59 = 9 classes (best to always round up classes to ensure that no values are left out!)

  • The commute times of 200 students at State University (in minutes) is shown in the table below: ➢ Statistical unit: students ➢ Variable. Commute time ➢ Unit of measurements= minutes Step 2: Class Width ➢ The class interval defines the lower and upper boundaries for the values to be included in each class. ➢ We aim to create our classes with more or less equal intervals so that no one interval is artificially over- (or under-) represented by being larger (or smaller) than the others. ➢ Divide the range of the data by the number of classes. ➢ Range=largest minus the smallest value in our dataset. So, 8.34 is the class interval E.g. class width = (90 (largest commute) - 15 (shortest commute))/9 = 75 (range) / 9 (number of classes) = 8.34 → better to use rounding again, for a class width of 9 minutes though we can still use decimals

Stem and Leaf Plot A different way of graphing quantitative data

  • Stem and Leaf plot displays data broken into the stem , which is on the left hand side of the line and represents the grouping level of the data, and the leaves , shown on the right hand side of the line If we are dealing with grades, we divide each grade into two parts: the tens digits become the stem (e.g. 3 is the stem in 34) and the units digits become the leaves (e.g. 4 would be the leaf in 34) Hence, each row in the stem-and-leaf plot shows the grades for a given range of data values. It helps us visualise the shape and distribution of the data in a manner similar to a histogram. However, with this graph, we do not lose potentially useful information about the data itself, and we can still see where the majority of grades are (here the 50-79 range) Relative Frequency To compare two data sets, you’d use relative frequency or cumulative relative frequency Relative frequency: describes the frequency of the occurrence of specific values as a percent out of the total number of observations To create the relative frequency table, we divide the frequency of each class by the total number of observations Example : you compare 800 students who did not take a speed-reading course and 300 who took the course. First, we construct a frequency distribution table. As these data are quantitative , will use classes to create our frequency table - in this case, class widths of 100 wpm, as they are representative of different reading skills. We use a new notation in this table: we use the notation fi to represent the frequency (f) of class i. So f3 (frequency of class 3, i.e. 400-499) would equal 210 for the ‘No Course’ group and 86 for the ‘Course’ group. However, with this graph it is difficult to draw conclusions, given that group sizes are different Histogram Comparing these two histograms shows a relatively similar pattern in the data, with both graphs displaying an increasing number of students up to the 599wpm speed. Nevertheless, it is difficult and somehow misleading to compare the two histograms directly because there are fewer people in the ‘Course’ group (300 vs 800)

What we need is some measure of the number of people who fall in each class, relative to the size of the group. The relative frequency is the measure we are looking for, as it describes the frequency of occurrence of specific values as a percentage of the total number of observations. To create the relative frequency (rfi) distribution table, we divide the frequency of each class (fi) by the total number of observations (N) → rfi = fi/N The relative frequency provides a more accurate view of the share of each class (out of the total number of observations) in a data set. You can obtain a similar view of the data by using a pie chart A pie chart displays how the total data set (the whole pie, or 100%) is divided among the five classes: the larger the slice, the larger the relative frequency of that class. Comparing the two purple slices, which represent the class of 500 wpm to 599 wpm, we can see that this constitutes a larger part of the pie on the right, which is the pie chart for the ‘Course’ group. Further, compare the area captured by the two lower classes (red and blue) and you can see that it is smaller in the ‘Course’ group than in the ‘No Course’ group Cumulative Relative Frequency Another type of analysis you can do is add together the relative frequencies of these two classes (the dark blue - 200 to 299 - and red - 300 to 399 - slices) and compare these combined shares for both groups. Note that 45% students in the ‘No Course’ group read at a slower pace (399 wpm or lower), compared with about a third of the students in the ‘Course’ group (33.67%). The above calculation provides us with what is called the cumulative relative frequency. The cumulative relative frequency is obtained by adding up the relative frequencies of classes as you move down a frequency table.

Other possible relationships we might observe using scatter plots are a negative linear relationship , where the variables move in opposite directions (e.g., the lower the price of a product, the higher the demand for the product), and nonlinear relationships. An example of a non-linear, or curvilinear, relationship is that of diminishing marginal productivity: adding additional units of labour contributes less and less to the total quantity of goods being produced. Line graphs are commonly used to describe time series data (aka the values of a given variable over time). From the graph you can clearly see the trends in the stock market over time. For example, the stock market crash of 2008-2009 is shown as the large dip in the centre of the line MEASURES OF CENTRALITY AND VARIATION Fundamental to any interpretation of data in statistics, as well as in other fields, is the context in which these data lie. Context refers to the circumstances or conditions in which an event occurs. A commonly used context is the distribution from which specific data values are drawn, for instance, you might wish to find out how your grade compares to the grades obtained by the others. Specifically, we need to understand two types of measures - those that describe the centre of the frequency distribution, called measures of centrality , and those that describe the dispersion of data around the centre of the distribution, called measures of variation. We describe distributions using: o Central tendencies (where the centre of the distribution lies) → mean, median, mode o Variation (how values are spread around the centre) → range, standard deviation, variance → we will work mostly with quantitative data (interval/ratio) Capital letter: variable (e.g. X) aka population values (e.g., N represents the size of the population) Lower case letter: value of the variable (E.g. x) aka sample values (e.g., n represents the size of a sample) Number of ?: small n (n)

MEASURES OF CENTRALITY

The central tendency of a frequency refers to where its centre lies, but there are different ways to statistically define a distribution’s centre : o centre is the most common class → mode o centre is the value that splits the distribution in half, meaning 50% of values below it → median o actual centre → mean The Mean

  • Arithmetic mean , or the average, of a set of numbers is calculated by summing up all values and dividing this sum by the number of observations Example : you take all the grades obtained in Statistics by your 20 classmates, sum them up, and divide them by 20.
  • Geometric mean : the central number in a geometric progression → WE DON’T LOOK AT IT
  • Weighted mean : the average of a set of numerical values with varying weights Example : weighted GPA. You took three 3-credit courses and obtained 80; 75; 85, and two 4- credit courses with grades 90 and 95 The simple average of all five courses would be 85, but it does not account for different credit values Your weighted average is 85. Here n is the numer of observations (courses), w i is the weight assigned to each observation (course credits), and x i is the value of each observation (course grade) The Median o A value that divides the data in half so that half values are lower than it and half are higher o To compute the median, you need to sort the observations in ascending order o If n is odd: the median is the middle observation o If n is even: the median is the average of the middle two observations Example : to find the median of 10 SAT scores, you first put them from lowest to highest 1328, 1342, 1363, 1369, 1370, 1371 , 1381, 1410, 1441, 1463 → (1370+1371)/2 = 1370.5: this value divides the data so that exactly 5 observations are below it, and exactly five are above it To find the location of the median, you use L = 0.5(n+1) = o.511 = 5.5 (so the value of the median will be in between value in location 5 and value in location 6)

MEASURES OF VARIATION

Variance : variation means that not all people are created equal. Researchers are often interested in studying expected versus observed variance or in comparing the variance of two data sets under different scenarios Example : test scores of 10 students The mean is 77, and all students except for one got either below or above average test scores Plot: Compare two sections: The graph on the right shows higher variation around the mean Deviation : The distance between each student’s grade and the mean is called a deviation. These deviations represent the fact that the grades in this data set are not identical. o refers to the difference between each observation and the mean (e.g. each student’s grade and the mean of 77), thus representing that the values in the data set are not identical o the extent of deviations tells you the extent of variation that exists in the data o the sum of all deviations is zero (because of how the mean is computed, positive deviations cancel out negative deviations, so the sum of all deviations from the mean is always zero) and, therefore, we use the squared deviations in our calculation

Variance : o is calculated as the average of the squared deviations of a data set for population variance , we divide the sum of squared deviations by the population size (N) for sample variance , we divide the sum of squared deviation by the sample size minus 1 (n-1) The variance of the sample of ten quiz grades in our example is calculated as: Standard Deviation

  • Mathematically, the standard deviation is calculated as the squared root of the variance.
  • In our grades example:
  • Why? We used squared deviations to calculate the variance and, therefore, are using the squared root of the variance to get back to the scale of the data (grades between € 0and 100) The standard deviation can be used to compare the variability of several distributions and make a statement about the general shape of a distribution.
  • The higher the standard deviation, the wider the distribution is, meaning that the values in this population are spread and are different from each other.
  • A smaller standard deviation means that the values are clustered more closely around the mean. Shortcut Formula for Calculating Standard Deviation To calculate the standard deviation, first we calculate the variance and then take the square root of the value we obtain. But we may also use this formula: xi are the actual test scores recorded in our data set. xi^2 is a calculated value, computed by squaring each value of xi. At the bottom of the table are the sums of xi and xi^2. These are all the values needed for our shortcut variance formula Example of Standard deviation for Section 1 (Student Test Scores) By then calculating the one for Section 2, your work should reveal that the standard deviation for Section 2 (17.2434) is indeed larger than that of Section 1 (8.7813)

E.g. In the case of 10 SAT scores used earlier: 60th percentile L60 = (10+1)60/100 = 6.6 → the value located in place 6.6 is the 60th percentile o To calculate the actual value of the 60th percentile, you can use the weighted average E.g. the value is located 60% of the way between 1371 and 1381, so: 0.41371+0.6*1381= Interquartile Range

  • The 25th ,50th, and 75th percentiles are named quartiles.
  • The interquartile range (IQR), calculated as the difference between the first (Q1) and third (Q3) quartiles (i.e., the 25th and 75th percentiles), is another measure of the variability of a data set.
  • The interquartile range gives us a view of how the middle 50% of the data are spread. Box Plot A graphic representation of this interquartile range is called a box plot. There are five values of interest shown in the boxplot:
  • The minimum value in the data set.
  • The maximum value in the data set.
  • The three quartiles (25th, 50th and 75th percentiles). ❖ the distance between the first and third quartile is large, indicating a high spread of these data. ❖ the median is closer to the third quartile, indicating the lower values are more spread than the higher values (i.e., the distribution is negatively skewed). ❖ The two lines extending out at the top and bottom of the box are called the ‘whiskers’. Computing Outliers
  • Outliers are extreme observations , typically those that lie beyond 1.5 times the interquartile range away from the box.
  • To compute the threshold for outliers: ▪ Find the interquartile range (IQR)and multiplyitby1.5: 24*1.5= ▪ Then, add this value to the value of Q3 for the upper limit:44.75+36=80. ▪ and subtract it from the value of Q1 for the lower limit: 20.75-36=-15. ▪ In our example, only the top threshold matters.
  • If we decide to analyse the data further, we may wish to exclude outliers, as they represent extreme and potentially unusual cases and may bias our findings.