Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Difference Fit vs. Correlation

2 views
Skip to first unread message

Claus

unread,
Feb 24, 2009, 5:47:58 AM2/24/09
to
Hi,
in the code below, using Correlation I get 0.501338, using Fit I get
0.514093.
How come?

Thanks for your help,
Claus


In[47]:= GaltonX = {65.04851`, 63.25094`, 64.95532`, 65.7525`,
61.13723`, 63.02254`, 65.37053`, 64.72398`, 66.06509`, 66.96738`,
59.008`, 62.93203`, 63.67063`, 64.07386`, 64.68851`, 65.15466`,
66.37353`, 65.57704`, 67.36765`, 66.75929`, 67.79764`, 69.5348`,
62.54014`, 63.81016`, 64.4565`, 64.9665`, 64.70662`, 65.73829`,
65.50141`, 65.55416`, 66.90294`, 66.57388`, 66.53198`, 67.90613`,
68.29198`, 67.74123`, 68.46917`, 69.38327`, 71.81791`, 62.41615`,
64.49083`, 64.4876`, 63.92303`, 65.44592`, 65.02977`, 65.67038`,
68.66078`, 66.54597`, 64.85954`, 69.60692`, 64.8135`, 65.32703`,
65.83169`, 65.83427`, 65.56135`, 65.8688`, 65.77339`, 67.09116`,
66.61374`, 67.41075`, 67.27716`, 66.61134`, 68.17412`, 67.80555`,
68.32529`, 68.07787`, 68.96795`, 68.9255`, 69.60862`, 70.35646`,
70.00643`, 72.75425`, 62.82147`, 62.86855`, 63.91261`, 64.54118`,
64.51906`, 66.02688`, 65.81011`, 66.01812`, 65.53742`, 65.73346`,
66.77424`, 66.67869`, 66.97585`, 66.94021`, 66.84575`, 67.12008`,
67.74181`, 68.27194`, 67.60691`, 68.44737`, 67.65832`, 68.71193`,
69.32025`, 68.7403`, 69.13395`, 69.34995`, 68.6297`, 69.58258`,
70.39517`, 71.19284`, 70.82429`, 71.65367`, 73.28133`, 63.03753`,
63.66428`, 65.38311`, 64.60205`, 66.40661`, 65.76985`, 65.66729`,
66.05712`, 66.54635`, 66.5723`, 66.64876`, 67.71899`, 68.48726`,
67.82769`, 67.55801`, 68.07763`, 69.16715`, 68.693`, 68.61779`,
68.64797`, 68.61666`, 70.36485`, 70.0099`, 70.13984`, 70.2073`,
71.28063`, 70.90445`, 72.19036`, 74.96203`, 64.88218`, 65.55174`,
65.65889`, 65.92826`, 65.94198`, 67.43646`, 67.48444`, 67.61344`,
68.4518`, 68.49456`, 68.1056`, 69.48308`, 69.07389`, 69.39251`,
69.44294`, 69.52131`, 70.15463`, 69.86911`, 70.44394`, 70.85393`,
71.30074`, 72.13978`, 72.19045`, 75.43393`, 64.51788`, 66.36335`,
65.56855`, 66.78957`, 66.91193`, 68.1714`, 67.50102`, 67.83492`,
68.95255`, 69.26`, 68.74223`, 69.74288`, 70.29942`, 70.04402`,
70.23559`, 70.88075`, 71.19091`, 72.37396`, 73.03345`, 74.8083`,
67.39521`, 67.31523`, 67.77952`, 69.33827`, 68.72404`, 69.98991`,
69.75383`, 70.65942`, 71.10882`, 72.4811`, 72.4801`, 67.52214`,
68.23931`, 68.7997`, 69.89568`, 71.48641`, 70.76482`, 71.9137`,
63.08399`, 68.23241`, 70.05787`, 70.83996`, 72.56944`, 67.93353`,
67.54033`, 72.79855`, 62.67482`, 68.19196`, 65.07215`, 73.42952`,
62.94125`, 62.53667`, 69.90248`, 71.07217`, 71.11059`, 69.48402`,
70.18338`, 65.46124`, 62.04073`, 63.60063`, 65.60613`, 68.02969`,
61.81571`, 63.78886`, 64.89023`, 65.79072`, 66.42371`, 68.80877`,
61.76521`, 64.30302`, 63.69064`, 64.99662`, 65.34899`, 64.81278`,
65.71736`, 66.03148`, 67.04912`, 67.77522`, 69.04964`, 62.1833`,
62.76393`, 63.88391`, 65.41055`, 64.62347`, 65.64621`, 66.16257`,
65.99538`, 65.79786`, 67.42936`, 67.11933`, 67.32907`, 67.86233`,
68.31609`, 67.96359`, 68.68615`, 71.18085`, 62.4296`, 62.88524`,
64.07313`, 63.88597`, 64.8272`, 65.39653`, 64.77344`, 68.66581`,
65.19783`, 64.32621`, 66.08278`, 69.01679`, 64.50194`, 66.07654`,
65.73631`, 66.45485`, 65.63018`, 66.39423`, 67.33687`, 66.83938`,
66.69739`, 67.34708`, 67.35319`, 67.93575`, 67.76608`, 68.11569`,
68.2548`, 68.83427`, 69.40758`, 69.32068`, 70.48`, 70.06429`,
70.63764`, 62.41134`, 63.15274`, 63.51409`, 63.91446`, 64.61683`,
64.86185`, 65.91332`, 66.1992`, 66.45978`, 65.50286`, 66.87795`,
67.0791`, 66.83256`, 67.18231`, 66.51763`, 66.95295`, 66.63586`,
68.18453`, 67.60565`, 68.27918`, 67.97994`, 69.00094`, 69.31139`,
68.88641`, 68.94824`, 69.42186`, 69.49516`, 70.34647`, 69.92358`,
70.69078`, 70.56571`, 72.40997`, 72.47685`, 62.72118`, 63.9001`,
64.50433`, 64.81813`, 65.37582`, 65.82612`, 66.29436`, 65.81042`,
66.80854`, 67.16724`, 67.30525`, 67.54577`, 67.86855`, 68.35003`,
67.60818`, 68.48397`, 68.56724`, 69.07405`, 68.56831`, 69.15373`,
68.60744`, 68.5443`, 69.65536`, 70.41632`, 69.97528`, 70.26613`,
71.31667`, 71.29178`, 72.59442`, 64.40268`, 64.9127`, 66.34756`,
66.04291`, 65.69477`, 66.71512`, 66.64971`, 68.33241`, 67.94335`,
67.96734`, 68.27657`, 68.75008`, 69.05441`, 69.00755`, 69.39488`,
69.7628`, 69.6464`, 70.45427`, 69.89852`, 70.984`, 71.22015`,
71.45442`, 71.60966`, 73.20296`, 63.89132`, 65.99384`, 66.0424`,
67.47658`, 66.68527`, 68.27034`, 67.72898`, 68.28372`, 68.39453`,
69.12925`, 69.10844`, 69.74196`, 69.9987`, 69.56148`, 69.97779`,
70.88691`, 70.64687`, 72.26404`, 71.50569`, 73.01402`, 66.20254`,
67.26312`, 67.8086`, 69.08284`, 69.35107`, 69.59962`, 70.08948`,
70.18385`, 71.26955`, 72.07717`, 72.33894`, 67.06776`, 67.85929`,
69.07274`, 69.59893`, 69.73728`, 70.54066`, 72.40962`, 72.78889`,
68.10144`, 68.6106`, 71.293`, 72.09445`, 74.69236`, 71.16246`,
68.30804`, 60.41857`, 63.94459`, 63.06849`, 63.98036`, 73.89524`,
72.03687`, 61.02471`, 65.39914`, 71.96564`, 71.29643`, 65.15837`,
68.90263`, 64.45192`, 63.99469`, 66.46124`, 67.12556`, 62.27941`,
63.8488`, 65.43612`, 65.62145`, 66.16956`, 67.62675`, 60.21393`,
62.99378`, 63.57239`, 65.15088`, 65.13462`, 64.79732`, 66.24856`,
66.22743`, 66.6056`, 67.99167`, 69.04862`, 62.12902`, 63.16227`,
64.45497`, 63.75483`, 64.63959`, 64.59106`, 66.06003`, 65.98544`,
65.66176`, 67.11501`, 67.31302`, 67.16149`, 68.38679`, 67.64175`,
67.55466`, 68.53614`, 70.02702`, 61.07412`, 62.72387`, 64.28642`,
64.11073`, 63.68318`, 64.68393`, 64.66753`, 67.95848`, 64.60933`,
66.07775`, 65.25267`, 69.67201`, 65.33965`, 65.54375`, 66.1112`,
66.22968`, 66.00879`, 66.03248`, 65.94624`, 67.09734`, 66.98893`,
67.38837`, 67.4075`, 67.31108`, 68.27151`, 68.33586`, 67.56752`,
68.23182`, 69.07604`, 68.77033`, 70.49154`, 70.00767`, 69.52007`,
61.50617`, 62.93875`, 64.10318`, 63.85157`, 65.08731`, 64.62588`,
65.8912`, 66.24386`, 65.66031`, 66.05344`, 66.30711`, 67.15303`,
66.90986`, 66.89436`, 66.56566`, 67.23789`, 67.05684`, 67.94515`,
67.94026`, 67.84234`, 67.91887`, 68.63961`, 68.60477`, 69.04036`,
69.03336`, 69.12497`, 68.53779`, 70.24335`, 69.84308`, 69.90057`,
71.48946`, 72.37013`, 71.94413`, 61.01904`, 63.0108`, 64.5793`,
65.39658`, 64.84995`, 65.54542`, 65.56421`, 66.09747`, 67.40602`,
66.5839`, 67.41035`, 67.21634`, 68.23175`, 67.88053`, 68.0153`,
67.69332`, 68.85462`, 68.73264`, 69.0711`, 68.79964`, 68.79876`,
69.32241`, 69.60923`, 69.76071`, 70.1611`, 70.12109`, 71.10802`,
71.44164`, 71.75006`, 64.35591`, 65.16253`, 66.09529`, 65.78674`,
65.53927`, 66.71703`, 67.17284`, 67.16853`, 68.06061`, 67.85988`,
68.1968`, 69.29537`, 68.84067`, 69.18095`, 68.69659`, 69.45833`,
70.0483`, 69.6916`, 70.20658`, 70.79086`, 70.87977`, 71.30702`,
72.3266`, 72.7824`, 64.40052`, 64.89121`, 65.84506`, 67.35461`,
67.44953`, 67.86439`, 67.92443`, 68.49998`, 67.60602`, 69.37288`,
69.34931`, 69.48306`, 70.21887`, 70.02161`, 69.83698`, 69.6041`,
71.49829`, 72.16894`, 72.41045`, 72.52521`, 64.6702`, 66.78417`,
67.83401`, 68.15907`, 69.19301`, 68.86739`, 70.11126`, 70.12007`,
71.03691`, 71.43196`, 72.04564`, 72.738`, 68.02564`, 69.04939`,
68.86356`, 69.63421`, 71.24085`, 71.95679`, 72.89983`, 65.86028`,
68.48883`, 70.72676`, 72.34582`, 72.59922`, 68.82986`, 73.49987`,
70.0599`, 67.9291`, 64.66998`, 60.7795`, 74.94058`, 70.64925`,
60.91526`, 65.28934`, 71.362`, 71.66893`, 62.68868`, 71.39326`,
66.56302`, 67.18788`, 62.532`, 64.85512`, 66.94161`, 62.3603`,
63.58145`, 65.44633`, 65.00539`, 66.43717`, 66.6676`, 59.4898`,
63.00108`, 64.0892`, 64.0753`, 64.52103`, 65.19231`, 66.30604`,
66.03081`, 66.83096`, 68.19724`, 68.6599`, 61.29369`, 63.26089`,
63.86162`, 64.13176`, 64.81105`, 64.55987`, 66.19437`, 66.5`,
66.43436`, 67.30468`, 67.36559`, 67.29162`, 67.69874`, 68.38221`,
67.76712`, 69.29587`, 69.66477`, 60.03436`, 62.1356`, 63.64047`,
63.82278`, 64.46555`, 64.73798`, 65.43021`, 65.07381`, 69.29517`,
67.67996`, 64.94267`, 69.47933`, 65.05963`, 65.01253`, 65.61963`,
65.94819`, 65.68803`, 65.87689`, 65.91481`, 67.41946`, 66.53833`,
67.41995`, 67.21977`, 67.33721`, 68.11283`, 68.02017`, 68.02829`,
68.35139`, 68.80254`, 69.49307`, 70.2297`, 69.71997`, 70.16651`,
61.07369`, 62.66947`, 64.32254`, 64.27362`, 64.96148`, 64.77222`,
66.2365`, 66.10686`, 66.42772`, 66.22727`, 65.87574`, 67.03017`,
67.48545`, 66.7367`, 66.69181`, 67.31766`, 67.1219`, 67.82592`,
68.4376`, 67.74551`, 68.0934`, 67.71665`, 68.99349`, 69.24616`,
69.2828`, 69.26254`, 68.75605`, 69.62519`, 69.61942`, 69.94715`,
70.58916`, 72.34058`, 71.56142`, 72.94457`, 63.33777`, 64.3445`,
65.14077`, 65.2424`, 65.90397`, 65.98763`, 65.57065`, 65.82733`,
66.88576`, 66.98594`, 67.41537`, 67.93319`, 67.77812`, 68.44999`,
68.32281`, 68.35148`, 68.73678`, 68.97673`, 69.31931`, 68.80442`,
68.90434`, 69.80381`, 69.66712`, 70.38052`, 70.29892`, 71.02634`,
71.28432`, 72.03259`, 63.26539`, 64.87623`, 65.72722`, 66.13831`,
66.48902`, 66.06395`, 66.73532`, 67.12329`, 67.57161`, 68.18286`,
68.33868`, 68.14658`, 69.17022`, 69.17597`, 68.52789`, 68.84874`,
69.69833`, 69.86528`, 70.48646`, 71.16238`, 70.58946`, 70.54353`,
72.38576`, 73.18522`, 64.12344`, 64.62855`, 65.74244`, 67.11563`,
66.81497`, 68.38001`, 68.33835`, 68.25066`, 68.36488`, 68.67873`,
68.70293`, 69.0466`, 70.17375`, 69.86849`, 70.15821`, 70.24204`,
71.41811`, 70.66031`, 72.42614`, 73.04341`, 64.6891`, 67.09928`,
67.79858`, 68.37299`, 69.19364`, 68.5938`, 69.86969`, 70.17952`,
70.51811`, 71.00743`, 71.83086`, 72.81121`, 67.95451`, 67.81317`,
69.32812`, 70.45127`, 71.38916`, 72.31022`, 71.8821`, 64.61601`,
67.75382`, 69.90335`, 70.87039`, 72.71533`, 69.03942`, 72.44463`,
69.07253`, 70.1758`, 72.37219`, 59.63777`, 73.27737`, 68.12621`,
63.15234`, 66.00489`, 71.45303`, 68.1456`, 65.25527`, 70.41584`,
68.38452`, 61.89133`, 64.98391`, 66.21887`, 59.48391`, 62.77645`,
63.86507`, 64.56486`, 65.60265`, 66.28333`, 70.55256`, 62.14539`,
64.37906`, 64.35191`, 64.91304`, 65.33085`, 65.17545`, 66.10285`,
66.05004`, 67.38231`, 67.83999`, 70.27309`, 63.19263`, 63.66834`,
64.12671`, 64.71388`, 65.14662`, 65.94428`, 65.67785`, 65.95134`,
67.30819`, 66.69404`, 66.56885`, 66.80951`, 68.24011`, 67.5344`,
68.4157`, 69.09588`, 70.81036`, 61.68183`, 63.04493`, 64.34945`,
63.89336`, 65.48176`, 64.726`, 64.65128`, 67.47271`, 66.76701`,
64.98147`, 69.38684`, 63.7123`, 64.63358`, 66.00037`, 65.96621`,
66.49751`, 66.27177`, 65.67892`, 66.86814`, 66.73495`, 66.53357`,
67.05051`, 67.04958`, 67.55908`, 67.58076`, 67.51942`, 68.12592`,
68.57465`, 68.52484`, 69.20286`, 69.7551`, 69.91868`, 70.50329`,
62.83528`, 63.24504`, 64.44602`, 64.31819`, 64.73521`, 64.72352`,
65.97741`, 65.63739`, 65.83449`, 65.87064`, 66.61001`, 66.75821`,
66.77012`, 67.21373`, 67.09047`, 66.93359`, 68.03852`, 67.98476`,
68.25046`, 68.26078`, 68.21235`, 68.54029`, 68.50469`, 69.13248`,
69.21981`, 69.34385`, 69.41153`, 70.25056`, 69.68641`, 70.51091`,
71.29598`, 72.20218`, 72.33929`, 62.91628`, 63.93525`, 64.59851`,
65.47401`, 65.864`, 66.30684`, 65.77587`, 66.48386`, 67.31983`,
67.39901`, 67.05939`, 68.45161`, 67.7061`, 68.08389`, 67.58923`,
67.80388`, 69.25919`, 69.05302`, 68.70921`, 69.02788`, 68.94943`,
68.81536`, 69.91801`, 70.45072`, 69.96349`, 69.75787`, 71.38281`,
71.08122`, 72.74936`, 65.26855`, 66.01549`, 65.5142`, 65.62374`,
65.92199`, 67.11129`, 66.89727`, 67.94195`, 67.7274`, 67.54999`,
67.96013`, 68.83038`, 69.43917`, 68.55957`, 69.10638`, 70.4814`,
69.92992`, 70.04238`, 69.56779`, 71.01077`, 70.62603`, 71.46383`,
71.62112`, 73.87758`, 65.00573`, 66.30354`, 65.86743`, 66.86667`,
67.15958`, 68.06904`, 67.57382`, 67.63354`, 69.41356`, 68.87192`,
69.07779`, 69.81177`, 70.01463`, 69.56649`, 70.254`, 70.68296`,
70.87874`, 72.45099`, 73.04359`, 74.40915`, 67.40139`, 66.53122`,
68.04593`, 68.82772`, 69.33069`, 70.34676`, 70.173`, 70.80883`,
70.7029`, 72.35959`, 72.3661`, 67.17534`, 67.84045`, 68.9053`,
70.3752`, 71.18523`, 71.41254`, 71.70673`, 72.60072`, 67.57652`,
68.55814`, 70.95019`, 71.99783`, 75.17469`, 73.07157`, 69.92407`,
65.54323`, 72.56261`, 72.15051`, 63.22006`, 73.2645`, 65.81296`,
67.70657`, 66.99681`, 71.33181`, 71.78314`, 70.73837`, 70.30609`};

In[59]:= GaltonY = {59.77827`, 63.21404`, 63.34242`, 62.79238`,
64.28113`, 64.24221`, 64.08231`, 63.99574`, 64.61338`, 63.97944`,
65.24451`, 65.35102`, 65.67992`, 65.43664`, 65.29391`, 64.79017`,
65.01881`, 65.5464`, 65.08145`, 65.49008`, 65.1352`, 65.51262`,
66.58436`, 66.37842`, 66.14782`, 65.97259`, 65.95887`, 66.45202`,
65.74797`, 65.97164`, 65.90548`, 65.90773`, 66.47103`, 65.75023`,
66.34666`, 66.08577`, 66.28037`, 66.34354`, 66.41711`, 67.22558`,
67.46394`, 66.99362`, 66.76647`, 67.0342`, 66.84316`, 69.2989`,
69.09114`, 61.66358`, 65.7288`, 68.98012`, 67.37397`, 67.17459`,
67.06712`, 67.29446`, 67.62665`, 67.47923`, 66.92162`, 67.58324`,
67.21191`, 66.81629`, 67.24268`, 67.51036`, 67.57026`, 67.17258`,
67.54129`, 67.37113`, 67.59714`, 67.25104`, 66.82533`, 66.72679`,
66.92996`, 67.64847`, 68.04291`, 68.4885`, 68.04777`, 68.34573`,
68.33829`, 68.3138`, 68.18333`, 68.51056`, 68.12014`, 68.31563`,
68.04774`, 68.61273`, 67.9425`, 68.08381`, 68.36754`, 67.85181`,
68.19806`, 68.01897`, 68.23431`, 67.89742`, 68.62409`, 67.97912`,
68.2668`, 67.94192`, 68.62072`, 68.23857`, 68.58554`, 68.06568`,
68.38188`, 67.75943`, 68.59991`, 67.91483`, 67.83861`, 68.77562`,
69.60782`, 69.69143`, 69.41491`, 69.68931`, 69.20775`, 69.45627`,
69.59614`, 69.27994`, 69.52338`, 68.74406`, 69.30987`, 69.22571`,
69.24073`, 69.4912`, 69.11921`, 68.93751`, 69.45774`, 69.27599`,
69.22869`, 68.70547`, 69.34638`, 68.87137`, 69.30262`, 69.1579`,
69.62727`, 69.11014`, 69.09596`, 69.03281`, 69.85677`, 70.06274`,
69.89765`, 70.26185`, 70.52663`, 70.52744`, 69.7865`, 70.36684`,
69.97604`, 69.83308`, 70.69951`, 70.16871`, 70.11632`, 69.95433`,
70.31279`, 69.80903`, 69.96792`, 69.93939`, 69.73486`, 70.08397`,
70.01015`, 70.65025`, 70.01253`, 70.09077`, 71.34319`, 70.81542`,
71.44929`, 71.18676`, 71.66276`, 71.39516`, 70.73612`, 71.2608`,
71.04721`, 71.2592`, 70.89486`, 71.31732`, 71.55712`, 71.17701`,
71.03412`, 71.37275`, 71.64741`, 71.1205`, 70.91756`, 71.66455`,
72.39198`, 71.87928`, 72.34482`, 72.17265`, 72.52078`, 71.98836`,
72.34482`, 72.45347`, 72.26945`, 71.96844`, 72.18169`, 72.7864`,
73.0414`, 72.87858`, 73.17304`, 73.63274`, 72.88245`, 73.18148`,
74.3209`, 74.40727`, 73.76791`, 73.92119`, 73.75503`, 75.56214`,
75.70222`, 77.21338`, 61.28882`, 74.28343`, 70.93102`, 75.34802`,
61.78758`, 64.00009`, 62.4658`, 73.70465`, 66.3495`, 62.20543`,
65.421`, 63.9922`, 62.78458`, 63.52486`, 63.49966`, 62.89658`,
63.72784`, 63.73231`, 64.39579`, 63.70072`, 64.44796`, 64.2795`,
65.18412`, 65.10118`, 65.56277`, 64.94454`, 65.14227`, 65.16843`,
65.58149`, 65.63474`, 64.87191`, 65.4176`, 64.7231`, 65.84559`,
65.77333`, 66.67371`, 66.54726`, 66.43228`, 66.3326`, 66.24935`,
66.39759`, 66.69366`, 66.22114`, 66.43499`, 66.65758`, 65.76873`,
66.20784`, 66.30166`, 65.81894`, 66.34562`, 66.88369`, 66.8162`,
67.36245`, 67.68308`, 67.19885`, 67.26903`, 67.45131`, 68.95907`,
62.013`, 64.10658`, 66.00879`, 65.77796`, 66.94446`, 66.81229`,
67.01431`, 67.43705`, 66.8442`, 67.25391`, 67.52273`, 67.17782`,
67.6068`, 66.8991`, 66.74675`, 67.16928`, 67.23833`, 66.75589`,
66.79828`, 67.488`, 67.1104`, 67.06455`, 66.93899`, 67.54723`,
66.85662`, 67.70971`, 67.88296`, 68.66534`, 68.58164`, 68.44493`,
68.41199`, 68.44665`, 68.38258`, 67.92987`, 68.3033`, 67.97479`,
68.18304`, 68.57984`, 68.56974`, 67.81854`, 67.8796`, 68.22794`,
68.01258`, 67.85023`, 67.80077`, 68.59968`, 68.08671`, 67.87656`,
68.47849`, 68.60006`, 68.07838`, 68.08199`, 67.73211`, 68.4132`,
68.59541`, 68.28458`, 68.06489`, 68.41445`, 69.36998`, 69.00435`,
69.37297`, 68.89496`, 69.37382`, 69.34415`, 68.96686`, 69.59887`,
69.24597`, 69.68301`, 68.90541`, 69.07283`, 69.03297`, 69.18202`,
69.64233`, 68.82818`, 69.24165`, 69.10265`, 68.98512`, 69.31551`,
69.20435`, 68.93765`, 69.36661`, 68.71181`, 68.75662`, 69.35439`,
69.42891`, 69.52003`, 69.2275`, 69.95069`, 69.9199`, 69.98123`,
69.74222`, 69.82326`, 69.90223`, 70.2992`, 69.83745`, 69.94847`,
70.27479`, 70.67752`, 70.38903`, 70.37578`, 70.60668`, 70.16921`,
69.85223`, 70.23353`, 70.28373`, 70.33881`, 69.81443`, 70.54739`,
69.96746`, 69.73702`, 69.8604`, 70.87111`, 71.36657`, 71.1878`,
70.75001`, 70.72998`, 71.32092`, 70.88794`, 70.9085`, 70.87662`,
71.19803`, 71.31925`, 71.22916`, 71.35939`, 71.60205`, 70.97309`,
71.1886`, 71.40319`, 71.39524`, 70.88752`, 71.27449`, 72.10289`,
72.03197`, 71.9969`, 71.72577`, 71.92914`, 72.20518`, 72.29401`,
72.5854`, 72.04673`, 71.80541`, 71.80464`, 73.06559`, 73.44548`,
73.19223`, 73.37471`, 73.22554`, 72.88357`, 72.77826`, 73.26989`,
73.96165`, 74.64342`, 73.92565`, 74.58767`, 74.31029`, 75.10003`,
77.15504`, 60.78204`, 62.36303`, 66.40186`, 58.50708`, 70.00052`,
70.99433`, 64.96417`, 70.47639`, 69.23383`, 64.90184`, 68.7749`,
69.85805`, 62.52373`, 63.28805`, 63.52861`, 62.87456`, 63.91754`,
64.32325`, 64.22405`, 64.59643`, 64.28548`, 63.78835`, 65.66404`,
64.80838`, 65.63528`, 64.74897`, 64.79081`, 65.10988`, 65.55215`,
65.30083`, 65.1426`, 65.09433`, 64.81397`, 65.95058`, 66.37511`,
66.38624`, 66.31904`, 65.80919`, 66.09556`, 66.49077`, 66.32632`,
66.59779`, 66.00909`, 66.45585`, 66.00818`, 66.46605`, 66.37783`,
66.34685`, 66.31558`, 66.62303`, 66.79229`, 67.5336`, 67.15587`,
66.78051`, 67.25544`, 66.79006`, 66.88298`, 68.1121`, 63.61572`,
63.17978`, 65.67211`, 67.23403`, 67.4089`, 67.57913`, 67.20643`,
67.10018`, 66.80557`, 67.09308`, 66.91372`, 66.77528`, 66.97572`,
67.66639`, 67.62089`, 67.66841`, 67.32572`, 67.04153`, 66.96445`,
67.07223`, 67.169`, 67.48077`, 67.67057`, 66.86465`, 67.04437`,
67.72523`, 68.52969`, 67.8741`, 67.84693`, 68.26632`, 68.18364`,
68.55723`, 67.77137`, 67.92976`, 67.72522`, 67.98916`, 68.0679`,
67.772`, 68.11035`, 68.16623`, 68.61054`, 68.2893`, 68.38263`,
68.6212`, 68.27802`, 67.93914`, 67.7105`, 68.351`, 68.14712`,
67.97421`, 68.23682`, 68.05699`, 68.49856`, 68.58894`, 67.74098`,
68.69765`, 68.63531`, 68.37844`, 69.11352`, 69.35385`, 69.5135`,
69.11`, 69.64324`, 69.40655`, 69.18575`, 68.80709`, 69.11679`,
69.02706`, 69.05703`, 69.14581`, 68.7308`, 68.9798`, 68.95303`,
69.1639`, 68.81649`, 68.73746`, 69.00102`, 69.28222`, 69.37676`,
68.90879`, 69.32318`, 69.63872`, 69.43581`, 68.97885`, 69.54252`,
68.73497`, 69.20127`, 70.36167`, 70.10118`, 70.39507`, 70.03877`,
69.76556`, 70.39131`, 70.0372`, 70.25908`, 69.87081`, 70.69845`,
70.25756`, 69.7177`, 70.31993`, 69.95735`, 69.72691`, 70.22698`,
70.02038`, 70.32035`, 70.39947`, 69.78074`, 69.7598`, 70.53827`,
70.03449`, 70.59135`, 71.13378`, 71.15371`, 71.03018`, 70.93936`,
70.78603`, 71.50695`, 71.57023`, 70.83563`, 70.96118`, 71.55428`,
71.08274`, 71.49587`, 71.36997`, 71.49891`, 71.01177`, 71.62784`,
71.36701`, 71.23426`, 70.90129`, 71.53087`, 72.441`, 72.5999`,
71.79167`, 72.00806`, 72.01746`, 72.44981`, 71.92864`, 72.0908`,
72.57398`, 72.53335`, 71.78483`, 72.57594`, 73.06795`, 73.18852`,
73.39371`, 73.3754`, 73.67679`, 72.84789`, 72.99608`, 74.67822`,
73.8507`, 74.35692`, 73.99906`, 73.92525`, 75.67784`, 76.10484`,
78.2476`, 61.89619`, 69.86215`, 62.26801`, 71.40839`, 71.60925`,
65.51351`, 71.86574`, 71.16645`, 64.53321`, 65.25053`, 69.62871`,
65.10223`, 61.03526`, 63.12132`, 63.5968`, 63.47848`, 63.83162`,
64.18388`, 64.66888`, 64.06363`, 64.38072`, 64.60295`, 64.81735`,
65.22864`, 65.62354`, 65.62755`, 64.8584`, 65.6482`, 65.6904`,
65.58218`, 65.08945`, 64.87234`, 65.68794`, 66.54461`, 66.23255`,
65.91034`, 66.29882`, 66.33603`, 66.19024`, 66.12728`, 66.1938`,
65.82389`, 66.61389`, 66.45299`, 66.25633`, 66.53703`, 66.28457`,
65.90354`, 66.61969`, 66.59349`, 67.30641`, 67.41523`, 67.51658`,
66.94071`, 67.11246`, 66.99107`, 66.94124`, 68.06898`, 67.47908`,
63.00731`, 67.40208`, 68.75691`, 66.90827`, 67.28305`, 67.15978`,
67.12405`, 67.07313`, 67.17665`, 66.74724`, 66.81865`, 67.43735`,
67.37322`, 66.96049`, 67.40154`, 66.91834`, 66.93007`, 66.78425`,
66.7842`, 67.15158`, 67.45025`, 67.68985`, 67.13767`, 67.60589`,
67.96334`, 68.65674`, 68.42972`, 68.01111`, 68.61891`, 68.50647`,
67.77439`, 68.09837`, 68.19228`, 68.54918`, 68.59413`, 68.65282`,
68.40294`, 68.54259`, 68.59444`, 67.87885`, 68.0454`, 67.96346`,
68.55092`, 68.07785`, 67.93252`, 68.5916`, 67.90891`, 68.63842`,
68.6514`, 68.40634`, 68.19563`, 68.3391`, 68.13175`, 67.79551`,
68.24471`, 67.96366`, 68.02669`, 68.07695`, 69.23339`, 69.22874`,
68.9062`, 69.33247`, 69.53206`, 69.02418`, 69.26288`, 69.55433`,
69.3664`, 68.96569`, 69.33038`, 69.10425`, 69.29199`, 69.26009`,
68.71424`, 69.48488`, 69.48141`, 68.88311`, 68.83524`, 69.42378`,
68.82387`, 69.06951`, 69.18528`, 69.26989`, 68.83727`, 69.11594`,
69.39569`, 68.70258`, 70.39288`, 70.49606`, 70.11817`, 69.75304`,
70.25238`, 70.28837`, 69.71807`, 70.13835`, 70.41752`, 69.91638`,
69.7803`, 69.90789`, 70.29221`, 70.20136`, 70.42766`, 70.40239`,
70.65713`, 69.7276`, 70.45174`, 70.52536`, 70.45682`, 70.52011`,
70.25621`, 70.32714`, 71.39933`, 71.03487`, 71.61276`, 70.90129`,
71.36831`, 71.46158`, 71.22939`, 71.59368`, 71.6476`, 71.33885`,
71.13133`, 71.52388`, 70.95837`, 71.48199`, 70.85433`, 71.41922`,
71.30872`, 71.22321`, 71.4506`, 70.76122`, 72.65576`, 71.96434`,
72.3071`, 72.2446`, 72.38029`, 72.04211`, 71.77644`, 72.54877`,
72.57381`, 71.90584`, 72.62022`, 72.4218`, 73.13823`, 73.60773`,
73.2649`, 73.0769`, 73.69792`, 73.60551`, 72.87015`, 73.90142`,
74.32431`, 73.87776`, 74.20972`, 74.47833`, 75.07304`, 76.3516`,
78.36479`, 61.22021`, 72.63356`, 64.94291`, 73.02984`, 71.81569`,
65.29123`, 60.90911`, 72.131`, 70.98853`, 61.7019`, 67.51436`,
64.37789`, 63.2825`, 63.47892`, 63.66235`, 63.94637`, 63.93831`,
63.94722`, 64.08187`, 64.68702`, 64.38337`, 63.91132`, 64.84282`,
65.33216`, 65.2375`, 65.47348`, 65.16309`, 65.35727`, 65.59545`,
64.70258`, 64.76966`, 65.55892`, 65.42338`, 66.54624`, 65.70133`,
66.12315`, 66.2678`, 66.55539`, 66.42398`, 66.50633`, 66.27712`,
66.42142`, 66.25827`, 66.1285`, 66.53558`, 66.32575`, 66.11991`,
65.87925`, 65.70978`, 66.10198`, 67.57237`, 67.4361`, 67.00761`,
67.21048`, 67.1921`, 67.39528`, 67.44979`, 68.18883`, 62.74094`,
66.34954`, 65.69966`, 68.36264`, 67.52548`, 67.24632`, 67.21519`,
67.45383`, 66.93472`, 67.6832`, 66.97218`, 66.73049`, 66.75153`,
67.4346`, 66.92896`, 67.49282`, 66.93944`, 67.03135`, 66.91542`,
66.97758`, 67.14932`, 67.53093`, 67.52202`, 67.27928`, 67.56893`,
67.75773`, 68.10565`, 68.49664`, 68.5851`, 67.85579`, 68.60796`,
68.19156`, 68.25828`, 68.15401`, 68.18623`, 68.16064`, 68.6097`,
68.34391`, 68.65678`, 68.51914`, 67.72093`, 67.96986`, 67.75073`,
68.09745`, 68.64602`, 68.2318`, 68.18244`, 68.15011`, 68.13611`,
68.10048`, 68.53037`, 68.37728`, 68.17652`, 67.7452`, 67.93037`,
68.25872`, 68.33639`, 68.27405`, 69.5816`, 68.70027`, 68.93075`,
68.78663`, 69.0649`, 68.99285`, 68.99516`, 68.73929`, 69.47357`,
69.08392`, 69.07281`, 69.62286`, 69.35683`, 69.16149`, 68.81413`,
68.9529`, 69.47561`, 69.5506`, 69.38889`, 69.57241`, 69.37092`,
68.92229`, 68.71081`, 69.2671`, 68.74473`, 68.81509`, 69.47472`,
69.69307`, 69.65334`, 70.46902`, 70.00607`, 70.61711`, 70.51318`,
69.97204`, 69.92313`, 70.46938`, 69.91923`, 69.71908`, 70.61155`,
70.20868`, 70.27586`, 70.18348`, 70.5115`, 70.50015`, 70.24017`,
70.001`, 70.21726`, 70.20554`, 69.97788`, 70.36632`, 70.38931`,
70.18593`, 70.23168`, 70.74197`, 71.47899`, 71.41695`, 71.20207`,
70.87987`, 71.26557`, 71.41653`, 71.24074`, 71.15528`, 71.20588`,
70.98515`, 71.35642`, 71.21331`, 71.59639`, 71.25854`, 71.53325`,
70.92787`, 71.54787`, 71.07293`, 70.86163`, 72.67319`, 71.77245`,
72.64278`, 72.48159`, 71.9078`, 72.18324`, 72.55104`, 72.33861`,
72.07098`, 72.30647`, 72.05185`, 72.75204`, 72.79178`, 73.50606`,
73.68578`, 72.79593`, 73.41049`, 73.02077`, 73.20758`, 74.49237`,
73.81263`, 73.81376`, 73.82642`, 73.81739`, 75.57544`, 77.23474`,
60.05859`, 76.81927`, 66.72684`, 58.79456`, 67.89277`, 61.04946`,
59.81693`, 70.75232`, 68.26774`, 69.30589`, 69.30199`, 67.015`};

In[60]:= lm = LinearModelFit[GaltonDat, {1, x}, x]

Out[60]= FittedModel[\!\(\*
PanelBox[
TagBox[
RowBox[{"33.88660435407788`", " ", "+",
RowBox[{"0.5140930386233082`", " ", "x"}]}],
Short],
FrameMargins->5]\)]

In[62]:= lm["BestFit"]

Out[62]= 33.8866 + 0.514093 x

In[63]:= r2 = Correlation[GaltonX, GaltonY]

Out[63]= 0.501338

Darren Glosemeyer

unread,
Feb 25, 2009, 4:03:18 AM2/25/09
to

The correlation and slope are two different quantities. Correlation
gives a measure of how well one variable could predict the other, while
slope is part of the linear prediction. Note, also that correlation is
bounded by -1 and 1, while slope could be outside that range. If we take
the formulas from simple linear regression, we see that the results are
correct and that correlation and slope will only be equal if the x and y
sums of squares, sxx and syy, are equal.

In[3]:= xbar = Mean[GaltonX];

In[4]:= ybar = Mean[GaltonY];

In[5]:= n = Length[GaltonX];

In[6]:= sxy = GaltonX.GaltonY - n*xbar*ybar

Out[6]= 4171.58

In[7]:= sxx = GaltonX.GaltonX - n*xbar^2

Out[7]= 8114.44

In[8]:= syy = GaltonY.GaltonY - n*ybar^2

Out[8]= 8532.58

In[9]:= cor = sxy/Sqrt[sxx*syy]

Out[9]= 0.501338

In[10]:= slope = sxy/sxx

Out[10]= 0.514093


Darren Glosemeyer
Wolfram Research

Ray Koopman

unread,
Feb 25, 2009, 4:04:33 AM2/25/09
to
The slope of the regression line will equal the correlation
only when the two standard deviations equal one another.

Dimensions[XY = Transpose@{X,Y}]
{1078,2}

f = Fit[XY,{1,x},x]
a = f[[1]]
b = f[[2,1]]

33.8866 + 0.514093 x
33.8866
0.514093

{mx,my} = Mean@XY
{sx,sy} = StandardDeviation@XY
r = Correlation[X,Y]

{67.6871,68.6841}
{2.74487,2.8147}
0.501338

b == r*sy/sx
True

a == my - b*mx
True

Jens-Peer Kuska

unread,
Feb 25, 2009, 4:05:38 AM2/25/09
to
Hi,

can you explain what "using Fit" mean

lm["RSquared"] // Sqrt

gives 0.501338
and this corresponds to the correlation value.

Regards
Jens

Bill Rowe

unread,
Feb 25, 2009, 4:06:10 AM2/25/09
to
On 2/24/09 at 5:48 AM, claus...@gmail.com (Claus) wrote:

>Hi, in the code below, using Correlation I get 0.501338, using Fit I
>get 0.514093. How come?

<snip>

>In[60]:= lm = LinearModelFit[GaltonDat, {1, x}, x]

>In[62]:= lm["BestFit"]

>Out[62]= 33.8866 + 0.514093 x

>In[63]:= r2 = Correlation[GaltonX, GaltonY]

>Out[63]= 0.501338

You seem to expect the slope of the best fit line to have the
same value as the correlation between x and y. These are two
separate things and will never have the same value with real data.

The slope of the best fit line is given by

Covariance[x,y]/Variance[y]

The correlation between x and y (Pearson's correlation) is given by

Covariance[x,y]/Sqrt[ Variance[x] Variance[y] ]

The only case where the slope and correlation have the same
value is the trivial case where x = y and there is no error
term, i.e., perfect correlation with a slope of 1.

dh

unread,
Feb 25, 2009, 4:08:00 AM2/25/09
to

Hi Claus,

you are confusing two different things.

The correlation coefficient is not the slope of the regression line. The

correlation tells you how much the points are "scattered" around the line.

hope this helps, Daniel

DrMajorBob

unread,
Feb 25, 2009, 4:02:34 AM2/25/09
to
You gave us GaltonX (which isn't used in your code) and GaltonY, but not
GaltonDat.

Hence, the following is only a guess as to what you've actually done:

lm=LinearModelFit[Transpose@{GaltonX,GaltonY},{1,x},x]
FittedModel[33.8866+0.514093 x]

lm["BestFit"]
33.8866+0.514093 x

r2=Correlation[GaltonX,GaltonY]
0.501338

Now the question is, why should the two numbers agree? Here's an example
from Help:

data = {{0, 1}, {1, 0}, {3, 2}, {5, 4}};

lm = LinearModelFit[data, x, x];
lm["BestFit"]

0.186441 + 0.694915 x

The corresponding Correlation is

Correlation @@ Transpose@data // N

0.902244

Fit seeks to reproduce Y from X, but Correlation divides covariance by the
two standard deviations:

"Correlation[Subscript[v, 1],Subscript[v, 2]] is equivalent to
Covariance[Subscript[v, 1],Subscript[v,
2]]/(StandardDeviation[Subscript[v, 1]]StandardDeviation[Subscript[v,
2]]). "

That's a measure of how much a certain model explains (without the
constant term, where your model DOES have a constant term), but it IS NOT
a coefficient in the best fit model.

Bobby

--
DrMaj...@longhorns.com

Claus

unread,
Feb 26, 2009, 7:57:33 AM2/26/09
to
Gentlemen,
thanks for your comments, I was writing my original post in a hurry, and
I must have been in a hurry when I was writing the original code.
My problem was that I had calculated the slope of the regression line by
multiplying Correlation[GaltonX,GaltonY] with
StandardDeviation[GaltonX]/StandardDeviation[GaltonY]

However, the correct slope of the regression line is
Correlation[GaltonX,GaltonY] *
StandardDeviation[GaltonY]/StandardDeviation[GaltonX]

Below is some code that should clarify things (use GaltonX and GaltonY
from original post).

Thank you,
Claus


In[98]:= lm = LinearModelFit[Transpose@{GaltonX, GaltonY}, {1, x}, x]
lm["BestFit"]

Out[98]= FittedModel[\!\(\*


PanelBox[
TagBox[
RowBox[{"33.88660435407788`", " ", "+",
RowBox[{"0.5140930386233082`", " ", "x"}]}],
Short],
FrameMargins->5]\)]

Out[99]= 33.8866 + 0.514093 x

should be the same if I use the original pairs

In[100]:= lm2 = LinearModelFit[GaltonDat, {1, x}, x]
lm2["BestFit"]

Out[100]= FittedModel[\!\(\*


PanelBox[
TagBox[
RowBox[{"33.88660435407788`", " ", "+",
RowBox[{"0.5140930386233082`", " ", "x"}]}],
Short],
FrameMargins->5]\)]

Out[101]= 33.8866 + 0.514093 x

In[102]:= CorrelXY = Correlation[GaltonX, GaltonY]

Out[102]= 0.501338

In[103]:= SDevX = StandardDeviation[GaltonX]
SDevY = StandardDeviation[GaltonY]
MY = Mean[GaltonY]
MX = Mean[GaltonX]
CovXY = Covariance[GaltonX, GaltonY]

Out[103]= 2.74487

Out[104]= 2.8147

Out[105]= 68.6841

Out[106]= 67.6871

Out[107]= 3.87333

CorrelXY2 should be the same as CorrelXY

In[108]:= CorrelXY2 = CovXY/(SDevX*SDevY)

Out[108]= 0.501338

Slope of the regression line

In[109]:= slopeRegrL = CorrelXY*SDevY/SDevX

Out[109]= 0.514093

In[110]:= interceptRegrL = MY - slopeRegrL*MX

Out[110]= 33.8866

In[111]:= regrLine = interceptRegrL + slopeRegrL*x

Out[111]= 33.8866 + 0.514093 x

Now this is the same as the result from LinearModelFit

In[112]:= lm["BestFit"]

Out[112]= 33.8866 + 0.514093 x

Sjoerd C. de Vries

unread,
Feb 26, 2009, 7:50:35 AM2/26/09
to
Perhaps you should read an article on correlation (Wikipedia?). It is
NOT the coefficient of a linear fit. The correlation between two
variables can have values between -1 and +1, with 0 indicating no
(linear) relationship between them and 1 perfect linear relationship.
The coefficient of x in the fit is not restricted to this range.
Evidently, there is no reason for them to be equal.

Cheers -- Sjoerd

> 67.70657`, 66.99681`, 71.33181`, 71.78314`, 70.73837`, 70.30609`}=

0 new messages