Docsity

SAS Macro to detect nd evaluate, Publikacje z Języki programowania

Toggle sidebar
bg1
Paper SP13
SAS MACROS TO DETECT AND EVALUATE STATISTICAL
OUTLIERS
Marek K. Solak, Schering-Plough Research Institute, Kenilworth, NJ
Monisha Dey, Schering-Plough Research Institute, Kenilworth, NJ
ABSTRACT
SAS ® macros are designed to apply Grubbs, Ferguson and Hofer-Rickard methods to evaluate
statistical outliers. All methods are applied to the same sample and results are compared.
I. INTRODUCTION
This paper describes SAS macros designed for several methods (Grubbs, Ferguson and Hofer-
Rickard), evaluating observed analytical results that are different from those expected. Such results may be
accurate measurements of the entity being measured and are termed atypical results (outliers). Sometimes,
assignable causes for the atypical result cannot be found (e. g. calculation, instrumentation or analyst error).
The 1998 FDA Draft Guidance for Industry “Investigating Out of Specification (OOS) Test results
for Pharmaceutical Production” [Hofer-Rickard] states that outlier testing may be performed as a part of the
investigation to determine, whether it is likely that an atypical result is due to an analytical mistake.
♦ Outlier tests should be performed, only when the assumption of homogeneity can be made
(assay)
♦ Outlier testing should not be used for tests such as those for dose uniformity and dissolution.
II. METHODS AND PURPOSE
Three outlier evaluation method macros are discussed:
♦ Grubbs
♦ Ferguson
♦ Hofer-Rickard.
These macros may be a useful tool in evaluation of test or experimental results, having values
unexpectedly lower or higher than the rest of results.
A brief discussion of these methods is provided below. All of these methods assume normal
distribution of measurements. A number of methods can be used for a quick evaluation of distribution
normalcy, like -2 =< standard s kewness =< 2 and -2 < standard kurtosis < 2.
Grubbs method
Grubbs [1,2] outlier approach assumes that all observations in a sample have normal distribution.
In practical cases all the observations may be subject to the same standard error, while it may happen that
the largest or smallest observations result from shifts in level. For instance, if one observation appears
unusually high compared to the others in the sample, we may want to consider hypothesis that all
observations com e from a normal parent with mean µ and standard deviation s, N(µ,s), against the
alternative hypothesis that the largest observation comes from a normal population with mean µ+?s,
? > 0, and standard deviation s, while the remaining observations are from N(µ,s). Another case may
involve the situation, where the largest or smallest observations may be from N(µ,?s), ? > 0, while the
remaining observations are from the normal parent N(µ,s).
Grubbs proposes the following statistics to test significance of the largest observation in a sample
size n from a normal population:
n-1 _ n _
S2n/S2 = sum(x
i - xn)2/ sum (x
i - x)2 where x
1=< x2 =< … =< x
n, (1 )
i=1 i=1
pf3
pf4
pf5
pf8

Podgląd częściowego tekstu

Pobierz SAS Macro to detect nd evaluate i więcej Publikacje w PDF z Języki programowania tylko na Docsity!

Paper SP

SAS MACROS TO DETECT AND EVALUATE STATISTICAL

OUTLIERS

Marek K. Solak, Schering-Plough Research Institute, Kenilworth, NJ

Monisha Dey, Schering-Plough Research Institute, Kenilworth, NJ

ABSTRACT

SAS ® macros are designed to apply Grubbs, Ferguson and Hofer-Rickard methods to evaluate statistical outliers. All methods are applied to the same sample and results are compared. I. INTRODUCTION This paper describes SAS macros designed for several methods (Grubbs, Ferguson and Hofer- Rickard), evaluating observed analytical results that are different from those expected. Such results may be accurate measurements of the entity being measured and are termed atypical results (outliers). Sometimes, assignable causes for the atypical result cannot be found (e. g. calculation, instrumentation or analyst error). The 1998 FDA Draft Guidance for Industry “Investigating Out of Specification (OOS) Test results for Pharmaceutical Production” [Hofer-Rickard] states that outlier testing may be performed as a part of the investigation to determine, whether it is likely that an atypical result is due to an analytical mistake.

♦ Outlier tests should be performed, only when the assumption of homogeneity can be made

(assay)

♦ Outlier testing should not be used for tests such as those for dose uniformity and dissolution.

II. METHODS AND PURPOSE

Three outlier evaluation method macros are discussed:

♦ Grubbs

♦ Ferguson

♦ Hofer-Rickard.

These macros may be a useful tool in evaluation of test or experimental results, having values unexpectedly lower or higher than the rest of results. A brief discussion of these methods is provided below. All of these methods assume normal distribution of measurements. A number of methods can be used for a quick evaluation of distribution normalcy, like - 2 =< standard s kewness =< 2 and - 2 < standard kurtosis < 2. Grubbs method Grubbs [1,2] outlier approach assumes that all observations in a sample have normal distribution. In practical cases all the observations may be subject to the same standard error, while it may happen that the largest or smallest observations result from shifts in level. For instance, if one observation appears unusually high compared to the others in the sample, we may want to consider hypothesis that all observations com e from a normal parent with mean μ and standard deviation s, N(μ,s), against the alternative hypothesis that the largest observation comes from a normal population with mean μ+?s, ? > 0, and standard deviation s, while the remaining observations are from N(μ,s). Another case may involve the situation, where the largest or smallest observations may be from N(μ,?s),? > 0, while the remaining observations are from the normal parent N(μ,s). Grubbs proposes the following statistics to test significance of the largest observation in a sample size n from a normal population: n- 1 _ n _

S^2 n/S^2 = sum(xi - xn)^2 / sum (xi - x)^2 where x 1 =< x 2 =< … =< xn, (1 )

i=1 i=

_ n- 1 _ n xn = 1/(n-1) sum(xi), x = (1/n)sum(xi) i=1 i= A similar statistics, S^21 /S^2 , can be used for testing whether the smallest observation is too low. For testing whether the two largest observations are too large, the statistics n- 2 _ n _ S^2 n-1,n/S^2 = sum(xi - xn-1,n)^2 / sum (xi – x)^2 (2) i=1 i= _ n- 2 xn-1,n = 1/(n-2) sum(xi) i= and a similar statistics, S^2 1,2/S^2 , can be used to test significance of the two smallest observations. Grubbs test applicability is limited by the calculated critical values in the paper itself, but is very suitable for small sample sizes (3-25 for statistics (1) and 4-20 for statistics (2)). The method allows evaluation simultaneously of two possible outliers in one method run. In case of larger samples, a suspected outlying observation(s) can be tested against a subset of a sample. Fergusson method F.E. Grubbs provides in [2] several methods to deal with sample outliers. One of them is a method published by Ferguson, cf. references in [2], based on sample skewness and kurtosis coefficients. Application of skewness coefficient is suggested for "one sided" tests and kurtosis is recommended for "two sided" tests. If skewness or kurtosis or both exceed significance levels, [2] then the observation farthest from the mean is rejected and the same procedure is repeated until no further samples are judged as outliers. The macro applies either skewness or kurtosis or both. Hofer-Rickard method Hofer and Rickard [3] conducted a simulation study, to determine sample sizes necessary to achieve a pre specified level of confidence of detection that the suspect result in question is a statistical outlier. Assume that a suspected outlying observation, I (initial), is detected. Hofer-Rickard method finds a number of additional observations required to classify I (outlier – yes or no). Next, the corresponding extreme studentized deviate (ESD) statistics value, with two-sided type I error either of 2% or 5% confidence, is calculated and compared with critical values, tabulated by Hofer-Rickard. Hofer-Rickard method requires estimate of the additional results standard deviation, S, and mean M. The degree of freedom associated with such an estimate is typically N-1, where N is the number of independent observations used to compute estimate. It is highly recommended, that both S and M are based on prior independent data. The normalized estimated distance of the initial result from the true mean, D, can be calculated as D = |M – I|/S (3) Based on values of D and the number of observations used to calculate S and M Rickard-Hofer tables allow finding the number of additional tests to be performed, with two-sided type I error either of 2% or 5% confidence. Two cases are considered: ♦ Prior to I sample data available (prior data sample deviation, SDprior^ , can be calculated or is known) ♦ No prior to I data available.

Hofer-Rickard macro %macro Hofer_Rickard(dsn_pre=, /* Input data set with (prior) to outlier observations / dsn_post=, / Input data set with (post) to outlier observations / /****** Should contain the suspected value ******/ var=, / Variable tested (assay) / int_out=, / Value of suspected outlier / exp_mean=, / Expected mean - if nonmissing, othervise calculated / exp_sd=, / Expected std - if nonmissing, otherwise calculated / select_pre=, / Selection of observations prior to (and excluding) an outlier / select_post=, / Selection of observations post (and excluding) an outlier / xls_smpl=, / Excel with prior sample size / xls_crit=, / Excel with H-R critical values / cnfdnce=, / Confidence level (2% or 5%) / err_rate=, / Error rate (2% or 5%) / out_dsn=, / Output data set / prt_obs=, / Request to print observations used, if nonmissing / add_obs_only=); / Prints the number of additional observations required only */

IV. APPLICATIONS

The following dataset is used (54 observations): { 100.1 99.2 100.2 100.3 100.5 9 8.4 99.6 99.5 98.4 97.3 97.9 99 100 99.8 99.2 97.6 9 9.2 99.5 99.7 99.3 97 99.3 99.4 98. 97.7 9 8.2 99 99.4 98.9 98.9 98.5 99.2 100.3 99.5 95.1 99. 98.9 99.2 97.8 97.8 97.1 98.6 99.1 98.4 97.9 98.7 98 .3 99. 98.2 98.2 98.4 97 94.8 94.8 } Suspected outliers: 94.8, 94.8. Grubbs test – simultaneous check on 2 and 1 possible outliers. The sample presented above is ordered from the smallest values to the largest, and then Grubbs macros are applied. For instance sample size 2 5 contains {94.8, 94.8, 95.1, 97, 97, 97.1, 97.3, 97.6, 97.7, 97.8, 97.8, 97.9, 97.9, 98.2, 98.2, 98.2, 98.2, 98.3, 98.4, 98.4, 98.4, 98.4, 98.5, 98.6, 98.7 }. Table 1. Grubbs tests for two consecutive suspect results. Outlier status Sample size Average Grubbs statistics 1 % 2. 5 % 5 % 10 % Not (an) outlier(s) 4 95.425 0.536006 0 0.0002 0.0008 0. Not (an) outlier(s) 5 95.74 0.449676 0.0035 0.009 0.0183 0. Not (an) outlier(s) 6 95.96667 0.40764 0.0186 0.0349 0.0565 0. Not (an) outlier(s) 7 96.15714 0.387305 0.044 0.0708 0.102 0. Not (an) outlier(s) 8 96.3375 0.384324 0.075 0.1101 0.1478 0.1 994 Not (an) outlier(s) 9 96.48889 0.383071 0.1082 0.1492 0.1909 0. Not (an) outlier(s) 10 96.62 0.383671 0.1415 0.1865 0.2305 0. Not (an) outlier(s) 11 96.72727 0.382417 0.1736 0.2212 0.2666 0. Not (an) outlier(s) 12 96.825 0.383461 0.2044 0.2536 0.2996 0.

Table 2. Grubbs tests for the first suspect result (the next is not removed).

Outlier status Sample size Average Grubbs statistics Table 3. Grubbs tests for one suspect result (the other is removed). Outlier status Sample size Average Grubbs statistics

  • 5%-10% outlier(s) 13 96.90769 0.383405 0.2333 0.2836 0.3295 0.
  • 5%-10% outlier(s) 14 97 0.392178 0.2605 0.3112 0.3568 0.
  • 5%-10% outlier(s) 15 97.08 0.397897 0.2859 0.3367 0.3818 0.
  • 2.5-5% outlier(s) 16 97.15 0.40176 0.3 098 0.3603 0.4048 0.
  • 2.5-5% outlier(s) 17 97.21176 0.404439 0.3321 0.3822 0.4259 0.
  • 2.5-5% outlier(s) 18 97.27222 0.408683 0.353 0.4025 0.4455 0.
  • 1%-2.5% outlier(s) 19 97.33158 0.414344 0.3725 0.4214 0.4636 0.
  • 1%-2.5% outlier(s) 20 97.3 85 0.418708 0.3909 0.4391 0.4804 0.
  • Not (an) outlier(s) 3 94.9 0.75 0.0001 0.0007 0.0027 0. 1% 2.5% 5% 10%
  • Not (an) outlier(s) 4 95.425 0.845335 0.01 0.0248 0.0494 0.
  • Not (an) outlier(s) 5 95.74 0.793629 0.0442 0.0808 0.127 0.
  • Not (an) outlier(s) 6 95.96667 0.763056 0.0928 0.1453 0.2032 0.
  • Not (an) outlier(s) 7 96.15714 0.74471 0.1447 0.2066 0.2696 0.
  • Not (an) outlier(s) 8 96.3375 0.736139 0.1948 0.2616 0.3261 0.
  • Not (an) outlier(s) 9 96.48889 0.730093 0.2411 0.3101 0.3742 0.
  • Not (an) outlier(s) 10 96.62 0.726076 0.2831 0.3526 0.4154 0.
  • Not (an) outlier(s) 11 96.72727 0.722088 0.321 1 0.3901 0.4511 0.
  • Not (an) outlier(s) 12 96.825 0.719755 0.3554 0.4232 0.4822 0.
  • Not (an) outlier(s) 13 96.90769 0.717394 0.3864 0.4528 0.5097 0.
  • Not (an) outlier(s) 14 97 0.719467 0.4145 0.4792 0.534 0.
  • Not (an) outlier(s) 15 97.08 0. 720452 0.4401 0.503 0.5559 0.
  • Not (an) outlier(s) 16 97.15 0.720821 0.4634 0.5246 0.5755 0.
  • Not (an) outlier(s) 17 97.21176 0.720831 0.4848 0.5442 0.5933 0.
  • Not (an) outlier(s) 18 97.27222 0.721733 0.5044 0.5621 0.6095 0.
  • Not (an) outlier(s) 19 97.33158 0.72344 0.5225 0.5785 0.6243 0.
  • Not (an) outlier(s) 20 97.385 0.724651 0.5393 0.5937 0.6379 0.
  • Not (an) outlier(s) 21 97.43333 0.725515 0.5548 0.6076 0.6504 0.
  • Not (an) outlier(s) 22 97.47727 0.726131 0.5692 0.6206 0.6621 0.
  • Not (an) outlier(s) 23 97.52174 0.727487 0.5827 0.6327 0.6728 0.
  • Not (an) outlier(s) 24 97.56667 0.729551 0.5953 0.6439 0.6829 0.
  • Not (an) outlier(s) 25 97.612 0.732279 0.6071 0.6544 0.6923 0.
  • Not (an) outlier(s) 3 95.63333 0.634075 0.0001 0.0007 0.0027 0. 1% 2.5% 5% 10%
  • Not (an) outlier(s) 4 95.975 0.566608 0.01 0.0248 0.0494 0.
  • Not (an) outlier(s) 5 9 6.2 0.534221 0.0442 0.0808 0.127 0.
  • Not (an) outlier(s) 6 96.38333 0.520074 0.0928 0.1453 0.2032 0.
  • Not (an) outlier(s) 7 96.55714 0.522081 0.1447 0.2066 0.2696 0.
  • Not (an) outlier(s) 8 96.7 0.524687 0.1948 0.2616 0.3261 0.
  • Not (an) outlier(s) 9 96.82222 0.528417 0.2411 0.3101 0.3742 0.
  • Not (an) outlier(s) 10 96.92 0.529599 0.2831 0.3526 0.4154 0.
  • Not (an) outlier(s) 11 97.00909 0.532766 0.3211 0.3901 0.4511 0.

Table 7. Ferguson tests for a single suspect results - 5% significance level. Outlier status Sample size Average Skewness Kurtosis Ferguson critical kurtosis NO 5 96.2 - 0.4304 1.225441 2. NO 10 96.92 - 1.21987 2.926098 3. YES 15 97.30667 - 1.54613 4.248557 4. YES 20 97.565 - 1.76521 5.294844 4. YES 25 97.776 - 1.81655 5.916916 4. YES 50 98.588 - 1.41616 5.644343 3. Hofer-Rickard macro – one suspect result Macro output: Hofer-Rickard outlier test - additional observations applied - including suspect result (=3) D statistics value = 8. Initial ESD outlier Hofer-Rickard Confidence Type I Outlier observation test value critical value level error rate status

  • suspect result (Y/N) 94.8 5. 64 3. 6 >=95% 2 % YES 94.8 5.09 2.9 >=95% 5% YES Measurement Observation status Obs ___________ __________________ 1 94.8 Suspect result 2 97.0 Retest data 3 97.0 Retest data 4 99.1 Prior mean and SD available NOTE: Average of observations 5 98.4 Prior mean and SD available 1 - 8 is 97. 6 97.9 Prior mean and SD available 7 98.7 Prior mean and SD available 8 98.3 Prior mean and SD available Hofer-Rickard outlier test - additional observations required (=2). TESTCODE RECOVERY Dixon macro The developed results are confirmed by application of Dixon test [4]. Dixon method can be easily programmed and is one of the most frequently used testing tools: % dixon (lib=, /* library, or source folder / dsn=, / dataset with tested sample / crit=, / confidence level, like 80%, 90%, 95% and 99% / varx=, / tested variable */);

Table 8. Dixon test results – 95% confidence. Sample size All 25 observations included - 94.8 is The first observation (94.8) excluded - second 94.8 is Two first observations (94.8) excluded, 95.1 is 3 - 10 Not an outlier Not an outlier An outlier 11 - 25 Not an outlier An outlier An outlier

V. CONCLUSION AND DISCUSSION

The paper discusses SAS macros to evaluate test and/or experiment suspect measurements. Three methods are used to develop three different macros (Grubbs, Ferguson and Hofer-Rickard). Sample average values are essential compared to outlier value. Grubbs – simultaneous evaluation of both suspect results - (2.5%-10%) outliers (average range 96.91 – 97.27). If one suspect result is evaluated against the rest of the sample (the other is removed) – the average range is 97.08 – 97.47. If only one is evaluated, but the other stays in the sample, no outlier is detected. Ferguson method with 5% significance – both suspect results – average is 97.61, in case of only one suspect result (the other is removed), average is 97.30. Hofer-Rickard provided average 97.65 – only one suspect result is considered. The results are confirmed by application of the Dixon test, [4].

VI. REFERENCES

[1] Frank E. Grubbs, Sample Criteria for Testing Outlying Observations, Annals of Mathematical Statistics, vol. 21, 1950, pp. 27- 58 [2] Frank E. Grubbs, Procedures of Detecting Outlying Observations in Samples, Technometrics, vol. 11, No. 1, 1969, pp 1- 21 [3] Jeffrey D. Hofer, Eugene C. Rickard, A Guide to Determining Sample Sizes and Outlier Criteria in Analytical Investigations, Pharmaceutical Technology, March 2001, pp. 52- 66 [4] D. R. Rorabacher, “Statistical Treatment for Rejection of Deviant Values: Critical Values of Dixon’s “Q” Parameter and related Subrange Ratios at the 95% Confidence Level”, Analytical Chemistry, vol. 63, No.2, January 15, 1991

VII. CONTACT INFORMATION

Your comments and questions are valued and encouraged. Contact the authors at:

Marek K. Solak, PhD

Schering-Plough Research Institute

2000 Galloping Hill Rd.

Kenilworth, NJ 07033

Email: [email protected]

Monisha Dey, PhD

Schering-Plough Research Institute

2015 Galloping Hill Rd.

Kenilworth, NJ 07033

Email: [email protected]

SAS and all other SAS Institute Inc. product or service names are registered trademarks or

trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration.

Other brand and product names are trademarks of their respective companies.