SUPPORT / SAMPLES & SAS NOTES
 

Support

Sample 25024: Confidence interval and hypothesis test for variance

DetailsResultsDownloadsAboutRate It

Confidence interval and hypothesis test for variance

Contents: Purpose / Requirements / Usage / Details / Limitations / Missing Values / References

NOTE: The CIBASIC option in PROC UNIVARIATE provides one- and two-sided confidence intervals for the standard deviation and variance. PROC TTEST provides a confidence interval for the standard deviation using either of two methods.
PURPOSE:
The %VARTEST macro tests the null hypothesis that the variance (or standard deviation) of a set of independent and identically normally distributed values is equal to a specified constant against an alternative that the variance (or standard deviation) exceeds the constant. The macro also provides point- and confidence interval estimates for the variance and standard deviation.
REQUIREMENTS:
Only base SAS software is required.
USAGE:
Follow the instructions in the Downloads tab of this sample to save the %VARTEST macro definition. Replace the text within quotes in the following statement with the location of the %VARTEST macro definition file on your system. In your SAS program or in the SAS editor window, specify this statement to define the %VARTEST macro and make it available for use:
   %inc "<location of your file containing the VARTEST macro>";

Following this statement, you may call the %VARTEST macro. See the Results tab for an example.

The following options are available. The VAR= option is required.

data=
Specifies the SAS data set to be analyzed. If omitted, the last-created dataset is used.
var=
Specifies the variable whose variance and standard deviation is to be estimated and/or tested. Only a single variable name should be given. This parameter is required.
alpha=
Specifies the level for the test and confidence intervals. For given value, alpha, the confidence level is (1-alpha)*100%. The ALPHA= value should be between 0 and 1. If this parameter is omitted, then ALPHA=0.05 resulting in a 95% level test and confidence intervals.

To request that a test of the variance or standard deviation, specify either VAR0= or SIGMA0= but not both. If both are omitted, then only point- and confidence intervals are computed.

var0=
The variance specified by the null hypothesis. The value must exceed zero.
sigma0=
The standard deviation specified by the null hypothesis. The value must exceed zero.
DETAILS:
The %VARTEST macro tests the hypothesis that the variance (or, equivalently, the standard deviation) is equal to a constant. The one-sided alternative hypothesis is that the variance exceeds the constant. It is assumed that the data are independent and identically normally distributed. Point- and confidence interval estimates of the variance and standard deviation are also provided. Note that the confidence interval provided is not necessarily the shortest length interval. The computed interval is such that the tail areas of the chi-square distribution outside the limits are equal.

Results of the test and the point- and confidence interval estimates are available in a data set named _VARTEST after execution of the macro.

LIMITATIONS:
Limited error checking is done. The macro assumes that the data set name and variable names entered are valid and that values of the ALPHA=, VAR0=, and SIGMA0= parameters are within their valid ranges.
MISSING VALUES:
Missing values are omitted from the computations. The sample variance, standard deviation, their confidence intervals and test will then be calculated on the remaining, nonmissing values of the analysis (VAR=) variable.
REFERENCES:
Mendenhall, W. and Scheaffer, R.L. (1973), Mathematical Statistics with Applications, North Scituate, MA: Duxbury Press.

Milton, J.S. and Arnold, J.C. (1995), Introduction to probability and statistics: Principles and applications for engineering and the computing science, New York: McGraw-Hill Inc.




These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.