[R] test for a single variance

Greg Snow Greg.Snow at imail.org
Wed Sep 10 18:08:36 CEST 2008

If you are trying to test the hypotheses:

H0: sigma^2 == sigma[0]^2
Ha: sigma^2 != sigma[0]^2

i.e. is the variance of the distribution from which the data came different from the hypothesized value?

Then the normal theory test can be done fairly simply (I don't know of any prepackaged equivalents) by something like:

> pchisq( var(y)*(length(y)-1)/sigma0, length(y)-1, lower.tail= var(y) < sigma0 ) * 2

Assuming "sigma0" is the hypothesized variance and I remember the formula correctly.

However, this is only valid if the data comes from a distribution that is very close to a normal distribution.  Inference on the mean is robust to normality assumptions, but not the variance, hence this is not used much in practice.

If you are really interested in the test on the variance (a good thing, many problems really should look at the variance as the 1st outcome of interest, rather than as a nuisance variable), then a possibly better approach would be to calculate a confidence interval on the variance using something that does not depend on distributional assumptions (bootstrap could be one option) and compare that to the hypothesized value.

Hope this helps,

Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
(801) 408-8111

> -----Original Message-----
> From: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-project.org] On Behalf Of Edna Bell
> Sent: Tuesday, September 09, 2008 4:31 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] test for a single variance
> Dear R Gurus:
> Is there a test for a single variance available in R, please?
> Thanks,
> Edna Bell
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list