JiscMail Logo
Email discussion lists for the UK Education and Research communities

Help for ACB-CLIN-CHEM-GEN Archives


ACB-CLIN-CHEM-GEN Archives

ACB-CLIN-CHEM-GEN Archives


ACB-CLIN-CHEM-GEN@JISCMAIL.AC.UK


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Monospaced Font

LISTSERV Archives

LISTSERV Archives

ACB-CLIN-CHEM-GEN Home

ACB-CLIN-CHEM-GEN Home

ACB-CLIN-CHEM-GEN  February 2010

ACB-CLIN-CHEM-GEN February 2010

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

ANOVA Question

From:

Andy Minett <[log in to unmask]>

Reply-To:

Andy Minett <[log in to unmask]>

Date:

Sun, 21 Feb 2010 12:29:50 +0000

Content-Type:

multipart/mixed

Parts/Attachments:

Parts/Attachments

text/plain (82 lines) , ANOVA Funtion.txt (152 lines)

Whilst this email is intended for the attention of Mr Kallner, I have posted it
here to the mailing list as someone else may also be able to answer my
question.

In recent discussions here on the mailing list, Mr Kallner provided references
to documents hosted on the ACB website. I refer specifically to: "Measurement
Verification in the Clinical Laboratory" (Khatami et al, dated "090605"), in which
reference is made to an excel spreadsheet created my Mr Kallner, and also to
a second document: "Statistical Background Information: Estimating
Imprecision Using ANOVA. Spreadsheet A, version 6.81", also written by Mr
Kallner.

I have read through these documents with interest, and can see the benefit of
using ANOVA as a means of estimating imprecision, across or within
instruments. The "Statistical Background Information" document I found to be
particularly useful.

I quickly put the ANOVA algorithm (as described by Mr Kallner) into computer
code for future use. However, when testing the code I came across an
anomaly which I hope Mr Kallner (or the mailing list) may be able to resolve.

The function code (attached, if anyone is interested) returns identical results
to that of the excel spreadsheet by Mr Kallner, so I assume my interpretation
is somewhat accurate. The problem I am having is when I send groups of pure
Gaussian data to the function sampled from a single population with consistent
mean and variance, the Total SD calculated from ANOVA is approximately 90%
of what it should be. A straight forward standard deviation calculation of the
combined data set (using N-1 df) reveals the SD as it should be.

So my question is, assuming my code is correct (I am open to the fact it may
not be*), does this mean that ANOVA implicitly relies on differences in the
group data sets to calculate an accurate Total Variance?

The results of testing my code are:

--ORIGINAL POPULATION--
mean = 100
SD = 1

--SAMPLE--
N = 25 (5 groups of 5 data points)

---ANOVA---
mean = 100.012
SD = 0.915

---STANDARD---
mean = 100.005
SD = 0.993

Note how the standard calculation for SD (with N-1 df) gives 0.993, whereas
the ANOVA calculation gives 0.915. These results are based on iterating the
calculation 100,000 times. I believe these should be close to identical.

Thank you!

Andy Minett


*one part of the algorithm I am slightly unsure about is in the purification of
the Mean Square Between variance. It is described as "dividing the difference
between MSbetween and MSwithin, by the average number of observations in
the series". How is the average number of observations in the series defined?
Is this the total observations divided by the number of groups?





------ACB discussion List Information--------
This is an open discussion list for the academic and clinical community working in clinical biochemistry.
Please note, archived messages are public and can be viewed via the internet. Views expressed are those of the individual and they are responsible for all message content.
ACB Web Site
http://www.acb.org.uk
Green Laboratories Work
http://www.laboratorymedicine.nhs.uk
List Archives
http://www.jiscmail.ac.uk/lists/ACB-CLIN-CHEM-GEN.html
List Instructions (How to leave etc.)
http://www.jiscmail.ac.uk/


# Code written in AutoIT v3.3.4.0

#include <Array.au3>

;----- from data points -----
Global $a1[6] = ["",2.50,2.50,2.48,2.52,2.53]
Global $a2[6] = ["",2.61,2.62,2.64,2.58,2.60]
Global $a3[6] = ["",2.51,2.53,2.56,2.54,2.52]
Global $a4[6] = ["",2.48,2.49,2.54,2.51,2.51]
Global $a5[6] = ["",2.49,2.51,2.53,2.48,2.52]

Global $a[6] = ["",$a1,$a2,$a3,$a4,$a5]
$a = _ANOVA($a,0)
_ArrayDisplay($a)

;----- from group stats -----
Global $b1[4] = ["",UBound($a1) - 1,_mean($a1),_SD($a1,True)]
Global $b2[4] = ["",UBound($a2) - 1,_mean($a2),_SD($a2,True)]
Global $b3[4] = ["",UBound($a3) - 1,_mean($a3),_SD($a3,True)]
Global $b4[4] = ["",UBound($a4) - 1,_mean($a4),_SD($a4,True)]
Global $b5[4] = ["",UBound($a5) - 1,_mean($a5),_SD($a5,True)]

Global $b[6] = ["",$b1,$b2,$b3,$b4,$b5]
$b = _ANOVA($b,1)
_ArrayDisplay($b)


Func _ANOVA(ByRef $aArray, $iType = 0)
;*************************************************************
; ANOVA : Analysis of Variance
;*************************************************************
; Arrays of data must be passed in a single array.
; Each nested array can be different sizes etc.
;
; e.g. $PassedArray[n] = ["",$aData1,$aData2...]
;
; $iType - 0 :actual data points passed in array
; - 1 :stats passed in array (each array must be ["",n,Mean,SD])

;----- Local Variables -----
Local $iGroup, $aData, $iGlobalMean, $iGlobalN, $iAverageGroupN
Local $iMeanSquareBetweenV, $iMeanSquareWithinV, $iIntermediateV
Local $iSum

;----- Collect Data -----
Local $aGroupData[UBound($aArray)][3] ;[group][n,mean,sd]
$aGroupData[0][0] = UBound($aArray) - 1 ;Total No. of Groups
Switch $iType
Case 0 ;Calculate n,Mean,SD for each group
For $iGroup = 1 to $aGroupData[0][0]
$aData = $aArray[$iGroup]
$aGroupData[$iGroup][0] = UBound($aData) - 1
$aGroupData[$iGroup][1] = _Mean($aData)
$aGroupData[$iGroup][2] = _SD($aData,True)
Next
Case 1 ;Put passed stats into array
For $iGroup = 1 to $aGroupData[0][0]
$aData = $aArray[$iGroup]
$aGroupData[$iGroup][0] = $aData[1]
$aGroupData[$iGroup][1] = $aData[2]
$aGroupData[$iGroup][2] = $aData[3]
Next
EndSwitch

;----- Mean Square Within (Var) -----
$iGlobalN = 0
$iGlobalMean = 0 ;for Mean Square Between
$iAverageGroupN = 0 ;for Intermediate
$iMeanSquareWithinV = 0
For $iGroup = 1 to $aGroupData[0][0]
$iMeanSquareWithinV += ($aGroupData[$iGroup][0] - 1) * ($aGroupData[$iGroup][2] ^ 2)
$iGlobalN += $aGroupData[$iGroup][0]
$iAverageGroupN += $aGroupData[$iGroup][0]
$iGlobalMean += $aGroupData[$iGroup][1]
Next
$iGlobalMean /= $aGroupData[0][0]
$iAverageGroupN /= $aGroupData[0][0]
$iMeanSquareWithinV = $iMeanSquareWithinV / ($iGlobalN - $aGroupData[0][0])

;----- Mean Square Between (Var) -----
$iSum = 0
For $iGroup = 1 to $aGroupData[0][0]
$iSum += $aGroupData[$iGroup][0] * ($aGroupData[$iGroup][1] - $iGlobalMean) ^ 2
Next
$iMeanSquareBetweenV = $iSum / ($aGroupData[0][0] - 1)

;----- Intermediate Variance (Var) -----
$iIntermediateV = ($iMeanSquareBetweenV - $iMeanSquareWithinV) / $iAverageGroupN
If $iIntermediateV < 0 Then $iIntermediateV = 0

;----- Total Variance (Var) -----
$iTotalVarianceV = $iMeanSquareWithinV + $iIntermediateV

;----- Return Data -----
Local $aReturn[8]
$aReturn[1] = $iGlobalN ;Total Observations
$aReturn[2] = $iGlobalMean ;Global Mean
$aReturn[3] = $iMeanSquareWithinV ^ 0.5 ;MSwithin (Repeatability) (SD)
$aReturn[4] = $iMeanSquareBetweenV ^ 0.5 ;MSbetween (SD)
$aReturn[5] = $iIntermediateV ^ 0.5 ;Intermediate Imprecision (SD)
$aReturn[6] = $iTotalVarianceV ^ 0.5 ;Total Imprecision (SD)
$aReturn[7] = ($aReturn[6] / $iGlobalMean) * 100;Total Imprecison (CV)

Return $aReturn

EndFunc



;**********************************************
; SD, Mean, Sum
;**********************************************
Func _SD(ByRef $aArr, $bSample = False, $iRound = -1)
;$bSample - if the data set represents a sampling of a population
;set this to true to reduce df to N - 1
Local $iU = _Mean($aArr), $iN = (UBound($aArr) - 1), $iE, $i
For $i = 1 to $iN
$iE += ($aArr[$i] - $iU) ^ 2
Next
If $bSample Then $iN -= 1
$iRet = Sqrt($iE / $iN)
If $iRound <> -1 Then $iRet = Round($iRet,$iRound)
Return $iRet
EndFunc
Func _Mean(ByRef $aArr, $iRound = -1)
$iRet = _Sum($aArr) / (UBound($aArr) - 1)
If $iRound <> -1 Then $iRet = Round($iRet,$iRound)
Return $iRet
EndFunc
Func _Sum(ByRef $aArr)
Local $iE, $i
For $i = 1 to (UBound($aArr) - 1)
$iE += $aArr[$i]
Next
Return $iE
EndFunc



------ACB discussion List Information--------
This is an open discussion list for the academic and clinical community working in clinical biochemistry.
Please note, archived messages are public and can be viewed via the internet. Views expressed are those of the individual and they are responsible for all message content.
ACB Web Site
http://www.acb.org.uk
Green Laboratories Work
http://www.laboratorymedicine.nhs.uk
List Archives
http://www.jiscmail.ac.uk/lists/ACB-CLIN-CHEM-GEN.html
List Instructions (How to leave etc.)
http://www.jiscmail.ac.uk/

Top of Message | Previous Page | Permalink

JiscMail Tools


RSS Feeds and Sharing


Advanced Options


Archives

April 2024
March 2024
February 2024
January 2024
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
2006
2005
2004
2003
2002
2001
2000
1999
1998


JiscMail is a Jisc service.

View our service policies at https://www.jiscmail.ac.uk/policyandsecurity/ and Jisc's privacy policy at https://www.jisc.ac.uk/website/privacy-notice

For help and support help@jisc.ac.uk

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager