Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • F test and Chi2 test

    Hi everyone:

    I would like to verify the relationship between F and chi2. But it is found that they are not equal, which step am I doing wrong?

    Thanks

    Click image for larger version

Name:	96843.jpg
Views:	1
Size:	108.5 KB
ID:	1660116


    Code:
    scalar chi2_nu = invchi2tail(60,0.05)
    scalar chi2_de = invchi2tail(120,0.05)
    scalar numerator= chi2_nu/60
    
    scalar   denominator = chi2_de/120
    dis  numerator/denominator
    dis invFtail(60,120,0.05)








  • #2
    You are misinterpreting the equation relating the F and chi square statistics.

    What the equation means it that if X1 is a random variable with a chi square distribution and nu1 df, and X2 is a random variable with a chi square distribution and nu2 df, then X1/X2 has an F distribution with nu1 and nu2 df. You cannot confirm this equality by comparing individual values from these distributions. If you want to get a rough demonstration, you can do it by simulation:

    Code:
    clear*
    set obs 100000
    set seed 1234
    
    gen x1 = rchi2(60)/60
    gen x2 = rchi2(120)/120
    gen x1_by_x2 = x1/x2
    
    
    gen u = F(60, 120, x1_by_x2)
    
    histogram u, bin(20)
    You will see that the histogram of u is roughly a uniform distribution on [0, 1], which confirms that x1/x2 has (approximately) an F distribution with 60 and 120 df. With larger sample sizes, the approximation gets better.

    Comment

    Working...
    X