SAS--Hypothesis Tests for Variances

advertisement
UNC-Wilmington
Department of Economics and Finance
ECN 377
Dr. Chris Dumas
SAS – Hypothesis Tests about Variances
This handout explains how to conduct hypothesis tests about variances in SAS. As an example, we’ll use the
dataset “VarTestsData.xls” located under Handouts on the course website. This dataset contains information on
eight variables for a random sample of 30 North Carolina counties (out of a population of 100 counties) in year
2000. The eight variables are defined in the table below:
Variable Name
CntyName
PopCens
UrbanPop
AgeMedian
UnempRate
HSDropouts
MeanFamInc
Urban
Definition
Name of county
County population in year 2000
Population living in urban areas of county in year 2000
Median age of individuals in county in year 2000
Average unemployment rate in county in year 2000
Number of high school dropouts in county in year 2000
Mean family income in county in year 2000
Variable indicating whether county is “urban” or “rural”.
If urban population in county > rural population in county, then Urban =1
If urban population in county < rural population in county, then Urban = 0
Create a New SAS Program
Add the usual Comments and Options at the top of the SAS program, and then use Proc Import to import the data
from the VarTestsData.xls dataset.
Testing Whether One Variance is Equal to a Given Number (Use PROC MEANS)
The unemployment rate varies from county to county in North Carolina. Suppose someone claims that
the variance of unemployment rates across North Carolina counties in year 2000 was larger than 3.5 (this
claim pertains to the whole population of 100 NC counties).
Use Proc Means in SAS to calculate the sample variance in unemployment rate (UnempRate) for your
sample of 30 N.C. counties. From the Proc Means output, the sample variance is 4.38. Use the sample
variance in the output from Proc Means and a Chi-square test to test whether the (population) variance in
unemployment rate is significantly larger than (one-sided test) the claimed value of 3.5. Do the Chisquare test on paper, using the sample variance number from Proc Means.
Testing Whether Two Variances Are Equal (Use PROC TTEST)
Suppose someone claims that the variation in mean family income (MeanFamInc) across urban NC
counties in 2000 is different from the variation in mean family income in rural counties. Conduct a
hypothesis test to test this claim.
In your SAS program, use Proc ttest for independent samples to test whether the variance of
MeanFamInc for urban counties is different from the variance of MeanFamInc for rural counties, using
variable Urban as your “class” variable in the Proc ttest. Remember: before you run Proc ttest for
independent samples, you much use Proc Sort to sort the data by the class variable, in this case, the
Urban variable. As part of the Proc ttest output, SAS will give the output for an F-test of the equality of
the variances of the two samples. Just use the part of the output about the F-test of variances and discard
the rest of the output. The p-value of the F-test is 0.3930. What does this tell you?
1
UNC-Wilmington
Department of Economics and Finance
ECN 377
Dr. Chris Dumas
/*
SOFTWARE: SAS Statistical Software program, version 9.2
AUTHOR: Dr. Chris Dumas, UNC-Wilmington, Sept. 15, 2015.
TITLE: Hypothesis tests about variances using PROC MEANS and PROC TTEST.
*/
options
options
options
options
helpbrowser=sas;
number pageno=1 nodate nolabel font="SAS Monospace" 10;
leftmargin=1.00 in rightmargin=1.00 in ;
topmargin=1.00 in bottommargin=1.00 in;
proc import datafile="v:\ecn377\VarTestsData.xls" dbms=xls out=dataset01 replace;
run;
proc means data=dataset01 maxdec=2 n max min mean var;
var UnempRate;
run;
proc sort data=dataset01;
by Urban;
run;
proc ttest data=dataset01 h0=0 sides=2 alpha=0.05;
class Urban;
var MeanFamInc;
run;
2
Download