La Regressione. Y = f ( X ) Le motivazioni che ci spingono alla ricerca di f essenzialmente due: la Previsione ed il Controllo.

Documenti analoghi
La Regressione. Y = f ( X ) Le motivazioni che ci spingono alla ricerca di f essenzialmente due: la Previsione ed il Controllo.

Vendite (Sales) in funzione della spesa pubblicitaria in TV, Radio e Giornali (Newspaper) (Ads.xlsx)

Dati Auto (Auto.xlsx)

MEDIA DI Y (ALTEZZA):

Caso studio 12. Regressione. Esempio

y = α + βx + ε Qui ci soffermeremo su un unica classe di modelli, detti modelli statistici lineari. Si veda la seguente figura:

Università degli Studi di Napoli Parthenope. Facoltà di Scienze Motorie a.a. 2011/2012. Statistica. Lezione IV

Quale retta? La retta migliore è quella che più si avvicina all insieme dei 115

Istogrammi e confronto con la distribuzione normale

Università di Cassino. Esercitazioni di Statistica 1 del 26 Febbraio Dott. Mirko Bevilacqua

LA REGRESSIONE LINEARE SEMPLICE

ANALISI DELLA REGRESSIONE ANALISI BIVARIATA DELLA REGRESSIONE

Il termine regressione fu introdotto da Francis Galton ( ), antropologo (promotore dell eugenetica).

Caso studio 10. Dipendenza in media. Esempio

Funzioni di più variabili Massimi e Minimi una funzione definita in un insieme E. Un punto ( x0, y0)

Corso di laurea in Scienze Motorie Corso di Statistica Docente: Dott.ssa Immacolata Scancarello Lezione 9: Covarianza e correlazione

Dott.ssa Marta Di Nicola

La regressione lineare. Rappresentazione analitica delle distribuzioni

LA FUNZIONE DI VEROSIMIGLIANZA

Esercizi 12/10/2007. oppure B 0. In modo del tutto analogo AB 0 se e solo se. oppure B 0 B 0. Studio del segno di una disequazione polinomiale.

Esercitazione 4 del corso di Statistica (parte 1)

ρ XY risponde alla domanda esiste un associazione lineare tra le variabili X e Y?

Contenuti. Facoltà di Economia. Scatterplot o diagramma a dispersione Analisi grafica della relazione tra due. francesco mola.

Esercitazione 6 del corso di Statistica (parte 1)

Università di Cassino Esercitazioni di Statistica 1 del 5 Febbraio Dott. Mirko Bevilacqua

Matematica elementare art.1 di Raimondo Valeri

Regressione e Correlazione

Sommario. Facoltà di Economia. Generalità sulla variabilità A B C. francesco mola. Lezione n 4. Variabilità e Dispersione. Concetto di variabilità

Lezione 4. La Variabilità. Lezione 4 1

Interpolazione. Definizione: per interpolazione si intende la ricerca di una funzione matematica che approssima l andamento di un insieme di punti.

INDICI DI VARIABILITA

CORSO DI STATISTICA I (Prof.ssa S. Terzi)

LA REGRESSIONE LINEARE SEMPLICE

Variabilità = Informazione

Università egli Studi di Bergamo Corso di laurea in Ingegneria Edile STATISTICA Stima di massima verosimiglianza

Due distribuzioni, stessa media ma in quale delle due la media rappresenta, sintetizza meglio la situazione?

Due distribuzioni, stessa media ma in quale delle due la media rappresenta, sintetizza meglio la situazione?

( ) 2 i 1 X. n(n + 1) a) si determini se sono corretti; b) per quelli non corretti, si calcoli la distorsione d;

Facoltà di Economia - STATISTICA - Corso di Recupero a.a Prof.ssa G. Balsamo CONCETTI di BASE Carattere X [o A ] i = 1

Seconda Prova Parziale di STATISTICA Modalità A

Analisi dei Dati. La statistica è facile!!! Correlazione

Indipendenza tra due caratteri

Sommario. Facoltà di Economia francesco mola ( ) ( ) Boxplot (grafico a scatola) Esempio riepilogativo sulla forma di una distribuzione

SECONDA PROVA INTERMEDIA DI STATISTICA CLEA gennaio 2005 COMPITO C2

12/11/2015 STATISTICA 1. Esercitazione 4. Dott.ssa Vera Gurtovaya

Approfondimenti sui diagrammi di Bode

Correlazione. Obiettivo: studiare la dipendenza fra due fenomeni quantitativi

Capitolo 17. Suggerimenti agli esercizi a cura di Elena Siletti. Esercizio 17.1: Suggerimento

Capitolo 6 Gli indici di variabilità

I percentili e i quartili

Associazione tra due variabili quantitative

Esercitazione 3 del corso di Statistica (parte 1)

Esame di Statistica del 20 Giugno 2014 Corso di Laurea in Economia Docente: S. Giordano

Aritmetica 2016/2017 Esercizi svolti in classe Quarta lezione

7 STIMATORI DI REGRESSIONE LINEARE 7.1 INTRODUZIONE

Compito A1- Soluzioni

Gli indici sintetici Forma. Un caso studio. Gli indici sintetici. Qualche considerazione. Qualche considerazione. Tendenza centrale Forma

Esercitazione 5 del corso di Statistica (parte 1)

pè via che, lì, la media è sempre eguale risurta che te tocca un pollo all'anno: Me spiego: da li conti che se fanno seconno le statistiche d'adesso

Soluzione degli esercizi del capitolo 11

b) Relativamente alla variabile PREZZO, fornire una misura della variabilità della distribuzione attraverso

Gli indici sintetici Forma. Gli indici sintetici. Gli indici sintetici. Qualche considerazione. Qualche considerazione. Tendenza centrale Forma

Analisi Matematica Lezione 30, 4 dicembre 2014 e x2 dx =

DATA MINING PER IL MARKETING (63 ore)

( ) ( ) ( ) ( ) Mutua variabilità. n n 1. n n 1. n n 1. n n 1

Indici di asimmetria. Elementi di Statistica descrittiva Parte IV. Simmetria di una distribuzione di frequenze. Primo indice di asimmetria (1/3)

Lezione 13. Anelli ed ideali.

Anche le rette raccontano

Generalmente sia l ampiezza che il valore medio della sollecitazione sono variabili nel tempo.

Analisi della Dipendenza

UNIVERSITA DEGLI STUDI MEDITERRANEA DI REGGIO CALABRIA

exp("# (al posto di n) var Ca Coefficiente di asimmetria, indipendente dal valore dei parametri. f X DISTRIBUZIONE EV1 o DI GUMBEL.

Controlli Automatici A

La media aritmetica. La sua individuazione si basa sulla logica della trasferibilità di un carattere. Se la funzione f( ) corrisponde alla somma:

Gli indici sintetici Forma. Un caso studio. Gli indici sintetici. Qualche considerazione. Qualche considerazione. Tendenza centrale Forma

Elementi di Statistica descrittiva Parte III

Rappresentazioni analitiche delle distribuzioni

Il modello di regressione lineare semplice (1) Studio della dipendenza riepilogo

6. LA CONCENTRAZIONE

La media aritmetica. Le medie. Esempio. Esempio. Media aritmetica Mediana. Medie analitiche Medie di posizione. x 1

ESAME DI STATISTICA cdl in ECONOMIA 13 GIUGNO Cognome Nome Matr.

6. LA CONCENTRAZIONE

Analisi delle distribuzioni doppie: dipendenza

Capitolo 13 Il modello di regressione lineare

Metodologie informatiche per la chimica

Caso studio 2. Le medie. Esercizio. La media aritmetica. Esempio

Daniela Tondini

Luogo delle Radici. Andrea Gasparri

PROVA SCRITTA DI STATISTICA (COD ) 4 Febbraio 2004 MODALITÀ A APPROSSIMARE TUTTI I CALCOLI ALLA QUARTA CIFRA DECIMALE

Unità 11. Studio di più variabili. Interpolazione. Regressione. Correlazione. Notazione matriciale

Indipendenza in distribuzione

Facoltà di Farmacia Corso di Matematica con elementi di Statistica Docente: Riccardo Rosso

Ellissi di densità costante. Distribuzione normale multivariata. Ellissoidi di isodensità. Esempio isodensità: X~N 2 (μ,σ) Consideriamo

1 ANALISI MATEMATICA A - Esercizi della settimana 1

Sommario. Facoltà di Economia. Obiettivo. Quando studiarla? Lezione n 7. X: carattere quantitativo tra le unità statistiche. Quando studiarla?

Modulo di Fisica Tecnica. Differenze finite per problemi di conduzione in regime instazionario

Voti Diploma Classico Scientifico Tecn. E Comm Altro

Classi di reddito % famiglie Fino a Oltre Totale 100

Statistica per le ricerche di mercato. 10. La regressione lineare semplice

ESAME DI STATISTICA cdl in ECONOMIA 13 GIUGNO Cognome Nome Matr.

Transcript:

La Regressoe Sulla base delle coppe d modaltà osservate (x 1,y 1 ),..,(x,y ), dopo aver verfcato la dpedeza tra caratter quattatv X ed Y, c propoamo d determare la fuzoe matematca f che meglo stetzz l legame d dpedeza tra X ed Y, coè: Y = f ( X ) Le motvazo che c spgoo alla rcerca d f essezalmete due: la Prevsoe ed l Cotrollo. soo Gova Latorre 1

Prevsoe Nella fase d raccolta de dat corrspodeza de valor osservat x 1, x 2,,x d X e soo stat ache rlevat valor y 1, y 2,...,y d Y. Se s osserva u uovo valore d X, dcamo x +1, possamo prevedere l goto valore d Y co y +1 = f ( x +1 ). Cotrollo Sulla base degl valor osservat d X e d Y s è determata la fuzoe che lega le due varabl: Y=f(X). C s chede ora: quale valore cogto l operatore deve dare alla X per otteere u desderato valore y 0 della Y. Il valore cogto è: x 0 = f -1 ( y 0 ), coè quel valore d X tale che f(x 0 )=y 0. Gova Latorre 2

Uemploymet Rate 25,0 20,0 Uemploymet rate ( % of age group from 25 to 74 years) by Veture captal vestmets ( % of GDP) of 20 EU coutres YEAR 2012 15,0 10,0 Italy (0,004;8,9) Demark (0,072;6,3) 5,0 0,0 0,000 0,020 0,040 0,060 0,080 0,100 0,120 0,140 Veture Captal Ivestmets Gova Latorre 3

Uemploymet Rate 25,0 20,0 Uemploymet rate ( % of age group from 25 to 74 years) by Veture captal vestmets ( % of GDP) of 20 EU coutres YEAR 2012 15,0 10,0 Italy (0,004;8,9) Demark (0,072;6,3) 5,0 0,0 0,000 0,020 0,040 0,060 0,080 0,100 0,120 0,140 Veture Captal Ivestmets Gova Latorre 4

Uemploymet Rate 25,0 20,0 Uemploymet rate ( % of age group from 25 to 74 years) by Veture captal vestmets ( % of GDP) of 20 EU coutres YEAR 2012 15,0 10,0 Italy (0,004;8,9) Demark (0,072;6,3) 5,0 x=0,040 0,0 0,000 0,020 0,040 0,060 0,080 0,100 0,120 0,140 Veture Captal Ivestmets Gova Latorre 5

Uemploymet Rate 25,0 20,0 Uemploymet rate ( % of age group from 25 to 74 years) by Veture captal vestmets ( % of GDP) of 20 EU coutres YEAR 2012 15,0 10,0 Italy (0,004;8,9) Prevsoe=8,3 Demark (0,072;6,3) 5,0 x=0,040 0,0 0,000 0,020 0,040 0,060 0,080 0,100 0,120 0,140 Veture Captal Ivestmets Gova Latorre 6

Uemploymet Rate 25,0 20,0 Uemploymet rate ( % of age group from 25 to 74 years) by Veture captal vestmets ( % of GDP) of 20 EU coutres YEAR 2012 15,0 10,0 Italy (0,004;8,9) y=8,0 Demark (0,072;6,3) 5,0 0,0 0,000 0,020 0,040 0,060 0,080 0,100 0,120 0,140 Veture Captal Ivestmets Gova Latorre 7

Uemploymet Rate 25,0 20,0 Uemploymet rate ( % of age group from 25 to 74 years) by Veture captal vestmets ( % of GDP) of 20 EU coutres 15,0 10,0 Italy (0,004;8,9) y=8,0 Demark (0,072;6,3) 5,0 Cotrollo=0,046 0,0 0,000 0,020 0,040 0,060 0,080 0,100 0,120 0,140 Veture Captal Ivestmets Gova Latorre 8

I dat del problema della rcerca della fuzoe f pù doea a rappresetare l legame tra X ed Y soo costtut dalle coppe d valor (x, y ) che grafcamete s possoo rappresetare co put: Gova Latorre 9

Il modo pù semplcstco per determare f cosste ello sceglere la polomale d equazoe Y=a 0 +a 1 x+a 2 x 2 + +a -1 x -1, che passa per tutt gl put dat: Gova Latorre 10

Dfett della polomale d grado (-1) La polomale d grado (-1) a) o opera essua stes; dat cosstoo coppe (x, y ) e la polomale è dvduata da parametr a 0,, a -1 ; b) o utlzzable a causa della sua complesstà; c) è certamete dversa dalla evetuale legge vera che lega Y ad X, perché quest ultma geererebbe dat scuramete affett da u certo grado d errore. Meglo sarebbe, ad esempo, la spezzata [x, M(Y x )] ma o s tratta d ua fuzoe matematca. Gova Latorre 11

S opera meglo se s procede el modo seguete: a) s potzza u modello semplce d relazoe tra X ed Y; b) s determao valor de parametr del modello mmzzado resdu, coè le dffereze tra valor osservat d Y ed valor teorc d Y*, fort dal modello; c) s gudca la botà d adattameto del modello a dat sulla base dell adameto de resdu; d) se l modello è soddsfacete, sulla base de resdu, s scegle u uovo modello da predere cosderazoe, e s rparte da a). Gova Latorre 12

Il modello d relazoe pù semplce è quello leare: a e b soo: - parametr del modello, ovvero: Y= a+ b X - l terme oto ed l coeffcete d X, ovvero: - l tercetta ed l coeffcete agolare della retta d equazoe: y=a+bx. Gova Latorre 13

Esempo d perfetta relazoe leare tra X ed Y: Y = a + b X : co Y = a quado X = 0 e Y = a + b per X = 1. Gova Latorre 14

Y Il Metodo de Mm Quadrat X Gova Latorre 15

Y Il Metodo de Mm Quadrat X Gova Latorre 16

Y Il Metodo de Mm Quadrat y x X Gova Latorre 17

Y Il Metodo de Mm Quadrat y y x X Gova Latorre 18

Y Il Metodo de Mm Quadrat y y x Gova Latorre X 19

Y Il Metodo de Mm Quadrat y (y -y ) y x Gova Latorre X 20

Y Il Metodo de Mm Quadrat y e = (y -y ) y x Gova Latorre 21 X

Gova Latorre 22

Gova Latorre 23

Gova Latorre 24

Gova Latorre 25

Gova Latorre 26

Gova Latorre 27

Gova Latorre 28

Gova Latorre 29

Gova Latorre 30

Gova Latorre 31

Gova Latorre 32

Gova Latorre 33

Gova Latorre 34

Gova Latorre 35

Gova Latorre 36

Gova Latorre 37

Gova Latorre 38

Gova Latorre 39

Gova Latorre 40

Gova Latorre 41

Gova Latorre 42

Gova Latorre 43

Gova Latorre 44

Gova Latorre 45

Gova Latorre 46

Gova Latorre 47

Gova Latorre 48

Metodo de Mm Quadrat S dspoe d coppe d valor ( x, y ) relatve a caratter X ed Y rlevat su utà statstche. Avedo verfcato la dpedeza statstca d Y da X s vuole determare la fuzoe f pù doea per descrvere tale legame. Ipotzzamo, prma approssmazoe, che tale fuzoe sa la retta d equazoe: Y * = a + b X. I tal caso corrspodeza de valor d X: x 1, x 2,,x, le ordate de put ad ess corrspodet e gacet su tale retta soo: y * 1 = a + b x 1 y * 2 = a + b x 2. y * = a + b x tal ordate y * (=1,) le chameremo valor teorc d Y, Gova Latorre 49 metre le y (=1,) soo valor osservat della Y.

Impoamo ora la codzoe che sa mmzzata la somma de quadrat delle dffereze (y y * ) e determamo parametr cogt a e b modo che tale codzoe sa soddsfatta: Per determare valor d a e b che redao mma S dobbamo dervare la fuzoe f(a,b) rspetto ad a e b, uguaglare a zero le dervate parzal e rsolvere l sstema d I grado che s ottee, avete cogte a e b. Per verfcare che le soluzo a e b che s otterrao mmzzo S bast cosderare che f(a,b) è ua fuzoe d secodo grado tale Gova Latorre 50 f(a,b) 0.

Avremo che: Gova Latorre 52

Aalogamete avremo: Gova Latorre 53

Uguaglado a zero le due dervate parzal avremo l Sstema Normale: Gova Latorre 54

Sstema Normale: Gova Latorre 55

Nell espressoe che c forsce b se dvdamo umeratore e deomatore per 2, otterremo: oltre dalla prma equazoe del Sstema avremo: da cu otteamo: a e b soo gl stmator mm quadrat d a e b e la retta d equazoe: Y = a + b X è detta Retta d Regressoe e le y = a + b x soo valor stmat d Y corrspodeza Gova delle Latorre x osservate d X. 56

Alteratvamete, abbamo: Gova Latorre 57

Dervamo la fuzoe S rspetto ad a e b: S a = f S b = f b = 2b =1 a = 2a 2 =1 le dervate secode sarao allora: y + 2b =1 x x 2 2 x y + 2a =1 =1 x 2 S a 2 = 2 f a 2 = 2 > 0 2 S b 2 = 2 f b 2 = 2 > 0 Essedo queste ultme etrambe postve allora valor d a e b che aullao le dervate prme d S rappresetao u mmo d S=f(a,b). Gova Latorre 58

Pertato uguaglado a zero le dervate prme avremo: a y + b x = 0 =1 =1 a x + b x 2 x y = 0 =1 =1 =1 da cu otteamo le Equazo Normal: a + b x = y =1 =1 a x + b x 2 = x y =1 =1 =1 che formao u sstema d due equazo elle due cogte a e b, coè valor d a e d b che redoo mma S. Gova Latorre 59

Dalle equazo ormal otteamo: da cu: a = M y b M x M y b M x M x + b x 2 = x y a = M y b M x =1 =1 M x M y b M 2 x + b x 2 = x y =1 =1 a = M y b M x b x 2 M2 x =1 = x y M x M y =1 Gova Latorre 60

ed acora: a = M y b M x b = σ =1 x y M x M y x 2 2 M x σ =1 coè: a = M y b M x Cov(X, Yሻ b = V(Xሻ dove a e b soo, da ua parte, valor da dare ad a e b per mmzzare S e, dall altra, soo gl stmator dell tercetta e del coeffcete agolare della Retta d Regressoe, otteut col metodo de Mm Quadrat. Gova Latorre 61

Dagramma d Dspersoe: mpg vs horsepower Gova Latorre 62

Dagramma d Dspersoe: mpg vs horsepower e Retta d Regressoe: mpg = 39.94-0.16 * horsepower ( R 2 = 0.61 ) Gova Latorre 63

Vedte (Sales) fuzoe della spesa pubblctara TV, Rado e Goral (Newspaper) (Ads.xlsx) TV Rado Newspaper Sales 1 230.1 37.8 69.2 22.1 2 44.5 39.3 45.1 10.4 3 17.2 45.9 69.3 9.3 4 151.5 41.3 58.5 18.5 5 180.8 10.8 58.4 12.9 6 8.7 48.9 75.0 7.2 7 57.5 32.8 23.5 11.8 8 120.2 19.6 11.6 13.2 9 8.6 2.1 1.0 4.8 10 199.8 2.6 21.2 10.6 11 66.1 5.8 24.2 8.6 12 214.7 24.0 4.0 17.4 13 23.8 35.1 65.9 9.2 14 97.5 7.6 7.2 9.7 15 204.1 32.9 46.0 19.0 16 195.4 47.7 52.9 22.4 17 67.8 36.6 114.0 12.5 18 281.4 39.6 55.8 24.4 19 69.2 20.5 18.3 11.3 20 147.3 23.9 19.1 14.6 21 218.4 27.7 53.4 18.0 Gova Latorre 64

Vedte (Sales) fuzoe della spesa pubblctara TV, Rado e Goral (Newspaper) (Ads.xlsx) Gova Latorre 65

Gova Latorre 66

Vedte (Sales) fuzoe della spesa pubblctara TV, Rado e Goral (Newspaper) (Ads.xlsx) Superfce che rappreseta la Somma de Quadrat de Resdu fuzoe d (a,b) Gova Latorre 67

Vedte (Sales) fuzoe della spesa pubblctara TV, Rado e Goral (Newspaper) (Ads.xlsx) Isoquat che rappresetao la Somma de Quadrat de Resdu fuzoe d (a,b) 7.03259 Gova Latorre 68

Propretà della retta d regressoe: 1)Se tutte le coppe d dat osservat (x, y ) soddsfao la relazoe: y = c + d x,, allora put corrspodet soo perfettamete alleat su ua retta d equazoe Y = c + d X che cocde esattamete co la Retta d Regressoe d equazoe Y = a + b X, coè: b =Cov(X,Y)/V(X) = d e a = M(Y) b M(X) = c d cosegueza y = y,, e V(Y ) = V(Y). Dmostrazoe: date le coppe (x equazoe:, y ) la Retta d Regressoe avrà Y = a + b X, dove b = Cov(X,Y) / V(X) e a = M(Y) b M(X). Gova Latorre 69

Ma: Cov(X,Y)= = = 1 1 = d =1 =1 1 1 x - M(X) y - M(Y) x - M(X) c+d x - c - d M(X) x - M(X) d x - M(X) =1 x - M(X) = d V(X) =1 da cu: d = Cov(X,Y)/V(X) = b oltre: c = M(Y) d M(X) = a + b M(X) b M(X) = a. 2 = = = Ife: y = a + b x = c + d x = y c.d.d.. Gova Latorre,, e V(Y ) = V(Y), 70

2)Propretà d mmo de resdu: deft resdu le dffereze tra valor osservat y ed valor stmat y della Y, coè e = (y y ) avremo: =1 y - y 2 = mmo (a, b) Dmostrazoe: y = a + b x, dove a e b soo tal che sa: ma: Gova Latorre c.d.d. 71

3) La meda de resdu è ulla, coè M(e) = 0, perché la somma de resdu è ulla, coè: La varaza, vece, è par a:. Dmostrazoe: dalla prma equazoe del sstema ormale s ha che:, oltre: qud: e M(e)=0. Ife: Gova Latorre 72

Msura della botà della regressoe Dopo aver stmato l modello pù semplce d relazoe tra X ed Y affroteremo l problema della botà dell adattameto del modello otteuto a dat rlevat. Baseremo molta d questa aals su resdu, deft da: e = y y. Itato s ot che: =1 = = +2 2 y - M(Y) = y - M(Y)+ y - y =1 =1 y - y+ y - M(Y) 2 y y' + y - M(Y) =1 y - yy - M(Y) =1 =1 Gova Latorre 2 = 2 + 2 = 73

S ot che ella formula precedete l doppo prodotto è ullo: =0, I^ eq. ormale =1 = = y - yy - M(Y) =1 =1 = a = b = b = y - y y - y - y M(Y)= y - ya +bx - M(Y) y - y= =1 =1 =1 y - y+b y - y =1 y x - a - bx y - a =1 x x =1 = - b Gova Latorre =1 x =1 x 2 = = 0 =0, II^ eq. ormale =0, I^ eq. ormale 74

qud: =1 = =1 y - M(Y) V(Y)=V(Y )+ 2 = 2 y - M(Y) + y - y dvdedo membro a membro per avremo: 1 =1 =1 2 1 2 y - y =V(Y )+ ma rcordado che M(e)=0 l ultmo terme è par a V(e), coclusoe: V(Y) =V(Y')+V(e) dove: V(Y) = Varabltà Totale = Varabltà delle y osservate; V(Y ) = Varabltà del Modello o della Regressoe = =Varabltà delle y ; Gova Latorre 75 V(e) = Varabltà Resdua = Varabltà degl e. =1 e 2

Y y 7 y 9 y 6 y 8 y 4 y 5 y 3 y 2 y 1 I I I I I I I I I I I I I I I I I x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 Gova Latorre I X 76

Y Valor d x y 7 y 9 y 6 y 8 y 4 y 5 y 3 y 2 y 1 I I I I I I I I I I I I I I I I I x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 Gova Latorre I X 77

Y y 7 y 9 y 6 y 8 y 4 y 5 y 3 y 2 y 1 I I I I I I I I I I I I I I I I I x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 Gova Latorre I X 78

Y Retta d Regressoe: Y = a + b X y 7 y 9 y 6 y 8 y 4 y 5 y 3 y 2 y 1 I I I I I I I I I I I I I I I I I x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 Gova Latorre I X 79

Y Valor d y y 7 y 9 y 6 y 8 y 4 y 5 y 3 y 2 y 1 I I I I I I I I I V(Y) = Varabltà Totale = Varabltà delle y osservate I I I I I I I I x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 Gova Latorre I X 80

Y Retta d Regressoe: Y = a + b X y 7 y 9 y 6 y 8 y 4 y 5 y 3 y 2 y 1 I I I I I I I I I I I I I I I I I Valor d y V(Y ) = Varabltà del Modello o della Regressoe = = Varabltà spegata = Varabltà delle y x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 Gova Latorre I X 81

Y Retta d Regressoe: Y = a + b X Valor d e y 7 y 9 y 6 y 8 y 4 y 5 y 3 y 2 y 1 V(e) = Varabltà Resdua = Varabltà degl e I I I I I I I I I I I I I I I I I x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 Gova Latorre I X 82

Coeffcete d determazoe R 2 = V( Y!) V(Y) Valor estrem d R 2 = var. spegata var. totale Se put d coordate (x, y ) soo alleat su ua retta abbamo gà vsto che la Retta d Regressoe cocde co tale retta, pertato: y = y per (=1,,), V(Y ) = V(Y) e R 2 = 1. Se la Retta d Regressoe è parallela all asse delle ascsse s ha che: y = cost. = M(Y ) = M(Y) per (=1,,), pertato: V(Y )= 0 e R 2 = 0. 0 R 2 1 Gova Latorre 83

V(Y )= = = = = 1 1 1 1 =1 =1 =1 =1 1 y b Altre propretà d R 2 =1 a+bx x - M(X) + a+bm(x)- M(Y) y - M(Y) 2 = - M(Y)+bM(X)- bm(x) - bm(x)+bm(x)- M(Y) 2 2 b x - M(X) = b x - M(X) 1 =1 2 = 2 = 2 =0, I^ eq. ormale = 2 da cu: V(Y ) = b 2 Gova LatorreV(X) 84

Acora: R 2 = V( Y) V(Y) = b' 2 V(X) V(Y) = = Cov(X,Y)2 V(X) 2 V(X) V(Y) = = Cov(X,Y)2 V(X) V(Y) = r(x,y)2 coclusoe, e modell del tpo: Y = a + b X, s ha che: R 2 = r(x,y) 2 Gova Latorre 85

Nella dmostrazoe sulla scomposzoe della varabltà avevamo dmostrato che: 1 2 y y y 0 y y y 0 y y pertato: Cov Y, Y qud: = 1 =1 Þ r Y, Y = 1 =1 1 ( ) = Cov(Y, 1 1 y M Y y M Y = y y M Y 2 = 1 =1 Y) V(Y) V( Y) = V( Y) V(Y) V( Y) = 1 y 2 y 2 M Y 2 = V(Y ሻ 0 V( Y) 2 = V(Y) V( Y) = V( Y) V(Y) = coè s ha sempre: Gova Latorre R2 R 2 = r(y,y ). 86

Aals de Resdu. (1- R 2 ) c dce quato o è stato spegato dal modello, l Aals de Resdu c dce come l modello o ha spegato dat. Rcordamo che resdu soo deft da: e = y - y, per (=1,..,) e che: a) b) =1 e = V(e)= =1 1 y - y= 0 M(e)= e = 0 =1 e 2 - M(e) 2 = 1 1 =1 =1 e 2 = 1 y - y =1 2 c) V(Y) = V(Y ) + V(e). Gova Latorre 87

L Aals de Resdu è d tpo grafco. Essa cosste el costrure dagramm scatter : 1) (y, e ); 2)(x, e ) per (=1,..,) e verfcare adamet o-formatv, ovvero accdetal etro ua bada parallela all asse delle ascsse. Esempo d scatter d Resdu. e y (o x ) Se resdu hao l adameto descrtto ello scatter l modello è adeguato e o mglorable, Gova Latorre ache se R 2 è basso. 88

Lo scatter successvo mostra che l modello che ha determato resdu rportat el dagramma o è adeguato, perché u evdete compoete d II grado o è stata catturata e la s rtrova e resdu. e y (o x ) Gova Latorre 89

40,00 35,00 30,00 25,00 Dagramma Scatter (a) relatvo a 100 coppe d modaltà (x, y ) de caratter quattatv X e Y M(X)=11,87; M(Y)=9,87; V(X)=58,74; V(Y)=102,84; Cov(X,Y)=41,42; r(x,y)=0,53 b =0,71; a =1,50; R 2 =0,28; X1=5,00; y1=5,03; X2=30,00; y2=22,66. ( sovrmpressoe la retta d equazoe: Y = 1,5 + 0,71 X ) 20,00 15,00 10,00 M y =9,9 5,00 0,00 M x =11,9 0,00 5,00 10,00 15,00 20,00 25,00 30,00 35,00-5,00-10,00-15,00 Gova Latorre 90

20,00 15,00 Data set (a) relatvo a 100 coppe d modaltà (x, y ) de e caratter quattatv X e Y ANALISI DEI RESIDUI 10,00 5,00 Y 0,00 0,00 5,00 10,00 15,00 20,00 25,00-5,00-10,00-15,00-20,00 Gova Latorre 91

Aalogamete, per l data set (b), essedo caratter quattatv X e Y cocord, soo prevalet prodott d scart postv, qud Cov(X,Y)>0, partcolare: Cov(X,Y) = 41,64. 30,00 25,00 20,00 M(X)=11,87; M(Y)=10,29; V(X)=58,74; V(Y)=33,21; Cov(X,Y)=41,64; r(x,y)=0,94; b =0,71; a =1,88; R 2 =0,89; X1=0,00; y1=1,88; X2=20,00; y2=16,05. ( sovrmpressoe la retta d equazoe: Y = 1,88 + 0,71 X ) 15,00 10,00 M(Y)=10,29 5,00 M(X)=11,87 0,00 0,00 5,00 10,00 15,00 20,00 25,00 30,00 35,00-5,00 Gova Latorre 92

4,00 3,00 Data set (b) relatvo a 100 coppe d modaltà (x, y ) de e caratter quattatv X e Y ANALISI DEI RESIDUI 2,00 1,00 Y 0,00 0,00 5,00 10,00 15,00 20,00 25,00-1,00-2,00-3,00-4,00-5,00 Gova Latorre 93

Dagramma Scatter (c) relatvo a 100 coppe d modaltà (x, y ) de caratter quattatv X e Y 30 25 ( sovrmpressoe la retta d equazoe: Y = 24,19-0,74 X ) M(X)=11,88; M(Y)=15,40; V(X)=59,05; V(Y)=36,31; Cov(X,Y)=-43,72; r(x,y)=-0,94; b =-0,74; a =24,19; R 2 =0,89; X1=0,00; y1=24,19; X2=20,00; y2=9,39. 20 15 M y =15,4 10 5 0 Gova Latorre 0 5 10 M x =11,9 15 20 25 30 35 94

4,00 3,00 Data set (c) relatvo a 100 coppe d modaltà (x, y ) e de caratter quattatv X e Y ANALISI DEI RESIDUI 2,00 1,00 Y 0,00 0,00 5,00 10,00 15,00 20,00 25,00-1,00-2,00-3,00-4,00-5,00 Gova Latorre 95

Data Set (d) relatvo a 100 coppe d modaltà (x, y ) de caratter quattatv X e Y 8 6 4 ( sovrmpressoe la retta d equazoe: Y = 1,21 0,004 X ) M(X)=11,82; M(Y)=1,17; V(X)=57,42; V(Y)=9,28; Cov(X,Y)=-0,20; r(x,y)=-0,01; b =-0,004; a =1,21; R 2 =0,00; X1=0,00; y1=1,21; X2=20,00; y2=1,14. 2 M y =1,2 0 0 5 10 M x =11,8 15 20 25 30-2 -4-6 Gova Latorre 96

6,00 Data set (d) relatvo a 100 coppe d modaltà (x, y ) e de caratter quattatv X e Y ANALISI DEI RESIDUI 4,00 2,00 Y 0,00 1,10 1,12 1,14 1,16 1,18 1,20 1,22-2,00-4,00-6,00 Gova Latorre 97

6 4 Data Set (e) relatvo a 100 coppe d modaltà (x, y ) de caratter quattatv X e Y M(X)=2,91; M(Y)=0,14; V(X)=2,01; V(Y)=6,17; Cov(X,Y)=-0,03; r(x,y)=-0,01; b =-0,01; a =0,18; R 2 =0,00; X1=0,00; y1=0,18; X2=4,00; y2=0,13. 2 0 M y =0,1 M 0 1 2 x =2,9 3 4 5 6-2 -4-6 -8 Gova Latorre 98

6,00 4,00 Data set (e) relatvo a 100 coppe d modaltà (x, y ) e de caratter quattatv X e Y ANALISI DEI RESIDUI 2,00 Y 0,00 0,10 0,11 0,12 0,13 0,14 0,15 0,16 0,17 0,18-2,00-4,00-6,00-8,00 Gova Latorre 99

Dat Auto (Auto.xlsx) mpg cylders dsplacemet horsepower weght accelerato year org ame 1 18.0 8 307.0 130 3504 12.0 70 1 chevrolet chevelle malbu 2 15.0 8 350.0 165 3693 11.5 70 1 buck skylark 320 3 18.0 8 318.0 150 3436 11.0 70 1 plymouth satellte 4 16.0 8 304.0 150 3433 12.0 70 1 amc rebel sst 5 17.0 8 302.0 140 3449 10.5 70 1 ford toro 6 15.0 8 429.0 198 4341 10.0 70 1 ford galaxe 500 7 14.0 8 454.0 220 4354 9.0 70 1 chevrolet mpala 8 14.0 8 440.0 215 4312 8.5 70 1 plymouth fury 9 14.0 8 455.0 225 4425 10.0 70 1 potac catala 10 15.0 8 390.0 190 3850 8.5 70 1 amc ambassador dpl 11 15.0 8 383.0 170 3563 10.0 70 1 dodge challeger se 12 14.0 8 340.0 160 3609 8.0 70 1 plymouth 'cuda 340 13 15.0 8 400.0 150 3761 9.5 70 1 chevrolet mote carlo 14 14.0 8 455.0 225 3086 10.0 70 1 buck estate wago (sw) 15 24.0 4 113.0 95 2372 15.0 70 3 toyota coroa mark 16 22.0 6 198.0 95 2833 15.5 70 1 plymouth duster 17 18.0 6 199.0 97 2774 15.5 70 1 amc horet 18 21.0 6 200.0 85 2587 16.0 70 1 ford maverck 19 27.0 4 97.0 88 2130 14.5 70 3 datsu pl510 20 26.0 4 97.0 46 1835 20.5 70 2 volkswage 1131 deluxe seda 21 25.0 4 110.0 87 2672 17.5 70 2 peugeot 504 22 24.0 4 107.0 90 2430 14.5 70 2 aud 100 ls 23 25.0 4 104.0 95 2375 17.5 70 2 saab 99e 24 26.0 4 121.0 113 2234 12.5 70 2 bmw 2002 25 21.0 6 199.0 90 2648 15.0 70 1 amc greml 26 10.0 8 360.0 215 4615 14.0 70 1 ford f250 27 10.0 8 307.0 200 4376 15.0 70 1 chevy c20 28 11.0 8 318.0 210 4382 13.5 70 1 dodge d200

Dat Auto (Auto.txt) mpg cylders dsplacemet horsepower weght accelerato year org ame 372 29.0 4 135.0 84 2525 16.0 82 1 dodge ares se 373 27.0 4 151.0 90 2735 18.0 82 1 potac phoex 374 24.0 4 140.0 92 2865 16.4 82 1 ford farmot futura 375 36.0 4 105.0 74 1980 15.3 82 2 volkswage rabbt 376 37.0 4 91.0 68 2025 18.2 82 3 mazda glc custom l 377 31.0 4 91.0 68 1970 17.6 82 3 mazda glc custom 378 38.0 4 105.0 63 2125 14.7 82 1 plymouth horzo mser 379 36.0 4 98.0 70 2125 17.3 82 1 mercury lyx l 380 36.0 4 120.0 88 2160 14.5 82 3 ssa staza xe 381 36.0 4 107.0 75 2205 14.5 82 3 hoda accord 382 34.0 4 108.0 70 2245 16.9 82 3 toyota corolla 383 38.0 4 91.0 67 1965 15.0 82 3 hoda 384 32.0 4 91.0 67 1965 15.7 82 3 hoda cvc (auto) 385 38.0 4 91.0 67 1995 16.2 82 3 datsu 310 gx 386 25.0 6 181.0 110 2945 16.4 82 1 buck 387 38.0 6 262.0 85 3015 17.0 82 1 oldsmoble cutlass cera 388 26.0 4 156.0 92 2585 14.5 82 1 chrysler lebaro medallo 389 22.0 6 232.0 112 2835 14.7 82 1 ford graada l 390 32.0 4 144.0 96 2665 13.9 82 3 toyota celca gt 391 36.0 4 135.0 84 2370 13.0 82 1 dodge charger 2.2 392 27.0 4 151.0 90 2950 17.3 82 1 chevrolet camaro 393 27.0 4 140.0 86 2790 15.6 82 1 ford mustag gl 394 44.0 4 97.0 52 2130 24.6 82 2 vw pckup 395 32.0 4 135.0 84 2295 11.6 82 1 dodge rampage 396 28.0 4 120.0 79 2625 18.6 82 1 ford rager 397 31.0 4 119.0 82 2720 19.4 82 1 chevy s-10

Dat Auto (Auto.txt) Regresso: Mpg vs Dsplacemet Gova Latorre 102

Dat Auto (Auto.txt) Regresso: Mpg vs Dsplacemet R Retta d Regressoe: Mpg = 35.12-0.06 Dsplacemet R 2 = 0.6482 Gova Latorre 103

Dat Auto (Auto.txt) Regresso: Mpg vs Dsplacemet Resduals vs Dsplacemet Resdu formatv Gova Latorre 104

Dat Auto (Auto.txt) Regresso: Mpg vs Dsplacemet Resduals vs Ftted Mpg Resdu formatv Gova Latorre 105

Dat Auto (Auto.txt) Regresso: Mpg vs Weght Gova Latorre 106

Dat Auto (Auto.txt) Regresso: Mpg vs Weght Retta d Regressoe: Mpg = 46.22-0.0076 Weght R 2 = 0.6926 Gova Latorre 107

Dat Auto (Auto.txt) Regresso: Mpg vs Weght Resduals vs Weght Resdu formatv Gova Latorre 108

Dat Auto (Auto.txt) Regresso: Mpg vs Weght Resduals vs Ftted Mpg Resdu formatv Gova Latorre 109