How do I conduct a One-Sample Chi-Squared Test On Population Variance in R? [duplicate]

First of all, I'm aware that I can use var.test(x, y) for inference on the ratio of two population variances, but my question is regarding inference on one population variance.

According to this source, I should use the function varTest() to conduct a one-sample test on population variance. However, I get an error code whenever I try this, as R could not find this function:

x <- rnorm(50, mean = 4, sd = 1) varTest(x, sigma.squared = 1) # sigma.squared is our null hypothesis for population variance Error in varTest(x, sigma.squared = 1) : could not find function "varTest" 

This is what happens if I try to use var.test() for a one sample test on population variance:

x <- rnorm(50, mean = 4, sd = 1) var.test(x, sigma.squared = 1) Error in var.test.default(x, sigma.squared = 1) : argument "y" is missing, with no default 

No surprise for the second error as I think var.test() is reserved only for inference on the ratio of two population variances.

Is it the case that I'm supposed to use the function varTest, but I simply don't have the package which contains that function installed?

Background Information: I'm running RStudio Version 1.3.959 on macOS Catalina Version 10.15.6 This is a video of the statistical test that I'm trying to conduct in R.

0

1 Answer

The function you link to is part of the EnvStats package. You need to install it and load it before you can execute the function:

install.packages("EnvStats") library(EnvStats) x <- rnorm(50, mean = 4, sd = 1) varTest(x, sigma.squared = 1) #> #> Chi-Squared Test on Variance #> #> data: x #> Chi-Squared = 28.224, df = 49, p-value = 0.01506 #> alternative hypothesis: true variance is not equal to 1 #> 95 percent confidence interval: #> 0.4019175 0.8944284 #> sample estimates: #> variance #> 0.5759921 
0

You Might Also Like