O documento descreve testes estatísticos para análise de dados qualitativos, incluindo o teste binomial, teste qui-quadrado de homogeneidade, independência e ajustamento. Fornece exemplos e explica como interpretar os resultados dos testes.
2. TESTES DE HIPÓTESES PARA DADOS QUALITATIVOS
TESTS TO QUALITATIVE DATA
Variáveis / variables Testes / Tests Hipóteses / hypothesis
1 dicotómica /
1 dichotomic (0/1)
Teste Binomial / binomial
test
H0: p=a e H1: p≠a (bilateral)
H0: p≥a e H1: p<a (unilateral)
2 qualitativas
dicotómicas / 2
qualitative dichotomic
variables
Teste 2 homogeneidade
/
2 homogeneity test
H0: p1=p2
H1: p1≠p2
2 qualitativas não
dicotómicas / 2
qualitative non
dichotomic
Teste 2 independência /
2 independence test
H0: as variáveis são independentes
H1: as variáveis não são
independentes
1 qualitativa não
dicotómica / 1 qualitative
non dichotomic
Teste 2 ajustamento /
2 goodness of fit test
H0: os dados ajustam-se à
distribuição
H1: os dados não se ajustam à
distribuição
3. TESTE DA BINOMIAL / BINOMIAL TEST
O Teste da Binomial aplica-se a uma amostra
independente em que a variável qualitativa é
dicotómica (sucesso / insucesso).
O teste compara as frequências observadas
com as que se espera obter através de uma
distribuição binomial.
Exemplo: 100 indivíduos pronunciam-se sobre
um novo programa televisivo
- 45 respondem que apreciaram o programa
- 55 respondem que não apreciaram o
programa
Existirão diferenças estatisticamente
significativas entre a proporção que apreciou e
a que não apreciou o programa?
H0: p = q H1: p ≠ q
Uma vez que só há 2 resultados possíveis e
p=q p = 0,5 = q
H0: p = 0,5 H1: p ≠ 0,5
The Binomial Test applies to an independent
sample in which the qualitative variable is
dichotomous (success / failure).
The test compares the frequencies observed
with those expected to be obtained through a
binomial distribution.
Example: appreciation of a new television
program – 100 respondents
45 respondents enjoy the program
55 respondents did not enjoy the program
Are there statistically significant differences
between the proportion of those who enjoy
and of those who do not?
H0: p = q H1: p ≠ q
Once there are only 2 possible results:
p=q p = 0,5 = q
H0: p = 0,5 H1: p ≠ 0,5
4. TESTE DA BINOMIAL / BINOMIAL TEST
Se H0 for verdadeira então em 100
espectadores:
E = n x p = 100 x 0,5 = 50 espectadores dirão
que apreciaram o programa.
De facto só 45 apreciaram o programa. A
probabilidade de no máximo 45 terem
apreciado o programa é de:
P (x<45) = cdf.binom (45, 100, 0.5) = 0,184
Por outro lado a probabilidade de 55 ou +
espectadores não terem apreciado o programa
é: P (x>55) = 1 – cdf.binom (54, 100, 0.5) =
0,184
Então: p-value = 2*P(x<45)=0,368
or p-value =2*P(x>55)=0,368
Comparando p-value com a (0,05) opta-se por
não rejeitar H0.
If H0 is true, then in 100 respondents:
E = n x p = 100 x 0,5 = 50 respondentes will
say that they enjoy the program.
In fact only 45 have enjoyed the program.
The probability of of at most 45 having
enjoyed the program is:
P (x<45) = cdf.binom (45, 100, 0.5) = 0,184
On the other hand, the probability of 55 or +
viewers did not appreciate the program is: P
(x>55) = 1 – cdf.binom (54, 100, 0.5) = 0,184
So p-value = 2*P(x<45)=0,368
or p-value =2*P(x>55)=0,368
Comparing p-value with a (0,05) we decide
not to reject H0.
a
i
i
n
i
i
n
a q
p
C
a
x
P
valor
p 0
)
(
Se/if H0: p=0,5 teste bilateral / 2 tie test
Se/if H0: p≥a (0,5)teste unilateral / 1 tie test
𝑝 = 𝑥 𝑛
Proporção amostral / Sample proportion:
5. TESTE BINOMIAL
BINOMIAL TEST
Decisão: como p-valor>a, não se rejeita H0.
Analisar
Analyze
Comparar
Médias
Compare Means
Proporção de
uma amostra
One Sample
proportion
6. TESTE DA BINOMIAL / BINOMIAL TEST
Analisar
Analyze
Testes não paramétricos
Non parametric tests
Caixa de diálogo
Legacy dialogs
Binomial
8. TESTE BINOMIAL / BINOMIAL TEST
Exercício / exercise:
Admita que numa empresa multinacional recolheu uma amostra aleatória de
dados relativos a 20 empregados para avaliar o género, tendo obtido os seguintes
resultados / assume that a company collected a random sample of data for 20
employees to assess the gender and obtained the following results:
F, M, M, F, F, M, M, M, M, F, M, F, M, M, M, M, M, M, M, M
Teste a afirmação: a proporção de funcionários do género feminino é inferior a
0,25.
Test the claim: the proportion of female employees is less than 0,25.
Hipóteses a testar / hypothesis:
H0: p≥0,25
H1: p<0,25 (afirmação inicial / original claim) a=0,05.
H1: p >
9. TESTE DA BINOMIAL / BINOMIAL TEST
Decisão: como
p-valor>a não
se rejeita H0.
Decision: as p-
valor>a, do not
rejet H0.
Conclusão: não
há evidência
para corroborar
a afirmação
inicial. There are
no evidences to
corroborate
original claim
10. TESTE DO QUI-QUADRADO / CHI-SQUARE TEST
É uma distribuição assimétrica
(enviesada à direita)
Os valores de 2 podem ser
positivos ou zero, mas nunca
negativos
Existe uma distribuição 2 por
cada n.º de graus de liberdade
(gl)
À medida que o dF aumenta a
distribuição 2 tende para a
distribuição normal.
Distribuição 2 (qui-quadrado):
De uma população normalmente
distribuída com variância s2, selecionam-se
aleatoriamente amostras independentes
de tamanho n e, para cada amostra
calculam-se as variâncias amostrais s2.
A estatística amostral: 2=(n – 1)s2/s2
segue a distribuição Qui-quadrado.
A Distribuição qui-quadrado é determinada
pelo número de graus de liberdade, (n -
1).
It is an asymmetric
distribution (skewed to the
right)
The values of 2 can be
positive or zero, but never
negative
There is a distribution 2 for
each number of degrees of
freedom (dF)
As the dF increases the 2
distribution tends to the
normal distribution.
From a population normally distributed with
variance s2, independent samples of size n
are randomly selected and, for each sample,
the sample variances s2 are calculated.
The sample statistic: 2=(n – 1)s2/s2
follows the Chi-square distribution.
The chi-square distribution is defined by the
number of degrees of freedom, (n - 1), (n -
1).
ℵ2 =
(𝑛 − 1) × 𝑠2
𝜎2
11. TESTE DO QUI-QUADRADO HOMOGENEIDADE
HOMOGENEITY CHI-SQUARE TEST
Testa a afirmação que populações
diferentes têm igual proporção de dados
com uma mesma característica.
Requisitos
• Os dados amostrais são selecionados
aleatoriamente e representados como
contagens de frequências numa tabela
de dupla entrada
• As hipóteses são:
▫ H0: p1 = p2
▫ H1: p1 ≠ p2
• Para cada célula da tabela de
contingência, a frequência esperada, E, é
no mínimo 5 (não há exigências para a
frequência observada). Não existe
qualquer exigência relativamente à
Test the claim that different populations
have the same proportion of cases with a
specific characteristic.
Requirements
The sample data are randomly selected
and represented as frequency counts in
a double entry table
The hypotheses are:
H0: p1 = p2
H1: p1 ≠ p2
For each cell in the cross table, the
expected frequency, E, is at least 5 (there
are no requirements for the observed
frequency). There is no requirement to
population distribution.
12. TESTE QUI-QUADRADO
CHI-SQUARE TEST
)
1
(
)
( 2
2
2
E
E
O
Analisar
Analyse
Estatísticas Descritivas
Descriptive Statistics
Tabela de referência
cruzada
Crosstabs
H0: p1=p2
H1: p1≠p2
dF=(l-1).(c-1)
O – frequência observada / observed frequency
E – frequência esperada / expected frequency
l - n.º de linhas / number of lines (2)
c - n.º de colunas / number of columns (2)
13. TESTE QUI-QUADRADO HOMOGENEIDADE
HOMOGENEITY CHI-SQUARE TEST
Frequência observada
Observed Frequency
Produto / Product
Gosta /
Like
Não Gosta/Don’t
Like
TOTAL
Porto 63 15 78
Lisboa 47 11 58
Total 110 26 136
Frequência Esperada
Expected Frequency
Produto / Product
Gosta / Like Não Gosta/Don’t Like TOTAL
Porto 110*78/136=63,09 26*78/136 = 14,91 78
Lisboa 110*58/136 =
46,91
26*58/136=11,09 58
TOTAL 110 26 136
Exemplo: os dados da tabela ao lado traduzem as opiniões de consumidores de Porto e
Lisboa relativamente a um novo produto colocado no mercado.
Example: the data in the 1st table reflects the opinions of consumers in Porto and
Lisbon regarding a new product placed on the market.
Teste a afirmação: a
proporção de apreciadores
do produto é idêntica para
as duas cidades.
Test the claim: the
proportion of those who
like the product is identical
for both cities.
15. TESTE EXATO DE FISHER
FISHER EXACT TEST
A aplicação do teste qui-quadrado fica
condicionada a que toda e qualquer célula de
valor esperado assuma o valor mínimo de 5.
Como alternativa recomenda-se a utilização
do teste Exato de Fisher, que determina um
p-valor exato e não recorre à distribuição.
O teste de Fisher é um teste não paramétrico
potente, recomendado quando se pretende
comparar duas amostras independentes, de
pequena dimensão: variáveis independentes
apresentadas em tabelas de contingência
2x2.
Se % > 20% utilizar o
p-valor do teste exato
de Fisher!
If % > 20% p-value
from Fisher Exact Test
mus be used.
The application of the chi-square test is
conditioned to that every cell of expected
value assumes the minimum value of 5.
As an alternative it is recommended to use
the Fisher Exact test, which determines an
exact p-value and does not resort to
distribution.
The Fisher test is a powerful non-
parametric test, which is recommended
when comparing two small independent
samples: independent variables presented
in 2x2 cross tables.
16. TESTE QUI-QUADRADO INDEPENDÊNCIA
INDEPENDENCE CHI-SQUARED TEST
Exemplo:
Os dados a seguir apresentados destinam-se a avaliar as proporções de preços
aplicados erradamente. Teste a afirmação: os erros nos preços são independentes da
existência de promoção.
The data presented below are intended to assess the proportions of prices applied
incorrectly. Test the claim: pricing errors are independent of promotion.
Preços/Prices
Promoções/promotions
Errado e abaixo
Wrong and below
Errado e acima
Wrong and above
Correto
Right
Sem promoção
No promotion
17 12 14
Com promoção
With promotion
7 9 8
H0: as variáveis são independentes (af. Inicial) H0: the variables are independents
H1: as variáveis não são independentes H1: the variable are not independents
O teste qui-quadrado da
independência é semelhante ao da
homogeneidade mas as tabelas
posuem mais de 2 linhas e/ou mais de
duas coluna. Não são tabelas 2x2.
The independence Chi-square test is
almost identical to homogeneity, but
the table has more than 2 colums
and/or 2 lines. They are not 2x2
tables.
18. SIMULAÇÕES DE MONTE CARLO / MONTE CARLO SIMULATIONS
Na opção
“exact
tests”
define-se
(1-a) e
insere-se o
n.º de
simulações
desejadas.
In the
“exact
tests”
option, we
define (1-
a) and the
number of
simulation
s needed
The chi-square test can be applied if:
• N> 20
• All expected values> 1
• At least 80% of the expected
values ≥ 5.
When the conditions are not
satisfied, we can use a Monte Carlo
Simulation - Probability Theory
tested in Monte Carlo casino
(Monaco).
O teste do qui-quadrado só pode ser
aplicado com todo o rigor se:
▫ N>20
▫ Todos os valores esperados >1
▫ Pelo menos 80% dos valores esperados ≥
5.
Quando as condições não são cumpridas
pode–se recorrer a uma Simulação de
Monte. Carlo - Teoria das Probabilidades
testada no casino de Monte Carlo
(Mónaco).
19. SIMULAÇÕES DE MONTE CARLO
MONTE CARLO SIMULATIONS
As simulações de Monte Carlo
baseiam-se no seguinte princípio:
- se lançarmos dois dados a
probabilidade da soma ser 2 é de
1/36 (resulta de 1/6 x 1/6).
- se simularmos 10.000 lançamentos
e contabilizássemos quantas vezes
aparecia o 2, verificaríamos que a
probabilidade deste resultado era
1/36 ou um valor muito próximo
deste.
Monte Carlo Simulations are
based on the principle:
- if we roll two dices, the
probability of the sum being
2 is 1/36 (results from 1/6 x
1/6).
- if we simulated 10,000
launches and counted how
many times the 2 appeared,
we would see that the
probability of this result was
1/36 or a value very close to
this.
20. BOOTSTRAPPING
É uma alternativa ao Método de
Monte Carlo. Consiste numa
métrica que utiliza a
reamostragem com reposição
para aumentar artificialmente o
número de amostras. Permite
atribuir medidas de precisão (viés,
variância, intervalos de confiança,
erro de previsão, etc.) para
estimativas de amostra
Bootstrapping is an alternative to Monte Carlo Method, which uses
random resampling with replacement to increase artificially the
number of samples. Bootstrapping assigns measures of accuracy
(bias, variance, confidence intervals, prediction error, etc.) to sample
estimates
21. EXPERIÊNCIAS MULTINOMIAIS
MULTINOMIAL EXPERIENCES
Uma experiência multinomial satisfaz as
seguintes condições:
Ocorrência de um número fixo de
experiências
Os resultados das diversas experiências são
independentes
Todos os resultados de uma experiência
devem ser classificados numa das diferentes
categorias consideradas
As probabilidades para as diferentes
categorias permanecem constantes para
cada experiência
Com os dados separados em diferentes
categorias, testa-se a hipótese de que a
distribuição “ajusta-se a uma distribuição
específica”.
A multinomial experience
satisfies the following conditions:
• Fixed number of experiments
• The results of the various
experiments are independent
• All the results of an experiment
must be classified in one of the
different categories considered
• The odds for the different
categories remain constant for
each experiment
With the data separated into
different categories, the
hypothesis that the distribution
“data fits a specific
distribution”.
22. TESTE 2 DO AJUSTAMENTO
CHI-SQUARE GOODNESS OF
FIT
Requisitos:
Os dados são seleccionados
aleatoriamente
Os dados amostrais consistem em
contagens de frequências para cada uma
das diferentes categorias
A frequência esperada (ei) de cada classe:
Nunca pode ser inferior a 1
Só pode ser inferior a 5 em 20% das
classes
Os testes de hipótese do qui-quadrado são sempre
do tipo unilateral direito!
The chi-square tests are always right sided.
Requirements:
Data is random selected
The sample data consists of frequency
counts for each of the different
categories
The expected frequency (ei) of each
class:
23. TESTE QUI-QUADRADO DO AJUSTAMENTO
CHI-SQUARE GOODNESS OF FIT
)
1
(
)
( 2
1
2
2
m
k
E
E
O
k
i
i
i
i
Oi – frequência absoluta observada na
categoria i
observed frequency in category i
Ei – frequência absoluta esperada na
categoria i
expected frequency in category i
m – n.º de parâmetros desconhecidos
number of unknown parameters
k– n.º de categorias da variável nominal
number of categories
H0: a população ajusta-se à distribuição especificada
H1: a população não se ajusta à distribuição especificada
Analisar
Analyse
Testes não
paramétricos
Nonparametric Tests
Uma amostra
One sample
H0: the population fits the distribution
H1: the population does not fits the distribution
24. TESTE DO 2 DO AJUSTAMENTO
CHI-SQUARE GOODNESS OF FIT
Exemplo 1:
Num inquérito realizado a 75 pessoas pretende-se comparar marcas de 4 dentífricos. In a
questionnaire applied to 75 consumers it is intended to compare the brands of 4
toothpaste.
H0: as proporções são idênticas para todas as marcas (af. Inicial). All proportions are
identical (original claim)
H1: pelo menos uma proporção é diferente. Not all proportions are identical
Toothpaste Frequência
Dentalwhite 36
Dentalfresh 18
Halifresh 14
Oralight 7
Toothpaste Freq. Observ (O) Freq. Esperada (E) (O-E) (O-E)2/E
Dentalwhite 36 18,75 36-18,75=17,25 17,252/18,75=15,87
Dentalfresh 18 18,75 18-18,75=-0,75 (-0,75)2/18,75=0,03
Halifresh 14 18,75 14-18,75=-4,75 (-4,75)2/18,75=1,20
Oralight 7 18,75 7-18,75=-11,75 (-
11,75)2/18,75=7,36
467
,
24
36
,
7
20
,
1
03
,
0
87
,
15
)
(
1
2
2
k
i
i
i
i
E
E
O
P-valor= 1- Cdf.chisq(24.467, 3)=0,000
25. TESTE 2 DO AJUSTAMENTO
CHI-SQUARE GOODNESS OF FIT
Nenhuma das frequências
esperadas é inferior a 5. None
of the expected frequencies is
lower than 5.
Decisão: p-valor < a, rejeita-se H0. Decision: p-value<a, reject
H0.
Conclusão: há evidência para garantir a rejeição da afirmação
inicial Conclusion: there are enough evidence to warrant the
rejection o the original claim.
26. TESTE 2 DO AJUSTAMENTO
CHI-SQUARE GOODNESS OF FIT
Exemplo 2:
Pretende-se comparar marcas de 4 dentífricos. H1:
not all proportions are identical
H0: os dados ajustam-se à distribuição especificada
(af. Inicial) H0: data fits to the distribution (original
claim)
H1: os dados não se ajustam à distribuição
especificadaH1: data does not fits to the distribution
Toothpaste Distribuição
Dentalwhite 45%
Dentalfresh 25%
Halifresh 20%
Oralight 10%
Nenhuma das frequências esperadas é inferior
a 5.
None of the expected frequencies is lower than
5.