Introdução à Estatística ESTATÍSTICA? e Estatística...
Transcript of Introdução à Estatística ESTATÍSTICA? e Estatística...
Introdução à Estatísticae
Estatística Descritiva
0
ESTATÍSTICA?
Um conjunto de procedimentos e princípios para recolha, compilação, análise e interpretação de dados por forma a ajudar na tomada de decisões quando na presença de incerteza.
1
Herbert George Wells,Herbert George Wells, English author, said (circa 1940 ),
“Statistical thinking will one day be as necessary for efficient citizenship as the abilitynecessary for efficient citizenship as the ability to read and write”
2
Average depth 3ft (0 9144 )(0.9144m)
3
Why do we need to understand statistics?
Reasoning with Uncertainty
• from
• Peter Donnelly: How juries are fooled by statistics• http://www.ted.com/index.php/talks/view/id/67
4
Ex 1 Coin TossingEx 1 - Coin Tossing
• Imagine tossing a coin successively, and waiting till the first time a particular pattern appears, say HTT
• For example, if the sequence of tosses was
HHTHHTHHTTHHTTTHTHHHTHHTHHTTHHTTTHTH
Th tt HTT ld fi t ft th 10th t• The pattern HTT would first appear after the 10th toss
5
[email protected] 1 - Coin Tossing
• Imagine that half of you toss a coin several times, g y ,each time till the sequence HTT occurs.
– Record the average number of tosses till HTT occurs
• The other half of you prefer to count HTH• The other half of you prefer to count HTH
– Record the average number of tosses till HTH occurs
6
f f
Ex 1 - Coin Tossing
• Which of the following is true:
A. The average number of tosses until HTH is larger thanthe average number of tosses until HTT
B. The average number of tosses until HTH is the same asthe average number of tosses until HTT
C. The average number of tosses until HTH is smaller thanthe average number of tosses until HTT
Most people think that B is true but A is true The averageMost people think that B is true but A is true. The average number of tosses till HTH is 10 and the average number of tosses till HTT is 8.
7
tosses till HTT is 8.
[email protected] 1 - Coin Tossing
• Intuitive explanation:• Imagine that you win if HTH occursImagine that you win if HTH occurs
– If the first toss gives a H you are exited and you get even more exited if the second is a T. If the third is H you win ybut if it is a T you have to start again and wait for the next H.
• If you win when HTT occursy– For the first two tosses the experience is the same.
However, if the third toss is a H you loose but you already have the first H and are 1/3 of the way to your pattern.
8
[email protected] 1 - Coin Tossing
It l fIt was an example of a
simple question on
probabilities that most
people get wrong.
9
Conclusions from the examplesConclusions from the examples
• Randomness, uncertainty and chance are part of our life.
• People make errors of logic when reasoning with uncertaintywith uncertainty.
• Errors in statistics may have serious consequences.
It is very important to understand statistics!
10
statistics!
What is the problem here?
On average the gtemperature is very nicevery nice...
11
Estatística DescritivaEstatística Descritiva
Na estatística descritiva procura-se sintetizar e t d f í l i f ãrepresentar de forma compreensível a informação
contida num conjunto de dados (através da t ã d t b l d áfi d ál l dconstrução de tabelas, de gráficos ou do cálculo de
medidas)
12
Objectivo da estatística descritiva: síntese da informação contida em dados
13
Exemplo: notas a uma determinada disciplinae p o otas a u a dete ada d sc p a
14
Média 10.52Mediana 10 51Mediana 10.51Amplitude 16.29Máximo 17 67Máximo 17.67Mínimo 1.38Quartil 25% 9.068Quartil 75% 12.68Desvio Padrão 3.208Variância 10 291Variância 10.291Assimetria -0.25
15
Média e Mediana
Exemplox ( ) 25.118/21014711141210 =+++++++=x
Média:
1012
( )
14117
Mediana:
7 10 10 11 12 12 14 1471410
7 10 10 11 12 12 14 14
11.51012
16
Média e Mediana
Exemplox ( ) 5.348/210200711141210 =+++++++=x
Média:
1012
( )Mediana:
14117
7 10 10 11 12 12 14 200
11 5720010
11.5
Média mais sensível a valores extremos!1012 ex. Salário médio vs. Salário mediano
17
Variância e Desvio Padrão
Para inferir da variabilidade de uma população a partir de uma amostra usa-se a variância amostral (s2)
( ) −⋅=N
xxs 22 1
O d i d ã t l ( ) i
( )=
−⋅−
=n
n xxN
s11
O desvio padrão amostral (s), raiz quadrada da variância amostral, tem a vantagem de ser expresso nas mesmas unidades dos dados
( )21 N
18
( )2
1
11 n
ns x x
N =
= ⋅ −−
Exemplo: Calcular o desvio padrão da seguinte amostra: - 4 , -3 , -2 , 3 , 5
( )2Xi X XXi − ( )2XXi −
-4 -0,2 -3,8 14,44
-3 -2,8 7,84
-2 -1,8 3,24
3 3,2 10,24
5 5,2 27,04, ,
Soma= 62.8
Sabemos que n = 5 e 62,8 / (5-1) = 15,7A raiz quadrada de 15 7 é o desvio padrão = 3 96
19
A raiz quadrada de 15,7 é o desvio padrão 3,96
Histograma das classificações
20
http://www.stat.tamu.edu/~west/javahtml/Histogram.html
Coeficiente de assimetria (g1)Coeficiente de assimetria (g1)
( ) ( )
−⋅⋅−⋅−
== =
N
nn xx
NNNNkCOM
skg
1
32
333
1 )(121
,
g1 = 0
21
g1 > 0 g1 < 0
Box-Plot: permite comparar as classificações de 3 anos de Mest
percentil 75%
mediana
percentilpercentil 25%
22
Box Plot of Home Runs per Season for
60.0
70.0
Box Plot of Home Runs per Season for4 Great Players When They Were NY Yankees
30.0
40.0
50.0
e Ru
ns0 0
10.0
20.0Hom
e70.0
Box Plot of Home Runs per Season for4 Great Players for Their Entire Careers
-10.0
0.0
Ruth_Y Mantle_Y Gehrig_Y Maris_YPLAYERS 50.0
60.0
70.0
20.0
30.0
40.0
Hom
e Ru
ns
0.0
10.0
H
23
-10.0Ruth Gehrig Mantle Maris
PLAYERS
• Amostras bivariadas – dados quantitativosq
A relação existente entre os dois atributos de uma amostra bivariada com dados quantitativos pode ser evidenciada por um diagrama (X Y)com dados quantitativos pode ser evidenciada por um diagrama (X,Y)ou, de forma mais sintética, pelo cálculo do grau de ajuste de determinada relação
LOTE VOLUME DE PRODUÇÃO
CUSTO DE PRODUÇÃO
(unidades) (contos)
1 1500 3100 2 800 1900 3 2600 4200 4 1000 23004 1000 2300 5 600 1200 6 2800 4900 7 1200 2800 8 900 2100 9 400 1400
10 1300 2400 11 1200 2400
24
11 1200 2400 12 2000 3800
A relação entre duas variáveis pode ser ilustrada através de um diagrama(x,y) - scatterplot
5000
6000
ão
3000
4000
de p
rodu
ç
1000
2000
Cus
to
00 500 1000 1500 2000 2500 3000
Volume de produção
25
matriz de scatter plotsp
26
Um scatterplot permite analisar o relacionamento geral e a existência de desvios entre duas variáveis.
Por vezes interessa caracterizar a relação entre duas variáveis e medirPor vezes interessa caracterizar a relação entre duas variáveis e medir o respectivo grau de ajuste.
Vamos ver o exemplo a relação linear
27
Vamos ver o exemplo a relação linear.
Medidas do grau de ajustamento da relação linear aos dados:
Covariância amostral (permite inferir acerca da população)Covariância amostral (permite inferir acerca da população)
( ) ( )=
−⋅−⋅−
=N
nnnXY yyxx
Nc
111
( ) ( )1 N
yyxx
Coeficiente de correlação amostral (medida adimensional)
( ) ( )
( ) ( )( )11
11
11
1
1
2
1
2
1 ≤≤−⋅
=−⋅
−⋅−⋅
−
−⋅−⋅−=
==
=XY
YX
XYN
nn
N
nn
nnn
XY rss
c
yyN
xxN
yyxxNr
28
11 == nn
x y 1000x 1000y1500 3100 1500000 3100000800 1900 800000 1900000
2600 4200 2600000 4200000
y
60002600 4200 2600000 42000001000 2300 1000000 2300000600 1200 600000 1200000
2800 4900 2800000 49000001200 2800 1200000 2800000 3000
4000
5000
6000
y1200 2800 1200000 2800000900 2100 900000 2100000400 1400 400000 1400000
1300 2400 1300000 24000001200 2400 1200000 2400000 0
1000
2000
3000 y
1200 2400 1200000 24000002000 3800 2000000 3800000
correl: 0.9811009 0.9811009cov: 757847.22 7.578E+11
00 500 1000 1500 2000 2500 3000
1000y
4000000
5000000
6000000
1000000
2000000
3000000 1000yPara uma determinada relação a mudança de escala altera o valor da covariância.
29
00 500000 1000000 1500000 2000000 2500000 3000000
30
http://bcs.whfreeman.com/ips4e/cat_010/applets/CorrelationRegression.html
31
9657
Expresso – 18 Jan. 2003
8.234499657 =
32
Classical example of how to lie with statistics.
The Lie Factor is simply the ratio of the difference in the proportion of the graphic elements versus the difference in the quantities they represent. The most informative graphics are those with a Lie Factor of 1. Here is an example of a badly scaled graphic, with a lie factor of 14.8:
33
(from Tufte, E.R. (1983). The Visual Display of Quantitative Information. Cheshire, CT: Graphics Press)
An example of a graph where two-dimensional figures are used to represent one-dimensional values. What often phappens is that the size of the graphic is scaled both horizontally and vertically according to the value being graphed. However, this results in the area of the graphic varying with the square of the underlying data, causing y g q y g , gthe eye to read an exaggerated effect in the graph. This graph has a lie factor of about 2.8, based on the variation between the area of each doctor graphic and the number it represents. p
34
(from Tufte, E.R. (1983). The Visual Display of Quantitative Information. Cheshire, CT: Graphics Press)
35
One more point about graphs: be sure to include enough context to make the graph meaningful. For instance, one may be tempted to draw unwarranted conclusions based on this graph:
(f T ft E R (1983) Th Vi l Di l f Q tit ti I f ti Ch hi CT G hi P )
36
(from Tufte, E.R. (1983). The Visual Display of Quantitative Information. Cheshire, CT: Graphics Press)
População e Amostrap ç
Designa-se por população (ou universo) o conjunto dos g p p p ç ( ) jdados que expressam a característica em causa para todos os objectos sobre os quais a análise incide.
Uma amostra corresponde a um subconjunto de d d t à l ãdados que pertencem à população.
37
Exemplo
Objectos: contas à ordem de todos os profissionais liberais clientes de um bancoliberais clientes de um banco
Característica: saldo registado num dado momentog
População: conjunto dos saldos das contas à ordem de t d fi i i lib i li t dtodos os profissionais liberais clientes do banco num dado momento
Amostra: conjunto de 100 saldos seleccionados
38
Selecção de amostras
QQuando todos os elementos da população têm igual probabilidade de ser incluídos na amostra evita-se qualquer enviesamento de selecção designando se então o processo porenviesamento de selecção, designando-se então o processo por
amostragem aleatória
39
The 1936 election: the literary digest pollThe 1936 election: the literary digest poll
•• CandidatesCandidates: Democrat FD Roosevelt and Republican Alfred Landon
• Prediction: Landon to win with 57% of the vote
• Outcome: Landon lost with only 38% of the vote
• Sample Size: 2 3 million people!• Sample Size: 2.3 million people!
• Literary Digest went bankrupt soon after
40
Why the Digest went wrong:Why the Digest went wrong:
• Bias in selection of sample• Bias in selection of sample– 10,000,000 questionnaires sent out to
Magazine subscribers car owners telephone owners• Magazine subscribers, car owners,telephone owners
Bi f• Bias from non-response– 20% bothered to reply
P bl th ith t i b t th– Presumably, those with strong views about the forthcoming election
Large sample size cannot compensate for poor sample design!!!
41
for poor sample design!!!
Análise dos dadosRecorre-se às técnicas de estatística descritiva para sintetizar a informação contida nos dados
Estabelecimento de inferências acerca da populaçãoCom base na informação contida na amostra pretendemCom base na informação contida na amostra, pretendem retirar-se conclusões relativas à população e associar-lhes um grau de credibilidade
42
Na inferência estatística com base na análise de umNa inferência estatística, com base na análise de um conjunto limitado de dados (amostra), pretende-se caracterizar o todo a partir do qual tais dados foram p qobtidos (população)
E lExemplo
A partir dos 100 saldos disponíveis retirar conclusõesA partir dos 100 saldos disponíveis, retirar conclusões sobre a forma como se comportam os saldos das contas à ordem de todos os profissionais liberais clientes do pbanco
43
DN e TSF -> Marktest
Eleições legislativas 2002
EXPRESSO-SIC-Renascença -> Eurosondagem
DN e TSF > Marktest
2057 entrevistas validadas e apresenta um erro de amostra de 2,16 por cento para um grau de probabilidade de 95 por cento.
819 entrevistas e apresenta um erro de amostragem para um intervalo de confiança de 95 por cento, de maisconfiança de 95 por cento, de mais ou menos 3,42 por cento.
Independente -> Instituto de Pesquisa de Opinião e Mercado (IPOM)
Resultados Finais
997 entrevistas validadas e apresenta um erro de amostragem, para um nível de confiança de 95,5 por cento, de mais ou
3 1 t t i
PS: 46% (118-124 deputados)PSD: 31% (80-84)CDU: 7% (8 12)menos 3,1 pontos percentuais.
JN -> Intercampus
CDU: 7% (8-12)BE: 7% (8-12)CDS-PP: 6% (6-10)Outros: 1% (0)
5051 inquiridos, de 1,4 por cento com um nível de confiança de 95 por cento.
44
1015 entrevistas, e apresenta um erro de amostragem, para um intervalo de confiança de 95 por cento, de mais ou menos 3,1 por cento.
PÚBLICO, RTP e Antena 1 -> Universidade Católica
Brancos/nulos: 2%
Teste de Hipótese à Diferença de Duas Proporções Binomiasp ç p ç(amostras de grande dimensão - N > 20 e N.p> 7)
A hi ó id l i à dif d d õ
pppH
As hipóteses a considerar num teste relativo à diferença de duas proporções binomiais são:
0000001
00
ppppouppppppppH
ppp:H
BABBABA
BA
<=−>=−≠=−=−
,:
Sendo a estatística do teste dada por
( )( )( ) ( )
( )1033
0 ,NNYNYNYNY
pNYNYET
BBBBAAAA
BBAA →−⋅+−⋅
−−=
45
ExemploExemplo
Na avaliação de um problema de classificação foram utilizados dois algoritmos ONa avaliação de um problema de classificação foram utilizados dois algoritmos. O algoritmo A classificou correctamente 27 de 45 exemplos enquanto o algoritmo B classificou correctamente 32 de 65 exemplos.A h d fi l it A é i ifi ti t i i dAcha que se pode afirmar que o algoritmo A é significativamente mais preciso do que o algoritmo B?
4906532
6004527 .. ==== ba pep
121326532274527
6532
4527
.)()(
=−
=ET
65326532
45274527
33
)()( −+−
46
ivasignificat amenteestatistic é não diferença a logo,6451121 .. <
Introdução à Estatísticae
Estatística Descritiva
47
Basic Statisticsh // li d / l / i / S h lhttp://www.liaad.up.pt/~ltorgo/Regression/DataSets.html
48
Summary StatisticsSummary Statistics(Excel)
49
Histogramsg(SPSS)
50
Box Plots(SPSS)