Correlacao.ppt [Modo de Compatibilidade] · 2016-03-10 · Suponha que uma amostra de nnnn = === 12...

Post on 12-Jun-2020

0 views 0 download

Transcript of Correlacao.ppt [Modo de Compatibilidade] · 2016-03-10 · Suponha que uma amostra de nnnn = === 12...

Lorí Viali, Dr.

DESTAT/FAMAT/PUCRS

viali@pucrs.br

http://www.pucrs.br/famat/viali

Correlação

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

É o grau de associação entre

duas ou mais variáveis. Pode

ser:

correlacional

ou

experimental.

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Numa relação experimental os valores de

uma das variáveis são controlados.

No relacionamento correlacional, por

outro lado, não se tem nenhum controle sobre as

variáveis sendo estudadas.

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Um engenheiro químico está

investigando o efeito da temperatura de

operação do processo no rendimento do

produto. O estudo resultou nos dados da

tabela seguinte:

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Temperatura, C0 (X) Rendimento (Y)100 45110 51120 54130 61140 66150 70160 74170 78180 85190 89

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

O primeiro passo para

determinar se existe relacionamento entre

as duas variáveis é obter o diagramadiagramadiagramadiagrama dededede

dispersãodispersãodispersãodispersão (scatter diagram).

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

0

25

50

75

100

100 120 140 160 180 200

Temperatura (X)

Rendimento

(Y)

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

O diagrama de dispersão

fornece uma idéia do tipo de

relacionamento entre as duas variáveis.

Neste caso, percebe-se que existe um

relacionamentorelacionamentorelacionamentorelacionamento linearlinearlinearlinear.

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Quando o relacionamento entre duas

variáveis quantitativas for do tipo linearlinearlinearlinear,

ele pode ser medido através do:

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Observado um relacionamentorelacionamentorelacionamentorelacionamento

linearlinearlinearlinear entre as duas variáveis é possível

determinar a intensidade deste

relacionamento. O coeficiente que mede este

relacionamento é denominado de Coeficiente

de Correlação (linear).

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Quando se está trabalhando com

amostras o coeficiente de correlação é

indicado pela letra “rrrr” e é uma estimativa

do coeficiente de correlação populacional

que é representado por “ρρρρ” (rho).

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Para determinar o coeficiente de

correlação (grau de relacionamento linear

entre duas variáveis) vamos determinar

inicialmente a variação conjunta entre elas,

isto é, a covariância.

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

A covariância entre duas variáveis X

e Y, é representada por “Cov(XCov(XCov(XCov(X;;;; Y)Y)Y)Y)” e

calculada por:

1n

)YY)(XX()Y,X(Cov ii

∑ −−=

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Mas:

∑ −=

=+∑ −−=

=∑+∑ ∑−∑−=

=∑+∑ ∑−∑−=

=+∑ −−=

=∑ −−

YXnYX

YXnYXnYXnYX

YXXYYXYX

YXYXYXYX

]YXYXYXYX[

)YY)(XX(

ii

ii

iiii

iiii

iiii

ii

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Então:

1n

YXnYX

1n

)YY)(XX()Y,X(Cov

ii

ii

∑ −=

=−

∑ −−=

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

A covariância poderia ser utilizada

para medir o graugraugraugrau e o sinalsinalsinalsinal do

relacionamento entre as duas variáveis, mas

ela é difícil de interpretar por variar de -∞ a

+∞. Assim vamos utilizar o coeficientecoeficientecoeficientecoeficiente dededede

correlaçãocorrelaçãocorrelaçãocorrelação linearlinearlinearlinear dededede PearsonPearsonPearsonPearson.

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

O coeficiente de correlação linear (de

Pearson) é definido por:

SS YX

)Y,X(Cov r =

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Onde:

1nYnY

S

1nXnX

S

1n

YXnYX )Y,X(Cov

22i

Y

22i

X

ii

∑ −=

∑ −=

∑ −=

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Esta expressão não é muito prática

para calcular manualmente o coeficiente de

correlação. Pode-se obter uma expressão mais

conveniente para o cálculo manual e o

cálculo de outras medidas necessárias mais

tarde.

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Tem-se:

( )( )∑ −∑ −

∑ −=

=

∑ −

∑ −

∑ −

=

==

YnYXnX

YXnYX

1nYnY

1nXnX

1n

YXnYX

SS

)Y,X(Cov r

22i

22i

ii

22i

22i

ii

YX

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Fazendo:

S.S

S r :seTem

YnYS

XnXS

YXnYXS

YYXX

XY

22iYY

22iXX

iiXY

=−

∑ −=

∑ −=

∑ −=FFFFFFFFaaaaaaaazzzzzzzzeeeeeeeennnnnnnnddddddddoooooooo

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

A vantagem do coeficiente de

correlação (de Pearson) é ser adimensional e

variar de – 1 a + 1, que o torna de fácil

interpretação.

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Assim se r = -1, temos uma

relacionamento linear negativo perfeito, isto

é, os pontos estão todos alinhados e quando X

aumenta Y decresce e vice-versa.

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

0

10

20

30

40

50

10 15 20 25 30

1r −=

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Se r = +1, temos uma relacionamento

linear positivo perfeito, isto é, os pontos

estão todos alinhados e quando X aumenta

Y também aumenta.

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

0

10

20

30

40

50

10 15 20 25 30

1r +=

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Assim se r = 0, temos uma ausência de

relacionamento linear, isto é, os pontos não

mostram “alinhamento”.

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

0r =

0

10

20

30

40

50

10 15 20 25 30

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Assim se –1 < r < 0, temos uma

relacionamento linear negativo, isto é, os

pontos estão mais ou menos alinhados e

quando X aumenta Y decresce e vice-versa.

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

0r1 <<−

0

10

20

30

40

50

10 15 20 25 30

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Assim se 0 < r < 1, temos uma

relacionamento linear positivo, isto é, os

pontos estão mais ou menos alinhados e

quando X aumenta Y também aumenta.

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

0

10

20

30

40

50

10 15 20 25 30

1r0 <<

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Uma correlação amostral não significa

necessariamente uma correlação populacional

e vice-versa. É necessário testar o coeficiente

de correlação para verificar se a correlação

amostral é também populacional.

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Observada uma amostra de seis pares,

pode-se perceber que a correlação é quase

um, isto é, rrrr ≅≅≅≅ 1111. No entanto, observe o que

ocorre quando mais pontos são

acrescentados, isto é, quando se observa a

população!

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

0

10

20

30

40

50

10 15 20 25 30

r r r r ≅≅≅≅ 1111

ρ ρ ρ ρ ≅≅≅≅ 0000

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Determinar o “grau de

relacionamento linear” entre as variáveis X

= temperatura de operação do processo

versus Y = rendimento do produto, conforme

tabela.

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

X Y XY X Y100 45 4500 10000 2025

110 51 5610 12100 2601120 54 6480 14400 2916130 61 7930 16900 3721140 66 9240 19600 4356150 70 10500 22500 4900160 74 11840 25600 5476170 78 13260 28900 6084180 85 15300 32400 7225190 89 16910 36100 79211450145014501450 673673673673 101570101570101570101570 218500218500218500218500 47225472254722547225

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Vamos calcular “r” utilizando

a expressão em destaque vista

anteriormente, isto é, através das

quantidades, SxY, SXX e SYY.

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Tem-se:

47225Y 218500X

101570 XY 67,3Y 145X

673 Y 1450X 10n

22 =∑=∑

∑ ===

∑ =∑ ==

Então:

3985

3,67.145.10101570

YXnYXS iiXY

=

=−=

=∑ −=

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

8250

145.10218500

XnXS

2

22iXX

=

=−=

=∑ −=

10,1932

3,67.1047225

YnYS

2

22iYY

=

=−=

=∑ −=

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

9981,0

10,1932.8250

3985

S.S

S r

YYXX

XY

=

==

==

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Apesar de “rrrr” ser um valor

adimensional, ele não é uma taxataxataxataxa. Assim

o resultado não deve ser expresso em

percentagem.

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

O valor de “rrrr” é obtido com

base em uma amostra. Ele é portanto, uma

estimativa do verdadeiro valor da

correlação populacional (r).

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

A teoria dos testes de

hipóteses pode ser utilizada para verificar

se com base na estimativa “r” é possível

concluir se existe ou não correlação

populacional, isto é, desejamos testar :

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

H0: ρ = 0

H1: ρ > 0

(teste unilateral/unicaudal à direita)

ρ < 0

(teste unilateral/unicaudal à esquerda)

ρ ≠ 0

(teste bilateral/bicaudal) .

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

O teste para a existência de correlação

linear entre duas variáveis é realizado por:

r1

2nr

2nr1

0r

ˆ

rt

2

2r

r2n

−=

=

−=

σ

µ−=−

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

tn-2 > tc(teste unilateral/unicaudal à direita)

tn-2 < tc

(teste unilateral/unicaudal à esquerda)

|tn-2| > tc(teste bilateral/bicaudal) .

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

P(t < tc ) = 1− α

(teste unilateral/unicaudal à direita)

P(t < tc ) = α

(teste unilateral/unicaudal à esquerda)

P(t < tc ) = α/2 ou P(t > tc ) = α/2

(teste bilateral/bicaudal) .

Onde tc é tal que:

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Suponha que uma amostra de nnnn ==== 12121212,

alunos forneceu um coeficiente de correlação

amostral de rrrr ==== 0000,,,,66666666, entre X = “nota em

cálculo” e Y = “nota em Probabilidade e

Estatística”. Verifique se é possível afirmar que

uma nota boa em Cálculo está relacionada com

uma nota boa em Probabilidade e Estatística a

1111%%%% de significância.

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Trata-se de um teste unilateral à direita

para o coeficiente de correlação.

HipótesesHipótesesHipótesesHipóteses::::

H0: ρ = 0

H1: ρ > 0

DadosDadosDadosDados::::n = 12r = 0 ,66

α = 1%

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Então:

778,20661

21266,0

r1

2nrt 2210 =

−=

−=

A variável teste é:

r1

2nrt 22n

−=−

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

O valor crítico tc é tal que: P(T > tc) = 1- α

Então tc = 2,764. Assim RC = [2,764; ∞)

DECISÃODECISÃODECISÃODECISÃODECISÃODECISÃODECISÃODECISÃO eeeeeeee CONCLUSÃOCONCLUSÃOCONCLUSÃOCONCLUSÃOCONCLUSÃOCONCLUSÃOCONCLUSÃOCONCLUSÃO::::::::Como t10 = 2,778 ∈ RC ou

2,778 > 2,764, Rejeito H0, isto é, a 1% designificância, pode-se afirmar que a nota deCálculo está relacionada com a deProbabilidade e Estatística.

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Região de Não Rejeição

778,2

%1=α

);764,2[RC +∞=

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

OPÇÃOOPÇÃO::

Trabalhar com a significância do

resultado obtido (2,778), isto é, o valor-p.

Para isto, deve-se calcular P(T10 > 2,778).

Utilizando o Excel, tem-se:

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Como a significância do resultado(0,98%) é menor que a significância do teste(1%) é possível rejeitar a hipótese nula.

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

O procedimento realizado para testar o

coeficiente de correlação só é válido para testar

a hipótese nula de que nãonãonãonão existe correlação, isto

é, ρ = 0. Outros tipos de testes só podem ser

realizados através da transformada “zeta” de

Fisher.

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

A transformada “ζ” é dada por:

+=ζ

r1

r1ln

2

1

O que equivale a considerar “rrrr” como

a tangente hiperbólica de “ζζζζ”

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

A vantagem desta transformação é que

os valores de “ζ” estão distribuídos

aproximadamente de acordo com uma normal

de média:

ρ−

ρ+=µζ 1

1ln

2

1

E desvio:3n

1

−=σζ

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Esta transformação permite, realizar,

testes de hipóteses e construir intervalos de

confiança para o coeficiente de correlação,

através de ζζζζ e da distribuiçãodistribuiçãodistribuiçãodistribuição normalnormalnormalnormal.

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

H0: ρ = ρ0

H1: ρ > ρ0

(teste unilateral/unicaudal à direita)

ρ < ρ0

(teste unilateral/unicaudal à esquerda)

ρ ≠ ρ0

(teste bilateral/bicaudal) .

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

O teste para a existência de correlação

linear populacional entre duas variáveis X eY é realizado por:

3n

1

1

1ln

2

1

z

ρ−

ρ+−ζ

µ−ζ=

ζ

ζ

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

z > zc(teste unilateral/unicaudal à direita)

z < zc

(teste unilateral/unicaudal à esquerda)

|z| > zc(teste bilateral/bicaudal) .

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Φ(zc ) = 1− α

(teste unilateral/unicaudal à direita)

Φ(zc ) = α

(teste unilateral/unicaudal à esquerda)

Φ(zc ) = α/2 ou Φ(zc ) = 1− α/2

(teste bilateral/bicaudal) .

Onde zc é tal que:

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Suponha que uma amostra de nnnn ==== 35353535,alunos forneceu um coeficiente de correlaçãoamostral de rrrr ==== 0000,,,,75757575, entre X = “número de horasde estudo” e Y = “nota em Probabilidade eEstatística”. Verifique se é possível afirmar que o“o número de horas de estudo” apresenta umacorrelação de pelo menos 0,5 na população com a“nota em Probabilidade e Estatística”, a 1111%%%% designificância.

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Trata-se de um teste unilateral à direita

para o coeficiente de correlação.

Hipóteses:

H0: ρ = 0,5

H1: ρ > 0,5

DadosDadosDadosDados::::n = 35r = 0 ,75

α = 1%

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Então:

9730,075,01

75,01ln

2

1=

+=ζ

A variável teste é:

3n

1

1

1ln

2

1

z

ρ−

ρ+−ζ

µ−ζ=

ζ

ζ

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

E o desvio padrão vale:

A média vale:

5493,05,01

5,01ln

2

1

1

1ln

2

1=

+=

ρ−

ρ+=µζ

1768,032

1

335

1

3n

1==

−=

−=σζ

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Padronizando, tem-se:

40,21768,0

5493,09730,0

3n

1

1

1ln

2

1

z

=−

=

=

ρ−

ρ+−ζ

µ−ζ=

ζ

ζ

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

O valor crítico zc é tal que:

P(Z > zc) = α = 1%.

Ou Φ(zc) = 99%.

Então zc = 2,33.

Assim RC = [2,33; ∞)

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

DECISÃO e CONCLUSÃO:

Como z = 2,40 ∈ RC ou

2,40 > 2,33, Rejeito H0, isto é, a 1% de

significância, pode-se afirmar que “o número

de horas de estudo” apresenta pelo menos 0,50

de correlação com a “nota em Probabilidade e

Estatística”.

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

Região de Não Rejeição

40,2

%1=α

);33,2[RC +∞=

Prof. Lorí Viali, Dr. - PUCRS – viali@pucrs.br – http://www.pucrs.br/famat/viali/

OPÇÃOOPÇÃO::

Trabalhar com a significância do

resultado obtido (2,40), isto é, o valor-p. Para

isto, deve-se calcular (Z > 2,40), isto é, Φ(-

2,40) = 0,82%. Como p = 0,82% < α = 1%.

Rejeito H0.