Docsity

Appunti corso Statistics - prof. Marella, Dispense di Statistica

Toggle sidebar
bg1
STATISTICS - Prof. Daniela Marella
12 set 2023
Data types and frequencies pt. 1
Basic definition
“Statistics is a scientific discipline providing the principles and methods for the collection, organization, analysis and
interpretation of data”.
Basic statistical terms
Population = the collection of the entities of the analysis.
Sample = subset of the units of the population obtained after a process of selection.
Statistical unit = the individual member of the population of the analysis.
Variable = any characteristic of the statistical units that we want to analyze (es: grade in statistics exam).
Variables are classified as:
- Qualitative —> expressed by categories (es: gender, hair color, job, city of birth…)
o They are mutually exclusive (a unit only has one category).
o Divided in:
▪ Nominal —> if categories can’t be arranged (es: religion, payment method…).
▪ Ordinal —> if categories can be ordered (es: army rank, degree of satisfaction…).
- Quantitative —> expressed by numbers (es: salary, expenses, number of cars…)
o They are discrete if has a countable number of possible values (es: n° of students attending a lecture of a
course, household size…).
o They are continuous if it can take all values on intervals of real numbers (es: length of a bar,
temperature…).
Percentage differencies
Let A and B be two numbers with the same unit of measurement and let A be the reference value.
The absolute difference is given by B - A.
The relative difference is given by (B-A)/A.
The percentage difference is given by 100*((B-A)/A).
Example:
A = 60.665 (in millions, Italy 2015).
B = 66.420 (in millions, France 2015).
Absolute diff. —> B - A = 66.420 - 60.665 = 5.755
Percentage diff. —> 100*((B-A)/A) = 100*((66.420 - 60.665)/60.665) = 9.49%
• “In 2015 population in France is 9.49% higher than population in Italy”
Ratios
Given a set of quantities a1, a2, …, ak such that a1 + a2 + … + ak = A
The percentage ratios 100a1/A, 100a2/A, …, 100ak/A expresses the quantities an as percentages of the total A.
Example:
a1 = 30.394 (female population in millions, Italy 2021).
a2 = 28.864 (male population in millions, Italy 2021).
A = 59.258 (total population in millions, sum of the two).
Then 100*(a1/A) = 100*(30.394/59.258) = 51.29% is the percentage of females.
While 100*(a2/A) = 100*(28.864/59.258) = 48.71% is the percentage of males.
• The ratio 100*(a2/a1) = 100*(28.864/30.394) = 94.97 informs that we have 94.97 males for each 100 females.
• This is known as the sex-ratio.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25

Anteprima parziale del testo

Scarica Appunti corso Statistics - prof. Marella e più Dispense in PDF di Statistica solo su Docsity!

STATISTICS - Prof. Daniela Marella

12 set 2023 Data types and frequencies pt. 1 Basic definition “Statistics is a scientific discipline providing the principles and methods for the collection, organization, analysis and interpretation of data”. Basic statistical terms Population = the collection of the entities of the analysis. Sample = subset of the units of the population obtained after a process of selection. Statistical unit = the individual member of the population of the analysis. Variable = any characteristic of the statistical units that we want to analyze (es: grade in statistics exam ). Variables are classified as:

  • Qualitative —> expressed by categories (es: gender, hair color, job, city of birth…) o They are mutually exclusive (a unit only has one category). o Divided in: ▪ Nominal —> if categories can’t be arranged (es: religion, payment method…). ▪ Ordinal —> if categories can be ordered (es: army rank, degree of satisfaction…).
  • Quantitative —> expressed by numbers (es: salary, expenses, number of cars…) o They are discrete if has a countable number of possible values (es: n° of students attending a lecture of a course, household size…). o They are continuous if it can take all values on intervals of real numbers (es: length of a bar, temperature…). Percentage differencies Let A and B be two numbers with the same unit of measurement and let A be the reference value. The absolute difference is given by B - A. The relative difference is given by (B-A)/A. The percentage difference is given by 100*((B-A)/A). Example: A = 60.665 (in millions, Italy 2015). B = 66.420 (in millions, France 2015). Absolute diff. —> B - A = 66.420 - 60.665 = 5. Percentage diff. —> 100((B-A)/A) = 100((66.420 - 60.665)/60.665) = 9.49%
  • “In 2015 population in France is 9.49% higher than population in Italy” Ratios Given a set of quantities a 1 , a 2 , …, ak such that a 1 + a 2 + … + ak = A The percentage ratios 100a 1 /A, 100a 2 /A, …, 100ak/A expresses the quantities an as percentages of the total A. Example: a 1 = 30.394 (female population in millions, Italy 2021). a 2 = 28.864 (male population in millions, Italy 2021). A = 59.258 (total population in millions, sum of the two). Then 100(a 1 /A) = 100(30.394/59.258) = 51.29% is the percentage of females. While 100(a 2 /A) = 100(28.864/59.258) = 48.71% is the percentage of males.
  • The ratio 100(a 2 /a 1 ) = 100(28.864/30.394) = 94.97 informs that we have 94.97 males for each 100 females.
  • This is known as the sex-ratio.

Frequency distribution It’s a table that lists the values of X variables and the corresponding frequencies. Starting from a long list of values, it allows to summarize the main characteristics of the phenomenon under study. Value of X Frequency x1 n x2 n .. .. xk nk Total N n 1 is the n° of times we observe the value x 1. Es:

  • Agriculture frequency = 3 companies.
  • Service frequency = 6 companies.
  • Total = 20 companies. Repeatable with all the categories in the columns. Proportions (relative frequencies) They are given by: fi = ni/N. N = total n° of observations. Two properties hold:
  • 0 ≤ fi ≤ 1
  • f 1 + f 2 + … + fk = 1 Percentages They are given by: pi = 100fi. Two properties hold:
  • 0 ≤ pi ≤ 100
  • p 1 + p 2 + … + pk = 100 Cumulative frequencies Can be defined for quantitative variables. At a certain value, it’s the n° of observations that are less or equal to that value. Two properties hold:
  • Ni = n 1 + n 2 + … + ni
  • Nk = n 1 + n 2 + … + nk = N → the last cumulative frequency

Exercises MyLab 1

1.1 “Identify the population and the statistical unit for each of the following variables: a) Level of computerization of Italian companies. b) Unemployment in the European Union member states. c) Consensus of Italians regarding a specific legal provision. d) Expediture of Italian households for the purchase of foodstuffs.” a-ans) Population : the entirety of the companies of the Italian Republic. Statistical unit : a single Italian company. b-ans) Population : all EU individuals who can work (usually aged 15yo or over). Statistical unit : a single individual living in the EU. c-ans) Population : the whole Italian adult population. Statistical unit : a single Italian citizen. d-ans) Population : the whole number of Italian households. Statistical unit : a single Italian household. 1.2 “You want to conduct a survey on how students who attend a certain university course get to the university. Specify the population and statistical unit. Indicate the possible variables of interest, their nature and the values that can be taken by each of them.” Population : all the students attending the course at a certain university. Statistical unit : a single student attending the course at a certain university. Variable Variable’s value Means of transport Bus; car; scooter; bike; train; tram; shuttle-bus Travel time Many possibilities (grouped frequencies) Distance Many possibilities (grouped frequencies) Region of residence Neighborhood ; other cities; other provinces; other regions; other countries Cost Many possibilities (grouped frequencies) 2.2a “The following observations refer to the number of statistical tables contained in the pages from 213 to 232 of a statistical handbook: 1, 2, 1, 0, 4, 5, 4, 1, 1, 0, 1, 1, 0, 0, 0, 0, 4, 2, 2, 3 o Arrange the data in the form of frequency distribution. o Determine the cumulative frequency distribution (both absolute and relative).” Ans) —————————————————————————————————————————————————————— Value Frequency (ni) Cumulative f. (Ni) Cumulative rel. f. (Fi) 0 6 6 0.3 = 6/ 1 6 8 = 6+2 0.4 = 8/ 2 3 11 = 8+3 0.55 = 11/ 3 1 12 = 11+1 0.6 = 12/ 4 3 15 = 12+3 0.75 = 15/ 5 1 16 = 15+1 0.8 = 16/ Total (N) 20 20

15 set 2023 Data Types and frequencies pt. 2 Class closure We gotta decide a rule for the class closure. [a,b) —> left closed class. (a,b] —> right closed class. When we form classes, we lose information, observations are no longer known singularly. How to form them is subjective but there are 2 rules:

  • The higher the n° of classes, the smaller the width.
  • If possible, we define classes of equal width. For a class with limits ci- 1 and ci , the midpoint is defined by the formula:
  • xi = (ci- 1 + ci)/ Whereas the width is defined by:
  • di = ci - ci- 1 Frequency density If we have classes of different width, we compute the frequency density. They can always be computed (they indicate the frequency per unit of class width). The formula is:
  • hi = ni/di Bivariate frequency distribution It shows the joint frequencies for two (qualitative or quantitative) variables. Given the values x1, x2, x3, … of the variable X and the values y1, y2, y3, … of the variable Y, the joint frequencies count the n° of times each pair is observed. Times series It’s an ordered sequence of values of a quantitative variable recorded at regularly spaced times (each year, each month). Time: time interval or point time. Spatial series It’s a set of values of a quantitative variable arranged according to geographical locations.

19 set 2023 Describing data by graphs pt. 2 Pie chart It’s used to summarize the percentages of a categorical variable.

  • It’s drawn as a circle where each category is represented as a “slice of the pie”.
  • The size of each pie slice is proportional to the percentage of observations falling in that category. Graphs for time series (Line chart & Bar chart) A time-series is an ordered sequence of values of a quantitative variable recorded at regularly spaced times (each year, each month, …).
  • Time : time interval or point time.
  • Line chart and Bar chart : are the typical graphs for time series.
  • Times are on the horizontal axis and the values are on the vertical axis.
  • In the Line chart we draw points connected to visualize the trend, in the Bar chart we draw bars. Graphs for spatial series (Map chart) A spatial-series is a set of values of a quantitative variable arranged according to geographical locations.
  • Geographical maps : are used for spatial series because of their strong informative content.

Measures of central tendency The Measures of central tendency , or averages , are different ways to identify a central value. First of all we distinguish:

  1. Algebraic averages: arithmetic mean and quadratic mean.
  2. Positional averages: median, quartiles, etc… Arithmetic mean It’s the sum of the observations divided by the number of observations.
  • It’s the summary statistics most widely used.
  • Let X be a quantitative variable with values x 1 , x 2 , …, xN, the mean is: It has the following properties:
  1. X 1 =< 𝜇 =< XN → es: 𝜇 = 4.5, 3<4.5<
  2. N𝜇 = X 1 +X 2 +…+XN → es: 44.5=
  3. ∑i=1N^ (Xi – 𝜇) = 0 → es: (3 − 4.5) + (4 − 4.5) + (5 − 4.5) + (6 − 4.5) = 0
  4. ∑i=1N^ (Xi – 𝜇)^2 = min → es: ( 3 – 4.5)^2 + (4 – 4.5)^2 + (5 – 4.5)^2 + (6 – 4.5)^2 = 5
  5. If Y=a+bX then 𝜇Y=a+b𝜇
  6. If the obs. Are divided into L subsets of certain sizes with certain means then
  7. In presence of a frequency distribution with k values, the mean is or 𝜇 = 1/N ∑i=1K^ (Xi*ni) Grouped frequency distributions
  • In presence of a grouped frequency distribution with k classes, the mean can be computed after identify the class means 𝜇 1 , 𝜇 2 , …
  • In practice, we don’t know these quantities and estimate them as midpoints of the classes: x̄i = (ci- 1 + ci)/
  • The formula for the mean is the same of the 7th property but with x̄i instead of xi. Weighted averages
  • In some applications the observations X 1 , X 2 , …, XK have some weights.
  • Denote the weights with w 1 , w 2 , …, wK.
  • The weighted mean is then:
  • Remark: the mean of a frequency distribution is a weighted average with weights equal to the frequencies. Quadratic mean
  • If the observations are negative and positive (but the sign is not relevant), we can:
  1. Square the observations;
  2. Compute the mean;
  3. Take the square root.
  • These steps lead to the quadratic mean: The median
  • Consider the observations X 1 , X 2 , …, XN and the ordered sequence X(1), X(2), …, X(N).
  • The median is the quantity placed at the center of the ordered sequence of data.
  • It separates the first half of the ordered data and the remaining half.
  • If N is odd, the median m is the middle value → m = X ((N+1)/2).
  • Index numbers are used to measure the change in level of a single variable, or a group of variables, over time or space.
  • We distinguish:
    1. (Simple) index number.
    2. Composite index number. Fixed-base index numbers
  • Let us consider a time series, to each unit of time is assigned a value a 1 , a 2 , a 3 , …
  • To compute fixed-base index numbers:
  1. Identify a base period h.
  2. Divide each value by the value of the base period, ah.
  • We have: o I1|h = a 1 /ah o I2|h = a 2 /ah
  • Multiplying each index number by 100, we get the percentage fixed-base index numbers. Chain index numbers
  • To compute chain index numbers:
  1. Divide each value by the value of the previous period.
  • We have: o I2|1 = a 2 /a 1 o I3|2 = a 3 /a 2
  • Multiplying by 100, we get the percentage chain index numbers. Composite index numbers
  • To describe the change over time of a set of items (e.g. prices of goods and services) we have to summarize the single changes, using a composite index number.
  • Let us consider 3 goods and their prices in 2019 and 2020.
  • The ratios P 2020 /P 2019 are the simple index numbers.
  • To define the composite price index, we have to summarize the simple index numbers, taking into account the importance of the goods.
  • The importance is measured by the purchased value.
  • A weighted mean replaces the simple mean.
  • The price change of smartphone (1.5%) is more important than the price changes of pen (9.1%) or pizza (7.1%).
  • Simple mean = 5.9%
  • Weighted mean = 1.579% Variability
  • Variability describes the dispersion of the data.
  • The higher the variability, the higher the dispersion.
  • Measures of variability usually integrate measures of central tendency.
  • Grades of student A: 23 24 25 >> 𝜇A = 24
  • Grades of student B: 18 24 30 >> 𝜇B = 24 Variability in finance
  • An investor is interested not only in average monthly returns but also in the variability of returns.
  • Given two assets with the same average return of 2%, the investor will prefer the asset with lower or higher variability according to her/his risk attitude. Standard deviation
  • The most important measure is the standard deviation.
  • Given the observations x 1 , x 2 , …, xN, the standard deviation is obtained as:
  • The shortcut formula is given by: Standard deviation: properties
  1. It’s non-negative and it’s null if all observations are equal, that is if x 1 = x 2 = xN , then σ = 0.
  • Grades of student C: 24 24 24 >> σ = 0
  1. If we add the same number a (either positive or negative) to all the observations, the standard deviation does not change.
  • Grades of student D: 23+3 2 4+3 2 5+3 >> σ = 0.
  1. If we multiply the observations by the same number b (either positive or negative), the standard deviation is multiplied by | b |.
  • Grades of student E: 232 242 25*2 >> σ = 1. Standard deviation for frequency distributions
  • Given the observations x 1 , x 2 , …, xK , with frequencies n 1 , n 2 , …, nK , the standard deviation is: Standard deviation for grouped frequency distributions
  • When the observations are grouped in classes, then we need to compute the class mid-points, x̄ 1 , x̄ 2 , …, x̄K , then:

Shape of the distribution

  • A graphical inspection of a distribution provides an insight into its shape.
  • One aspect is skewness (or asymmetry).
  • Skewness implies a departure from symmetry. A distribution is symmetric if:
  1. X 1 and XK are equidistant from m (median) and have the same frequency ( n 1 = nK ).
  2. X 2 and XK- 1 are equidistant from m (median) and have the same frequency ( n 2 = nK- 1 ). Symmetric frequency distribution Properties:
  3. The mean equals the median, 𝜇 = m
  4. The sum of the deviations from mean raised to 3 is null,
  5. The 1st^ and 3rd^ quartile are equidistant from the median, q 3 – m = m – q 1 Non-symmetric distribution
  • Non-symmetric distributions are called skewed or asymmetric distributions.
  • First, we distinguish between: o Positive asymmetry ▪ Taking the median as reference point on the x-axis, it occurs if the longer tail of the distribution lies to the right of the median. o Negative asymmetry ▪ Taking the median as reference point on the x-axis, it occurs if the longer tail of the distribution lies to the left of the median. Measures of skewness
  1. The 1st^ measure is:
  • α 1 = (𝜇 – m)/σ
  • Interpretation: o α 1 < 0 → negative asymmetry o α 1 = 0 → symmetry o α 1 > 0 → positive asymmetry
  1. The 2nd^ measure is:
  • Interpretation: o α 2 < 0 → negative asymmetry

o α 2 = 0 → symmetry o α 2 > 0 → positive asymmetry

  1. The 3rd^ measure is:

    • Interpretation: o α 3 < 0 → negative asymmetry o α 3 = 0 → symmetry o α 3 > 0 → positive asymmetry Box Plot The box plot is a graph that describes the data using the so-called five-numbers summary :
  2. Minimum
  3. 1 st^ quartile q 1
  4. Median m
  5. 3 rd^ quartile q 3
  6. Maximum Characteristics:
  • It is also known as Box and Whiskers Plot.
  • The box plot is a rectangle (the box) joined to two vertical segments.
  • The inspection of a box plot provides:
  1. A measure of central tendency, the median.
  2. Two measures of variability, range (ΔC) and interquartile range (Δq).
  3. The sign and the strength of skewness, seeing the position of the median relative to q 1 and q 3. Exercises MyLab 2

Contingency table

  • A contingency table (or bivariate frequency distribution , or joint frequency distribution) is a two-way table with joint frequencies nij.
  • Variable X with s values. Variable Y with t values.
  • The table has: o S rows o T columns o S x T cells, S x T joint frequencies.
  • It is mainly used with two qualitative variables.
  • The lateral columns/rows’ values are the marginal distribution of X/Y , we can use them to compute the relative frequency of X and Y (ex: Y >> 114 and 106)
    • As shown above, also a conditional relative distribution of X/Y exists. In the example it shows the relative frequency of X when Y = North.
    • The conditional relative distribution of X/Y can be summarized in a table, as in the example below.
      • Dividing each joint frequency by its column total, we get the conditional relative frequency distributions of the row variable.
      • In the example, 35. 9 % of people live in the South and work in Industry.
      • In the example, 45.4% of people simply work in IT.
      • The table is constructable viceversa for the variable Y. Independence
    • In a contingency table, two variables are independent if the conditional relative frequency distributions are equal to each other.
    • Hence, we draw the Independence table.
      • In the example, 10.7% of males and 10.7% of females workers are in agriculture.
      • The table is constructable viceversa for the variable Y.
  • In an independence table , the joint frequencies are: o nij = (row tot * column tot)/N o nij = (ni0 * nj0)/N Complete dependence
  • Complete dependence is the opposite of independence.
  • One-to-one matching between the variables.
  • As shown in the example, in a situation of complete dependence, a sector can either and only increase, be stable or decrease. Association
  • In a contingency table, two variables are associated if they are not independent. Independence joint frequencies
  • We have to compute the (theoretical) independence joint frequencies (the frequencies we would observe in case of independence).
  • The formula is: ňij = (ni0 * n0j)/N
  • Then we compare the observed joint frequencies nij to ňij. Measuring association
  • We define as contingency the quantity: cij = nij – ňij
  • Then we define 3 measures of association based on the contingencies.
  • The 1st^ measure of association is the χ^2 (chi-square) index
  • nij = observed joint frequencies
  • ňij = independence joint frequency o χ^2 = 0 → independence o χ^2 > 0 → association

Regression and Correlation The scatterplot

  • Consider two quantitative variables, X and Y.
  • The (bivariate) observations are: (x 1 , y 1 ), (x 2 , y 2 ), …, (xN, yN)
  • These N pairs may be represented on the Cartesian plane using N points with coordinates (xi, yi), i = 1, …, N.
  • The graph is the scatterplot. The Bubble Chart
  • The bubble chart is a scatterplot, but each circle is proportional to the pair frequency.

Simple linear regression

  • The simple linear regression model assumes a statistical relationship between X and Y (both quantitative). o Y = β 0 + β 1 X
  • Y is the dependent variable.
  • X is the independent variable.
  • The relationship identifies a straight line.
  • β 0 and β 1 are the parameters. Parameters
  • β 0 is the intercept (ordinate at the origin, the value of Y when X=0 ). o When X=0 → Y = β 0 + β 1 *0 = β 0
  • β 1 is the line slope (the change in Y when X increases by one unit) o (β 0 + β 1 *11) – (β 0 + β 1 *10) = β 1 *11 - β 1 *10 = β 1 How to determine the parameters
  • How do we determine the parameters starting from the observed points?
  • Assign values to β 0 and β 1 ( b 0 and b 1 ) to identify the straight line which best approximates the observed points (that is, fits the observed points in the best way).
  • The criterion is the minimization of the sum of the squared distances between predicted values of Y and observed values of Y.
  • Define the regression line: ŷ = β 0 + β 1 x
  • The predicted values are: ŷi = β 0 + β 1 xi i = 1, 2, …, N
  • Comparing precited and observed values provide the prediction errors (or residuals): o ei = yi - ŷi i = 1, 2, …, N
  • Define:
  • The criterion is the minimization of the previous formulas, find the values b 0 and b 1 such that S is minimum.
  • The parameters are: