Docsity

Applied Statistics - completo, Dispense di Statistica Applicata

Toggle sidebar
bg1
BIG DATA: Volume (huge volume of data), very complex and different (variety of data) and very fast
(velocity), in order to merge them together. It’s the mix of structure and unstructured data
DATA VISUALIZATION: interpretation of data = transforming collected complex data into something
everyone could understand (through graphs’ creation).
DASHBOARDING: it’s where we put the graphs of the analysis to make them readable to everyone, all the
companies are using it (they are linked with the data visualization)
BUSINESS ANALYTICS: analyzing data in order to build a business strategy or just create
knowledge\awareness inside the company.
VOC (VOICE OF THE CUSTOMER): it’s a sort of survey, it’s not spontaneous but it’s something that the
company is going to ask to customer to better understand their needs (very important in order to
understand my target and compete with my competitors). Collecting data from customers (quantitative
surveys) who want to make suggestions and tell their satisfaction rate.
PREDICTIVE MAINTENANCE: it’s a statical model that can predict if a product is going to have an issue, the
company is predicting the maintenance that is going to do at their own sold products (ex: all the
automotive companies are investing a lot on it because they’re going to increase the revenues)
BUSINESS INTELLIGENCE (BI): information-sharing through all company’s departments. Doing intelligence
collecting all the company’s data.
STATISTICAL ANALYSIS OF DATA
When talking about statistics we are today talking about big data.
Small data: data structured in a way that can be analyzed.
Dataset: It’s the starting point for data analysis, in which each row is a statistical unit: customer, order, day,
store, etc. and each column is a variable, i.e. information measured for each statistical unit (in the example
store)
Statistical unit can be what I want to analyze (e.g.
people, countries, products etc.)
There are some topics I cannot ask in a survey
data.
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
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63

Anteprima parziale del testo

Scarica Applied Statistics - completo e più Dispense in PDF di Statistica Applicata solo su Docsity!

BIG DATA : Volume (huge volume of data), very complex and different (variety of data) and very fast

(velocity), in order to merge them together. It’s the mix of structure and unstructured data

DATA VISUALIZATION: interpretation of data = transforming collected complex data into something

everyone could understand (through graphs’ creation).

DASHBOARDING : it’s where we put the graphs of the analysis to make them readable to everyone, all the

companies are using it (they are linked with the data visualization)

BUSINESS ANALYTICS : analyzing data in order to build a business strategy or just create

knowledge\awareness inside the company.

VOC (VOICE OF THE CUSTOMER ): it’s a sort of survey, it’s not spontaneous but it’s something that the

company is going to ask to customer to better understand their needs (very important in order to

understand my target and compete with my competitors). Collecting data from customers (quantitative

surveys) who want to make suggestions and tell their satisfaction rate.

PREDICTIVE MAINTENANCE : it’s a statical model that can predict if a product is going to have an issue, the

company is predicting the maintenance that is going to do at their own sold products (ex: all the

automotive companies are investing a lot on it because they’re going to increase the revenues)

BUSINESS INTELLIGENCE (BI): information-sharing through all company’s departments. Doing intelligence

collecting all the company’s data.

STATISTICAL ANALYSIS OF DATA

When talking about statistics we are today talking about big data.

Small data: data structured in a way that can be analyzed.

Dataset : It’s the starting point for data analysis, in which each row is a statistical unit: customer, order, day,

store, etc. and each column is a variable, i.e. information measured for each statistical unit (in the example

store)

Statistical unit can be what I want to analyze (e.g.

people, countries, products etc.)

There are some topics I cannot ask in a survey data.

DATA SOURCES:

  • Primary: data collected for my aim (I have doubts to solve and I collect data for this purpose). o Experiment o Ad hoc research o Internal research
  • Secondary: Data already inside my company but not collected for a specific purpose, they just can be useful for my research\doubt o IT systems o Publications o Data banks

DECISION MAKING PROCESS

Beginning: identify the problem → DATA collection* → descriptive statistics, probability, computers

(transforming data to information) → INFORMATION → transformation of information into knowledge

(inferential statistics*) → KNOWLEDGE → DECISION

*Data collection may be the longest among all processes.

*INFERETIAL STATISTICS → Transformation in information in knowledge means I’m going to generalize

information to the whole population (if I’m collecting data about customers I cannot ask all customers but

ask to a sample, generalizing all customers)

DEFINITIONS:

Population : the collection of all items of interest or under investigation Values calculated using population

data are called parameters. (Insubria students)

E.g., all voters in US, incomes of household level in a specific geographical area, daily sales of a store form

the beginning.

Sample : is an observed subset of population, a representative part of population (some of Insubria

students). Values computed from sample data are called statistics.

Parameter : specific characteristic of population (the average age of Insubria students)

Statistic : specific characteristic of a sample

DATA TYPES:

  • Quantitative (numerical): a. Discrete b. Continuous

There is a discrete quantitative data. In this graph the absolute frequency is the number of statistical units (people of the sample who have 1,2,3 or 4 luxury bags). The number of possible variables is very low (1-4) so I can use the bar chart.

In case of many values, it’s preferable a HISTOGRAM GRAPH

In this case there’s a bin for each range. The bin’s size is calculated from the absolute frequency (customers column).

This graph is WRONG: each bin should have a different height based on the frequency and a proportional base based on the relative range (if the range is 1 to 5 it should be smaller than the 10 to 50 range). 1

(^1) In quello rosa il range è sempre uguale (10 per volta), in quello blu cambia sempre (all’inizio differenzia di 5, poi il

range diventa di 10-50 dove la differenza è 40

Figure 1 BAR CHART

  • Qualitative (categorical) : all variables generally describe with categories (possible variables) a. Nominal: e.g geographic distribution of customers (north, south) b. Ordinal: e.g. product satisfaction (five points scale, very satisf..) !!! If it’s not a specific number, it’s not considered as quantitative (also if there’s a 1 to 5 scale)

Absolute frequency: number of statistical unit with this category. The sum of them makes the sample size (1324) Percentage frequency %: percentage of statistical unit with these modalities.

Figure 2 PIE CHART – frequency distribution table

UNIVARIATE DESCRIPTIVE STATISTICS

How can I do descriptive statistic for a single variable?

In univariate statistics we analyze one variable at a time with 2 methods:

1. Frequency distribution : useful to summarize data set for a single variable, it’s the set of the modalities and their frequencies (summarize data using one raw for each modality). 2. Synthesis measures : computing single indexes that are summarizing one variable

FREQUENCY DISTRIBUTION

Useful to summarize a dataset for a single variable. For example, if I have one variable with many possible

values (called modalities= values that each variable can assume) I can summarize this information in a new

little dataset\table which has for each row a new modality.

Frequency is the first level of data synthesis and consists of counting the number of times each modality is shown in the data (absolute freq. in a table)

Relative frequency it is the ratio between the modality frequency and total number of the unit considered in the population (percentage data) V. PIE CHART SOPRA

NB: Can be used for nominal, ordinal and quantitative data.

MEASURES OF SPREAD (can be computed only for quantitative variables)

Range → maximum value – minimum value (affected by outliers so not very reliable, it ignores the

distribution of data)

E.g. 1 ,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,4, 5 = Range = 5 - 1 = 4

Interquartile range → difference between the third and first quartile (Q3-Q1), it is the range of the 50% of

the central part of distribution (this value is not affected by outliers, minor values are excluded so it’s more

reliable). More reliable index but is not democratic.

Variance → The most important. Computing the difference of each value from the average, squaring this

value, take only positive average and doing the average. Each value is concurring in the computation of the

variance. Extremely affected by outliers. Can be interpreted as something related to a risk (ex. Stock

exchange if I have a high variance = values very different from each other, so there will be more risk) or to

something like an information.

Standard deviation → most common used variability indicator because has values you can easily interpret.

To understand the variability of the variable we have to look at the tales. If they’re higher = standard deviation is higher, if lower = standard deviation is lower.

Outliers influence the standard deviation

Coefficient of variation → is the relative index of variability. It is computed by dividing the standard

deviation with the average. It’s a percentage without unit of measurement. it can be used to compare more

set of data to see which one is more valuable.

Same standard deviation (5dollars) but share A and share B have different average price. So, for the same standard deviation the coefficient of variation is different

The coefficient of variation is higher as the average is lower. (low average = high coeff of variation)

Minor s.d. deviation

Major s.d. deviation

MEASURES OF SHAPE

Skewness → From a graphical pov there’s a histogram. If the 2 tails are similar, we can say the distribution is symmetrical. In case of a longer tale the distribution is asymmetrical.

Form of distribution: If I have a longer tale, I’ll have an asymmetrical form of distribution. The form of distribution is said to be asymmetrical if the observations are not equally spread around the center.

ASYMMETRICAL DISTRIBUTION

Skewed to the right

Skewed to the left

We cannot always understand through a graph the form of distribution, so we use an indicator called SKEWNESS : it measures the degree of symmetry or skewness of a distribution: 2

3. Skewness = 0 symmetrical distribution: median = mean 4. Skewness < 0 negative skewness: skewed to the left (mean<median), 5. Skewness > 0 positive skewness: skewed to the right (mean>median) because the mean is

affected by the tales

(^2) Skewed: sbilanciato

Skewness : it is an index which measures the degree of symmetry or skewness of a distribution:

  • Skewness=0 symmetrical distribution: median=mean;
  • Skewness<0 negative skewness: skewed to the left (mean<median);
  • Skewness>0 positive skewness: skewed to the right (mean>median);

Measures of the distribution shape

Mean < Median Mean = Median Median < Mean

Skewed to the left Symmetrical^ Skewed to the right

71

  • The form of distribution is said to be asymmetrical if the observations are not equally spread around the center

Distribuzione con Asimmetria Positiva

0

2

4

6

8

10

12

1 2 3 4 5 6 7 8 9

Freq

uen

za

Distribuzione con Asimmetria Negativa

0

2

4

6

8

10

12

1 2 3 4 5 6 7 8 9

Freq

uen

za

A distribution with positive skewness

(skewed to the right) has a tail stretching

to the right, towards positive values.

A distribution with negative skewness

(skewed to the left) has a tail stretching

to the left, towards negative values.

Form of Distribution

Positive skewness

Negative skewness

70

R COMMANDER

Open dataset → Data – load data set – select rcmdr file + open the excel one

Each column is a variable, each raw a statistical unit (each person who answers a questionnaire for ex.)

If from Rcmdr you click edit dataset the dataset is opening.

Change the language → from r console – edit – preference interface – in menus and messages write

“English” and select apply then ok. Anche se r console rimane in italiano prova ad aprire rcmdr.

FIRST BRIEF OVERVIEW OF ALL THE VARIABLES → R shows you the overall situation for each variable. If

qualitative I have frequency distribution, if quantitative 3 quartiles, min, max and mean.

statistics – summaries – active dataset

NUMERICAL SUMMARIES → if I want to compare\analyze 2 QUANTITATIVE VARIABLES.

statistics – summaries – numerical summaries – select the 2 variables (through ctrl button) – click OK

In numerical summaries menu, moving from “data” to “statistics” we can add some values (like skewness,

coefficient of variation etc.)

R COMMANDER:

SD – STANDARD DEVIATION | IQR – INTERQUARTILE RANGE | 0% - MINIMUM | 25% FIRST QUARTILE | 50%

MEDIAN | 75% THIRD QUARTTILE | 100% MAXIMUM | n – number of observations | NA – not available

Es. variabile che chiede quanti minuti spendiamo ogni giorno a telefono

Median = 10 means 50% of the observations speak more than 10 minutes at the telephone each day

Third quartile = 30 means that 75% speak equal or less than 30 minutes

MAX = 180 means that the maximum value is speaking 3 hours per day

FREQUENCY DISTRIBUTION → if I want to compare\analyze 2 QUALITATIVE VARIABLES.

statistics – summaries – frequency distributions – select 2 variables

In the output = counts are observations and then below I have percentages

PIE CHART → graphs – pie chart – select the variable(s) – OK

BAR GRAPH → graphs – bar graph – select the variable(s) – OK

HISTOGRAM (for quantitative variables) → graphs – histogram – select the variable(s) – OK

This one is skewed to the right (the longer tail is on the right)

modalities). There are some percentages called condition frequency, the last raw of each gender is the

relative frequency (dividing the count by the total. 11.3% is simply 25 out of all the observations in my

dataset)

TO SUM UP:

First raw: count (absolute frequency)

Second raw: count on the total by raw

Third raw: count on the total by column

Last raw: count on the gran total

Statistical independence : information from variable A is not giving me additional information for variable B

(if I have the same distribution among males and female it means that variables age\gender are not

related).

Conditioned frequencies : there’s a relationship between 2 variables

Two samples: sky sport customers and their competitors, mediaset premium customers.

Gender and awareness of Eurosport are the two variables. They are independent from each other because

computing the percentage of awareness is the same for the first group. Male and female have the same

awareness of sky sport while in the other is strictly different.

HOW CAN I ASSESS THE STRENGHT OF RELATIONSHIP BETWEEN 2 VARIABLES?

Indexes of connection

X^2 (Chi square) is and index which starts from zero

0 → no statistical dependence 1 → statistical dependence

The higher is the chi square, the higher is the intensity of the relation

Cramer’s V is an indicator from 0 to 1 where

0 → no dependence 1 → perfect dependence.

In this example there’s no dependence

Analysis of correlation

Linear correlation Can be applied to quantitative variables. If we wish to measure the degree of concordance between 2

quantitative variables, you need to use indexes:

Covariance, Cov(X,Y) you can assess if the linear relation is present or not. If it’s 0 there’s no relation, if

higher there is a relation, but I cannot assess the strength of the correlation.

Cov(x,y) > 0 → x and y tend to go in the same direction

Cov(x,y) < 0 → x and y tend to go in opposite directions

Cov(x,y) = 0 → x and y have no linear connection

To understand the strength of the relation we use

Coefficient of linear correlation p(X,Y), the covariance divided by the product between two standard

deviation. Because in this case we have and index without units of measurement so it’s easily to be

interpreted. The farer is from zero, the stronger is the relation.

  • 1|+1 = means a perfect linear relation (positive or negative)

0 = there isn’t linear relation, so they’re linearly independent

Example: 0.3 we have a weak linear correlation, 0.5 medium correlation, 0.9 very high

Scatterplot → in the first graph we see all the points are on the same line = perfect correlation

In case of INDEPENDENCE:

11. If testing 2 quantitative variables , in the H0 we won’t have a linear relation (it’s about a specific relation) 12. If testing 2 qualitative variables , in the H0 we will have the statistical independence, so we don’t have any kind of relation between X and Y (= independence between the 2 variables)^4

After the formulation, we have to select the appropriate test (according to the type of variables)

Then we have to choose the LEVEL OF SIGNIFICANCE → is a value called ALFA chosen by the analyst before

making the test. There are 3 different levels:

α= 0.01 (more difficult to reject H 0 )

α = 0.05 USUAL CHOICE

α =0.10 (simpler to reject H 0 )

My choice depends on how much I want to be conservative in my null hypothesis because the final result of

the test will reject or not my H0. According to the alfa we choose we are selecting the difficult to reject H0,

the higher is alfa, the easier is to reject H0. Usually, it’s chosen a medium level of significance.

Then we have to collect data and calculate test statistics (measure of distance from the null hypothesis in

the data) → I can compute if I’m next or not to the null hypothesis. if the test is very low it means I’m far

from H0 and I cannot reject it.^5 We determine whether my test rejects or not H0 by comparing alfa with P-

VALUE with alfa. If P-value is lower than alfa it means I can reject the null hypothesis. The lower p-value

is, the farer form the null hypothesis is (so I will reject it).

HOW FAR SHOULD I BE IN ORDER TO DETERMINE WHETHER I CAN REJECT NULL HYPOTHESIS?

It depends on alpha, the universal rule is that if p-value < α, then I reject H0. In our case, for our test, the

null hypothesis is “no relation”, so if p-value is lower than alpha it means there’s a significant relation.

So p-value < α = H0 rejected + there’s a significant relation (in statistics, significant means that the relation

is present at population level, so I can generalize the relation to the whole population).

CHI-SQURED (X^2 ) TEST FOR STATISTICAL INDEPENDENCE (2 qualitative variables)

The hypotheses are the following:

  • null H0: statistical independence between X and Y
  • alternative H1: statistical dependence between X and Y

If the p-value is lower than α, the null hypothesis can be rejected

(^4) Se confermiamo la null hypothesis (H0) con due qualitative vuol dire che non c’è proprio nessuna relazione tra X e Y.

Se confermiamo H0 con due quantitative vorrà dire che non c’è una linear relation. Perché tra due quali vediamo se c’è una qualche relazione, tra due quantitative vediamo se c’è una linear relation, non una qualsiasi tipo di relazione. (^5) Se tipo Alfa = 0. 05 e il p-value è 0 posso reject H0 perche sono molto vicini ed p-value è più basso.

Chi-square output:

In the first table have a significance\p-value of 0.14. It means that the two variables are not significant related, because 0.14 is not lower than alfa = don’t reject H0.^6

Here is the opposite, p-value is 0.001. I can reject H0 and state there’s a relation because p-value is very low.

NB: I cannot assess the strength of the relationship. (I can do it only if I had 2 quantitative through the

coefficient of correlaton)

T TEST FOR STATISTICAL INDEPENDENCE (2 quantitative variables)

We are assessing if the two variables are linearly independent or not. The null and alternative hypotheses

are similar to the others:

H0: = linear independence between X and Y (=0)

H 1 : = linear dependence between X and Y (not 0)

Here if I reject H0 I say that there’s a linear dependence.

NB difference between linear and statistical independence → the stronger is the statistical independence

because excludes any type of relation. Linear independence only excludes a linear relationship. Linear

independence means the coefficient of correlation are low and the raw is = 0. Linear dependence means

the raw is different from 0.

(^6) Pure se alfa fosse il massimo = 0.10, p-value è comunque piu alto

In this output age is the qualitative and the importance of handmade production on a scale from 1 to 9 is

the quantitative. Here we can say there’s a relation because averages are different. For example, for age

18 - 25 the average is 5, for 26-35 the average is higher, so they’re dependent.

BUT: Is this relation significant (so it can be generalized to the whole population?) To answer we have to

look to the f-test inside the anova table. In the anova there’s the result of the test = 0.045 → if alpha level is

0.01 I can’t reject the null hyp., so they’re not significantly related. I cannot generalize it to the whole

population. If alpha is 0.05 or 0.10, I reject the null hypothesis.

The result of the test sometimes (like in this case) depends on the level of alpha.

Here again we can say there’s a relation because we can see that the importance of customer service changes as the age changes.

Is this relation significant? p-value is higher than the highest alpha possible (0.10) so I cannot reject the null hypothesis.^7

Even if in the temple I see a relation (mean column), these differences are too low to be significant, these

differences are casual, are random results.

TO SUM UP:

Qualitative variables

Quantitative variables: linear relation

Mixed variables: analysis of variance, I analyze the variance of the quantitative changing the test of the

quantitative

(^7) I test sono usati per verificare che la relation sia significant = you can generalize it to the whole population. The

analysis of each test is the tool to use to assess if between the 2 variables there’s independence or not

Exercise lect. 3

There are both QUALITATIVE VS QUANTITATIVE

You have to guess what test has to be run.

  1. Since the new categories include decoration, kitchen accessories and cleaning products, they want to test if the percentage of female customers changed after the restyling process. What analysis should they do? Variables are RESTYLE and GENDER (2 qualitative). I want to understand if after the restyle process there more female customers than before are. The correct answer is: the chi-squared test (chi)

  2. Do the customers generally spend more money than before in the stores? Variables are PURCHASE VALUE (quantitative) and RESTYLE (qualitative), to analyze if there's a significant difference, I have to run an F - test

  3. Is there an impact of restyling on average overall satisfaction? Is it increasing or decreasing? RESTYLE (qualitative) VS SATISFACTION (quantitative, it’s a scale from 1 to 9): we analyze the relationship through the F - Test , calculating the satisfaction before and after restyle.

  4. Is there a relation between overall satisfaction and purchase value? 2 quantitative (SATISFACTION VS PURCHASE): we analyze it through a T - Test

R COMMANDER lect. 3

F TEST → variables are “gender” and “how many text messages do you send per day”. I have first need to

understand what the average of male and female is.

statistics – means – one way ANOVA – select variables

* If I can’t find my variable in groups because the system recognizes it as a numeric data : data – managing

variables – convert numeric variables to factors – select variable and nominal – then you can do the f test

The second one is the descriptive output: the male respondent on average is 120 message per day, female

223 messages per day. They’re quite different, but we have to see if this difference is significant or not. To

assess it, we look at the table above. We see that p-value (Pr(>F) or Pairwise) is 0.406 = there’s no

significant relationship. There’s a high variance among female respondents (standard deviation 954), so the

huge difference in the means may be caused by just some outliers in the female answer.