home *** CD-ROM | disk | FTP | other *** search
/ ftptest.leeds.ac.uk / 2015.02.ftptest.leeds.ac.uk.tar / ftptest.leeds.ac.uk / bionet / maths / anova.asc < prev    next >
Text File  |  1993-12-14  |  23KB  |  300 lines

  1. APNU1030 Data Handling Exercise
  2. Introduction
  3. In this exercise you will work on a quality control/quality assurance exercise using statistical 
  4. analysis.  Read all of this handout carefully before you start work.  The exercise represents a 
  5. full day of work for a professional person.  Allowing for the fact that you may be less familiar 
  6. with the work this exercise may take up to ten hours.  
  7. You may be tempted to avoid the computer and try to do the data processing on paper.  Please 
  8. don't, for your own sake, as you will never get it finished and it will be impossible to avoid data 
  9. entry mistakes on your calculator.  If you make one slip with a decimal point the result will be 
  10. out and you will have to work though all the calculations again.  Check your progress with 
  11. your tutor/demonstrator as you proceed if you wish.
  12. The Scenario
  13. You are supervising a food analysis laboratory.  Your client is a margarine manufacturer and 
  14. their brand of margarine has nutritional information printed on the package.  Your job is to 
  15. take samples from several batches of margarine, measure the amount of unsaturated fat and 
  16. indicate whether this is consistent with the claims on the packaging.  The packaging states 
  17. that the fat component of the product is 53% saturated and 47% monounsaturated.  
  18. You will include some data validation in order to convince your client of the reliability of your 
  19. results.  You have four technicians who are trained to make measurements and you will use 
  20. forty replicate measurements on each of the five batches of margarine.  (The client is very 
  21. determined to get good results.)  There are several questions you must answer.
  22. a)    Are any of your technicians introducing consistently wrong results?
  23. b)    Are the batches significantly different from each other?
  24. c)    If the answer to b is 'no', is the 'global' mean from all batches taken together 
  25. consistent with the manufacturers stated value allowing for your level of 
  26. measurement error?
  27. In order to answer a) and b) you must arrange for each technician to make some measurements 
  28. from each of the batches.  If you assigned a batch to one technician you wouldn't be able to see 
  29. if the different means were due to the margarine being genuinely different in different batches 
  30. or if certain technicians were producing biased results.
  31. So each technician will make ten replicate measurements for each of the five batches of 
  32. margarine.  This means that each technician will make fifty measurements and each batch will 
  33. be tested forty times.  Because you have a lot of data the process would be very time 
  34. consuming if done on paper with a pocket calculator.  You will use a spreadsheet to help you 
  35. come up with fast and reliable results.
  36. Your technicians will provide the data already entered into the spreadsheet and you will have to 
  37. add the formulae for calculating the results.
  38. Obtaining the Data
  39. The technicians will send you the data in an Excel spreadsheet file attached to an electronic 
  40. mail message.  (Put in a request for data by mailing your APNU1030 tutor.)  To get the file 
  41. onto your disc wait for a message from the technicians.  The message will indicate that there is 
  42. an attachment to the message.  Click on the attachments button of the message window.  You 
  43. will be shown a list of files attached to the message.  There will only be one file in the list.  
  44. Click on the filename to select it and use the save button.  Another box pops up which allows 
  45. you to choose which disc to put the file on.  Unfortunately this box is a bit different to what 
  46. you are used to.  Directories and disc drives are listed together in a box marked 'Directories'.  
  47. Scroll until you find your disc drive indicated as, for example, [-a-] and double click on it.  
  48. Now you are on the correct disc drive you can click on the OK button to save the file there.
  49. Calculations
  50. The margarine you are testing contains 98% lipid.  This is manufactured using  an oil with 
  51. three identical monounsaturated acyl groups, which has been partially hydrogenated in order to 
  52. make it solid at room temperature.  The percentage of saturated fat is taken to be 100% if all 
  53. the available double bonds are hydrogenated and 0% if none of the double bonds have been 
  54. hydrogenated.  You may take the molecular weight of the saturated and unsaturated lipids to be 
  55. both approximately 880 gmol-1  (The addition of two hydrogen atoms makes little difference to 
  56. the molecular weight.)  The values supplied by your technicians give the number of double 
  57. bonds in mmol g-1.  The packaging states the percentage of fat which is monounsaturated.
  58. You can analyse the raw data to answer the first two questions but to compare your mean with 
  59. the stated value on the packaging you will either convert your calculated mean to a percentage 
  60. or the stated percentage to millimoles of double bonds per gramme.  
  61. You will have to arrange data from the technicians' spreadsheet in different ways for the 
  62. different calculations so leave that spreadsheet intact and simply copy blocks of data into a 
  63. separate sheet for each calculation.
  64. The Global Mean
  65. It is quite quick to test your 'grand mean' from all the data against the stated value on the 
  66. packaging so you can start with this.  You can go on to look at the data more closely at a later 
  67. stage to test the quality assurance side of the project.  If you are lucky your team will be up to 
  68. scratch and this test of the mean will stand up.  If not, you may have to repeat it!
  69. Testing the Mean
  70. Copy all the data onto a separate new spreadsheet as a block.  It doesn't matter what order it 
  71. goes in as long each datum is pasted in only once.  Give the block of data the name 'data'.  (See 
  72. your course manual.) Use some convenient cells on the spreadsheet to enter formulae that will 
  73. give you the number of datum points, the mean and standard deviation.
  74. =COUNT(data)
  75. =AVERAGE(data)
  76. =STDEV(data)
  77. Name the cells with these results in 'N', 'mean', and 's' respectively.  You will either have to 
  78. convert these figures to percentage saturation using more cells on the spreadsheet or use some 
  79. cells to convert the manufacturer's stated value into mmol g-1.  This will be necessary in order 
  80. to make the comparison.
  81. You now have a mean calculated from a large number of measurements which you can 
  82. compare with the stated value on the margarine's packaging.  How do you do it?  First you 
  83. need to estimate your confidence in the measured mean.  This is the standard error of the mean.  
  84. This standardised measure of the experimental error depends on the spread of the 
  85. measurements but also the number of measurements used to estimate the mean.
  86. Divide your standard deviation by the square root of the number of measurements used to 
  87. estimate the mean.  This is your standard error.  You can see that as you make more 
  88. measurements the standard error decreases and you are therefore more confident about your 
  89. mean value.
  90. Standard error is a measure of the range of likely values for the actual saturated fat content of 
  91. the margarine.  There is an 84% chance (worked out from the normal distribution) that the 
  92. actual value lies within the range of the estimated mean plus or minus the standard error.  If 
  93. you compare your mean value with the expected you can test the hypothesis that the measured 
  94. value is consistent with the expected value.  In other words, what is the probability that your 
  95. measured mean could have resulted from measurements of saturated fat content, with normal 
  96. experimental error, of margarine of the stated saturated fat content.
  97. If the probability is very low then you will have satisfactorily proved that the level in the 
  98. supplied samples is not as stated on the packaging.
  99. Calculate the deviation of your measured mean from the expected (hypothetical) mean (a 
  100. simple subtraction).  You must scale this in terms of the standard error.  Simply divide by the 
  101. standard error.  You now have a measure of how far the expected value is from the 
  102. measured mean scaled according to your confidence in the measurement. A deviation 
  103. between two means (measured or hypothetical) scaled in this way is usually called 't'.  
  104. Now you need to know the probability.
  105. When you look at the deviation of a measurement from a mean the deviation is scaled to 
  106. standard deviation.  When you look at the deviation between two means the deviation is 
  107. scaled to standard error.  In either case it is the normal distribution itself which relates the 
  108. scaled deviation to a probability of reaching such a deviation by chance alone.  However, 
  109. because the normal distribution is described partly by the standard deviation and because this 
  110. is only estimated by your data, if you have small numbers of datum points the distribution is 
  111. adjusted.  That is why the t distribution is used.  The t distribution is an adjusted version of the 
  112. normal distribution for different numbers of data points.  The deviation you calculate is 
  113. referred to as t.
  114. The calculation of p from d is complex to perform on paper and the calculation of p from t is 
  115. more complex because you must involve the number of measurements as well, but the 
  116. spreadsheet program you are using has a simple function for calculating either.  (If you were 
  117. doing this on paper you would probably accept that, with the large amount of data you have, 
  118. you have such a good estimate of standard deviation that a normal distribution would be 
  119. acceptable - the deviation is called d instead of t.)
  120. On a spreadsheet enter a formula like this;
  121. =TDIST( t, count-1, TRUE )
  122. The TRUE in the function makes it perform a two tailed test.  This is needed because you are 
  123. concerned about the measurement being too low as well as too high.  If the probability is less 
  124. than 0.05 you can confidently reject the value stated on the packaging.
  125. Comparing Means
  126. Assume initially that the various batches of margarine are all the same at first.  It is safe to 
  127. look at the four mean values each of your technicians produced (using all the batches) and 
  128. compare them.  Are they consistent with each other?  You may have already met t tests as a 
  129. way of comparing two means.  Analysis of variance is an alternative way of comparing means.  
  130. It allows you to compare two means like a t test but can be extended to compare any number of 
  131. means.  Analysis of variance is also a little easier to understand than the various t tests.
  132. Variation
  133. Variation between individual values in our situation could be due to unavoidable measurement 
  134. error or due to consistent error introduced by the technician (we are ignoring any possible 
  135. variation due to batches being different for the moment.)  So if you take all 240 measurements 
  136. and calculate the variance these two forms of variation will both be contributing to it.  If you 
  137. could separate the two contributions and compare them it will show you if consistent error, due 
  138. to the technician, is real and significant
  139. That is what analysis of variance is about.  You calculate the two variance values which 
  140. contribute to the total variance.  If variation introduced by the technician is significant then you 
  141. will have demonstrated that the different means calculated by different technicians are really at 
  142. odds with each other.  The technique is called one factor analysis of variance because, apart 
  143. from the error in the measurement process you are looking at how one factor (technician bias) 
  144. affects the measured means.
  145. You should remember that variance is calculated as   divided by the degrees of 
  146. freedom (usually N-1).  Because of this division the component variance values are not directly 
  147. additive but the component   values are additive.  For this reason you work with 
  148.   initially and then work out the different variance values.
  149. Sum of Squares of Deviations from the Mean
  150.  
  151. This value, when calculated by hand or pocket calculator, is easier to work out in a different 
  152. way;
  153.      =     
  154. This second method gives an identical result but doesn't require you to work out the mean in 
  155. advance and then subtract each datum from it.  If you use a computer to work out the value 
  156. using a built in function you need not worry about how it is done.  For this reason the first 
  157. formula is used throughout this text as it describes the statistic better, i.e. it shows how much 
  158. your data varies from its own mean.  The square makes sure that each individual deviation is 
  159. positive so low values contribute as much as high values.
  160. Finding   is one step away from the variance (divide by degrees freedom) and two 
  161. steps away from the standard deviation (find square root of variance).
  162. In some text books this value is called 'sums of squares' for short.  Don't be confused by this.
  163.  
  164.  
  165. Comparing Technicians' Means
  166. You need to get four columns of data together on your spreadsheet each containing the sixty 
  167. measurements made by each technician.  There is no need to keep different batches separate for 
  168. this calculation so simply cut and paste to produce four long columns.  Leave a space of ten or 
  169. more rows at the top of the sheet to allow space for the statistical results.
  170. Graphical Method
  171. Before you do the statistical analysis (one factor ANOVA) you can use a graphical method to 
  172. compare technicians. Produce a histogram for each technician's set of data.  This involves 
  173. counting data points that fall in certain ranges and then graphing the frequency totals in a 
  174. column chart.  Fortunately the spreadsheet program you are using has a facility for automating 
  175. this.  What you will have to do though is set up a table of 'bins'.  A bin is a category for 
  176. counting.  It is defined by giving the lowest acceptable value for the bin.  A datum between that 
  177. value and the value for the next bin up will be counted.  A data point equal to the bin level will 
  178. also be counted.
  179. So, to the side of your data set up a column of figures starting with 0 and increasing in 0.2 
  180. steps to beyond the highest measurement you have.  Now, select the column of data for your 
  181. first technician and choose the analysis tools command on the options menu.  You will see that 
  182. the input range box has already been filled in with your data selection.  You must now click on 
  183. the bin range box and enter the range of cells where your column of bin values will be found.  
  184. (In excel dialogue boxes, instead of typing a cell reference you can click on the spreadsheet to 
  185. indicate a region - this speeds things up.)  Then click on the output box and enter the cell where 
  186. you want the results to be placed.  There are three check boxes on the dialogue box  - Pareto 
  187. and Cumulative Percentage should be switched off but the Chart Output option can be 
  188. switched on.  Click on the O.K. button to obtain the results.  You may have to change the title 
  189. of the chart before you save it to disc.
  190. Repeat this for each technician.  You now have a graphical way of comparing data sets; can 
  191. you pick out any set of data as being significantly biased compared to the others?  To really be 
  192. certain you will have to work out the statistics.
  193. Numerical Method
  194. It will be useful to give names to areas of data before you start.  Select all four columns of data 
  195. and use the appropriate command to name this 'data'.  Name each column 'datax', 'datay', 
  196. 'dataz' and 'dataw'.
  197. To start with you want to know the global degrees freedom, mean, sums of squares of deviation 
  198. from the mean and variance.  Use a space to the right of the data to enter formulae for these 
  199. and label them using neighbouring cells.  
  200. =COUNT(data)-1
  201. =AVERAGE(data)
  202. =DEVSQ(data)
  203. For variance you must enter a formula which refers to two cells above and does a division.
  204. Next you must start looking at the separate means.  Above each column enter a formula of the 
  205. type;
  206. =AVERAGE(datax)
  207. Have a look at the means.  They will certainly be each different to the overall mean but is this 
  208. due to the normal error associated with making the measurements or due to the technicians 
  209. introducing consistent error?  This is where the analysis of variance comes in.  Imagine that a 
  210. technician always makes a measurement 2.5 units too high.  The normal error will give 
  211. measurements spread out either side of a mean shifted 2.5 units up instead of either side of the 
  212. real mean.  So if you look at deviation from the technicians own mean you will see the variance 
  213. due only to the normal measurement error without the extra deviation due to the 2.5 unit shift.  
  214. So this is how to calculate the error variance;
  215. In cells above the four data columns calculate individual sums of squares of deviations from 
  216. the individual mean, e.g.;
  217. =DEVSQ(datax)
  218. Somewhere on your spreadsheet add up the four separate values.  You now have the 
  219. contribution to   from measurement error alone.  
  220. You also need to know the contribution due to technician bias.  There is more than one way to 
  221. find this out.  Imagine that each of the measurements a technician made were set to the 
  222. technicians own mean value, i.e. that each technician had made fifty identical measurements.  If 
  223. this were done you would have eliminated variation due to normal error and the variation left 
  224. would be down to the technicians.  You might then repeat the   calculation for this 
  225. block of data.  However there is a simpler way to do it without making up a big table of 
  226. figures.  If you calculate   for the row of four means you can simply multiply by 
  227. sixty to get the full figure.
  228. So calculate
  229. =DEVSQ(  insert  an appropriate reference to the four means here )*60
  230. You now have three values for   You should see that the two contributing values (for 
  231. error and for technician bias) can be added together to make the total   for all the 
  232. data.  So in reality you could choose to work out any two values and find the other by 
  233. subtraction or addition as appropriate.  On the other hand, by calculating all three values you 
  234. have got a way of checking your calculations.
  235. What next?
  236. You must find the variance for error and variance for technician.  To do this you need to divide 
  237. by degrees freedom.  You have to be careful here.  Degrees freedom for the error is ( ??? ) , 
  238. degrees freedom for technician bias is ( ??? ).
  239. Now is the time to compare the two contributory variance values.  Divide error variance by 
  240. technician variance.  This value is called f.  You have to obtain from this the probability that 
  241. variation between technicians' means is due to chance alone.  Do not look up f in a statistics 
  242. table.  Statistical tables are provided only because the necessary calculation is too complex and 
  243. time consuming to perform on paper using a pocket calculator.  You have a computer to help 
  244. you and the spreadsheet program is capable of the doing the proper calculation for you!  The 
  245. function must account for both degrees of freedom so it will take the form;
  246. =FDIST( reference to your f value, reference to error d.f., reference to tech. d.f. )
  247. This gives you p exactly - it is not an estimate.  If the value is low then the null hypothesis (that 
  248. variation between technicians' means is due to chance) is unlikely.  If it is lower than 0.05 then 
  249. you can confidently discount the null hypothesis.  If your value is greater than 0.05 then you 
  250. must assume that without any further evidence to the contrary your technicians are working 
  251. reliably.
  252. If there is a significant discrepancy between the means what can you do to satisfy the client?  
  253. Look at the four means and the histograms you produced.  Can you spot a single technician 
  254. who is at odds with rest?  If you can't, you will have to carry on regardless, but if there is one 
  255. technician who's mean is obviously deviating from the other three you can choose to disregard 
  256. the data from that person.  Repeat the ANOVA using the remaining three technicians' data.  
  257. Are the three means still at odds with each other?  Repeat the test of the mean against the 
  258. stated value on the packaging using an overall mean taken from the three technicians' data.  
  259. Comparing Batches of Margarine
  260. You can use exactly the same technique (one way analysis of variance) to find out if batches of 
  261. margarine have mean values which are significantly different.  Of course you will have to 
  262. arrange the data in columns differently, so start with a fresh spreadsheet, and remember that 
  263. the degrees freedom will be different.  If you have chosen to discount the data of one of your 
  264. technicians you will be using a smaller data set for each batch.
  265. If the batches are significantly different you will have to compare each batch against the value 
  266. on the packaging separately instead of the overall mean.
  267. Routine use of ANOVA
  268. The spreadsheet program you are using has a built in facility for ANOVA.  You have set the 
  269. calculations up manually so that the client could see all the intermediate values but using the 
  270. facility provided you can get instant results.
  271. You must still arrange the data into columns as before, but this time select the entire block and 
  272. choose the Analysis Tools command on the Options menu.  A dialogue box will ask you which 
  273. analysis you wish to use - choose one factor ANOVA.  A second dialogue box will ask you 
  274. questions about your data and how you want the test done.  Use the help button on this box to 
  275. find out what the options do.
  276. Two factor ANOVA
  277. In some studies you may choose to treat the two factors affecting the mean together.  In other 
  278. words look at the technician bias at the same time as batch variation.  There will now be more 
  279. than two contributors to variation in the measurements.  There is measurement error, 
  280. technician bias and batch variation.  In addition there may also be an interactive variation if a 
  281. technician introduces a different bias on different batches!  This seems very unlikely for our 
  282. study but is a distinct possibility in less clear cut studies.  
  283. There is no need to do this type of analysis for your client but you should be aware of the 
  284. possibility of using it in the future.
  285. The Report
  286. You need to word process a report for your client.  Tell them whether the margarine fits in with 
  287. the value stated on the packaging.  If you had to do this with batches of margarine separately 
  288. explain why.  If you had to ignore data from a technician explain why you did this - your data 
  289. set will be smaller than that paid for by the client so your reasoning must be well thought out.  
  290. At all points state the statistical test used and the key statistical results.
  291. Quality Assurance Audit
  292. Your company has a policy for running quality assurance audits.  Your study has been picked 
  293. out for audit.  You must provide all the documents connected with the project, every 
  294. spreadsheet file and a copy of the report, before sending off to the client.  (Using Email may be 
  295. a bit of strain on the computer system with all these files so check with your course tutor about 
  296. this first.)
  297.  
  298.  
  299.  
  300.