Announcement

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

  • Pearson's Chi-Squared Test - Requesting help with tab2

    I am currently working on an extension for research that requires me to measure whether the allocation of patents to examiners are random. I have sorted the data in order to conduct a Chi-squared test on the last digit to compare it to the expected number (which is the sum of patent applications/10). But I do not how to proceed from there. I have tried using the tabulate command (tabulate expected_no sumoflastdigit, chi2) with many different variations but it all doesn't seem right. There are 1370 observations in my data so some of the combination of variables I've tried also mentioned that there are too many values. Below is a screen capture of part of my data.
    Attached Files

  • #2
    If your image is an accurate guide (please see FAQ Advice #12 on how to give a data example) this should get you closer to where you want to be:


    Code:
    bysort examiner : egen total = total(sumoflastdigit)
    
    by examiner : egen double chisq = total((sumoflastdigit - total/10)^2 / (total/10)) 
    by examiner : gen counts = _N
    
    gen double Pvalue = chi2tail(9, chisq)
    
    format chisq %4.3f
    format Pvalue %06.5f
    
    tabdisp examiner, c(counts total chisq Pvalue)
    counts should be identical to 10 throughout.
    Last edited by Nick Cox; 29 Mar 2022, 03:06.

    Comment

    Working...
    X