Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange script in DescTools:::VarTest.default() #108

Open
DrJerryTAO opened this issue Apr 7, 2023 · 1 comment
Open

Strange script in DescTools:::VarTest.default() #108

DrJerryTAO opened this issue Apr 7, 2023 · 1 comment

Comments

@DrJerryTAO
Copy link

Hi @AndriSignorell, when testing a one-sample variance against a hypothesized population variance in VarTest(), the confidence interval appears only for the sample variance but not the ratio of sample variance to the population variance. Would you consider adding the confidence interval of the ratio based on https://stats.libretexts.org/Bookshelves/Introductory_Statistics/Book%3A_Introductory_Statistics_(OpenStax)/11%3A_The_Chi-Square_Distribution/11.07%3A_Test_of_a_Single_Variance?

Further, the confidence interval calculation for appears strange for alternative = "two.sided", as it seems to use a t distribution between line 34 and 41.

      pval <- 2 * min(pchisq(xstat, df), pchisq(xstat, 
        df, lower.tail = FALSE))
      alpha <- 1 - conf.level
      cint <- qt(1 - alpha/2, df)
      cint <- xstat + c(-cint, cint)
      cint <- df * vx/c(qchisq((1 - conf.level)/2, df, 
        lower.tail = FALSE), qchisq((1 - conf.level)/2, 
        df))
@AndriSignorell
Copy link
Owner

Thanks for that. The qt/xstat code is indeed bullshit and some historical phantom code. I dismissed it.
But I don't see, how you would like the confidence intervals to be.
From my point of view, the implementation exactly inverses the teststatistic with
cint <- df * vx / c(qchisq((1 - conf.level)/2, df, lower.tail = FALSE), qchisq((1 - conf.level)/2, df))
Could you be more specific?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants