Sample 25024: Confidence interval and hypothesis test for variance
Confidence interval and hypothesis test for variance
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.
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.
- EXAMPLE:
-
The data come
from "Closed Loop," Magazine of Mechanical Testing,
June 1980, p.18.
data dat;
input x @@;
cards;
6.2 1.9 4.4 4.9 3.5
4.6 4.2 1.1 1.3 4.8
4.1 3.7 2.5 3.7 4.2
1.4 3.2 2.6 1.5 3.9
;
%inc "<location of your file containing the VARTEST macro>";
%vartest(data= dat ,
var= x ,
alpha= 0.05 ,
var0= 2.25 )
- RESULTS:
- Following is the output from the example presented below. The
first table provides point- and confidence interval estimates.
The second table provides the hypothesis test. In this case, the
test that the variance equals 2.25 is not rejected (p=0.6051).
95% Confidence Intervals for Variance and Std Dev
Lower Upper
Confidence Confidence
Statistic Estimate Limit Limit
Variance 1.98661 1.14894 4.23796
Std Dev 1.40947 1.07189 2.05863
95% Hypothesis Test for
H0: Variance(X) = 2.25
Ha: Variance(X) > 2.25
Chi- Prob>Chi-
Square Square
16.7758 0.6051
Right-click on the link below and select Save to save
the %VARTEST macro definition
to a file. It is recommended that you name the file
vartest.sas
.
Download and save vartest.sas
The %VARTEST macro provides a one-tailed test of the null hypothesis that the variance equals a non-zero constant for normally distributed data. It also provides point- and confidence interval estimates.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> UNIVARIATE
|
Date Modified: | 2007-08-14 03:03:10 |
Date Created: | 2005-01-13 15:03:58 |
Operating System and Release Information
SAS System | SAS/STAT | All | n/a | n/a |