LINEST i Excel The Excel spreadsheet fuctio "liest" is a complete liear least squares curve fittig routie that produces ucertaity estimates for the fit values. There are two ways to access the "liest" fuctioality; through the fuctio directly ad through the "aalysis tools" set of macros. These istructios cover usig "liest" as a spreadsheet fuctio. Usig liest i your spreadsheets is very easy, after you master the cocept of a array fuctio. Array fuctios are fuctios that while etered ito a sigle spreadsheet cell produce results that fill several cells. The steps outlied below take you set-by-step through the process of liear curve fittig. Step 1. Type i your data i two colums, oe for the x variables ad oe for the y. You ca use ay labels you would like. "x" ad "y" are used i the example at right for coveiece. Step 2. Select the area that will hold the output of the array formula. For "liest" you should drag to form a 5 row by 2 colum data array. Step 3. Click i the formula bar at the top of the scree. Now press the fuctio wizard butto. This butto is i the formula bar ad is labeled "fx". A two-part scroll box will appear; i the left scroll box click o "Statistical" ad i the right click o "LINEST". Next click o "Next>." The widow show below will appear. O your spreadsheet select the cells cotaiig the y values by
draggig i the origial spreadsheet usig the mouse. Click i the "kow_x's" dialog box, ad select the cells cotaig the x values. Type i "TRUE" i the last two dialog boxes. The first TRUE idicates that you wish the lie to be i the form y=mx+b with a o-zero itercept. The secod TRUE specifies that you wish the error estimates to be listed. The Fuctio Wizard dialog box should the appear as below. Step 4. Click o "Fiish." The formula bar should the appear as below, although your y ad x cell rages may be differet, of course. If the values are icorrect, you ca edit them as you would ormally. Step 5. Now here is the importat step. LINEST is a array fuctio, which meas that whe you eter the formula i oe cell, multiple cells will be used for the output of the fuctio. To specify that LINEST is a array fuctio do the followig. Highlight the etire formula, icludig the "=" sig, as show above. O the Macitosh, ext, hold dow the apple key ad press "retur." O the PC hold dow the Ctrl ad Shift keys ad press Eter. Excel adds "{ }" brackets aroud the formula, to show that it is a array. Note that you caot type i the "{ }" characters yourself; if you do Excel will treat the cell cotets as characters ad ot a formula. Highlightig the full formula ad typig the apple key or Ctrl + Shift ad "retur" is the oly way to eter a array formula. The least squares results should be prited as show below. The labels i the first ad last colum are't provided by the LINEST fuctio. We've added them to show the meaig of each cell. For example, the slope is 2.629±0.085 ad the itercept is -3.33 ± 0.41.
x y 2 2.3 3 4.5 4 6.7 5 9.8 6 12.3 7 15.4 slope 2.62857143-3.3285714 itercept ± 0.084997 0.40910554 ± r 2 0.995835 0.35556796 s(y) F 956.384181 4 degrees of freedom regressio ss 120.914286 0.50571429 residual ss Step 6: You should ow evaluate the model that you have built. The r 2 value is ofte used for this purpose, but it is oly a rough idicator of the goodess of fit. The r 2 value is calculated from the total sum of squares, which is the sum of the squared deviatios of the origial data from the mea: total ss = (yi -yav) 2 ) ad the regressio sum of squares, which is the sum of the squared deviatios of the fit values from the mea: regressio ss = (y^i -y av ) 2 Givig: r 2 = regressio ss total ss = (y^ -y av ) 2 ( y i -y av ) 2 Values close to oe are good. The ucertaities i the slope ad itercept are much better for judgig the quality of the fit. I the example the ucertaity i the slope is 0.085/2.629*100 = 3% ad the ucertaity i the itercept is 12%, which is oly about two sigificat figures i each. The ucertaities i the slope ad itercept are ot as good as the r 2 of 0.996 might have idicated! A eve better statistical test of the goodess of fit is to use the Fisher F-statistic. The F-statistic is the ratio of the variace i the data explaied by the liear model divided by the variace uexplaied by the model. The F-statistic is calculated from the regressio sum of squares ad the residual sum of squares. The residual sum of squares is the sum of the squared residuals: residual ss = (y i -y^i) 2 = r 2 i Dividig by the degrees of freedom, gives the variace of the y values
r 2 i s 2 y = 2 The regressio sum of squares, the residual sum of squares, ad the stadard deviatio of the y values, s(y) are all listed i the liest output. The F-statistic is the the ratio of the variaces: F= variace explaied variace uexplaied = regressio ss/v ( (y^i -y av ) 2 ) 1 /v1 residual ss/v = 2 ( (y i -y^i) 2 ) /v2 You use the F-statistic uder the ull hypothesis that the data is a radom scatter of poits with zero slope. Critical values of the F statistic are listed i stadard statistics texts, the CRC Hadbook, ad Quatitative Aalysis texts. If the F-statistic is greater tha the F-critical value, the ull hypothesis fails ad the liear model is sigificat. For the degrees of freedom, which are abbreviated i most tables as v 1 ad v 2,usev 1 =1adv 2 =-k,wherekis the umber of variables i the regressio aalysis icludig the itercept ad is the umber of data poits. The value for v 2 is listed as the degrees of freedom i the liest output. A small part of the F-table is show at right for a α value of 0.05, that is, 95% cofidece. For the example above, v 1 =1adv 2 =6 2=4.The F-critical value is 7.71. The F-statistic for our example is 956.38, which is much greater tha the F-critical value. You are 95% sure that your data is ot a radom scatter of poits ad that the regressio is justified. F-critical values at α=0.05 v 2 F(v 1 =1) 1 161.5 2 18.51 3 10.13 4 7.71 5 6.61 6 5.99 7 5.59 8 5.32 Step 7. You will ow eed to calculate the fit y values, y^ i, which are the values that lie o the lie at the give x values. You ca use the TREND array fuctio for this, but it is just as easy to simply calculate the fit y values directly. Start a ew colum ext to the y values. I this ew colum eter the formula that gives y^ i =mx i + b, with the slope ad itercept from the LINEST output:
Step 8. You ca ow use the "Chart Wizard" to help graph the results: first select the three colums i your spreadsheet. Iclude the colum labels. Click o the Chart Wizard ico: The cursor will chage shape idicatig that you are to drag o your spreadsheet where you wat the plot to appear. Remember for lab reports that charts should be at least half a page. The Wizard will the take you through settig up your graph. Do a scatter graph, ad choose the format that has plot symbols, but ot coectig lies. Step 9. You ow eed to replace the plottig symbols for the fit y values poits with coectig lies. Double click o oe of the fit y value data poits. The "Format Data Series" dialog box will appear. Chage the default settigs to o plot symbol (marker) ad coectig lies as show below: The plot should ow appear as at right. Charts ad spreadsheet cells ca easily be copied ad pasted ito Word documets. 16 14 12 10 8 6 LINEST Tutorial Plot y fit y 4 2 0 0 2 4 6 8 x (uits?)
Addig Error Bars to Plots After you have your graph displayed you ca easily add error bars. Double click o oe of the plottig symbols for your data. The dialog box show below will appear. Click o the "Y Error Bars" tab. Click o the "Both" ico. Next click o the "Custom" butto. Next click i the "+" box ad the select the cell i your spreadsheet that cotais the s(y) value. Repeat this last step i the "-" box. Click o "OK" ad the error bars should appear o your plot. The fial chart, i all its glory looks like this: 16 LINEST Tutorial Plot 14 12 10 8 6 y fit y 4 2 0 0 2 4 6 8 x (uits?)